# Encoding HTML to pass through "customHtml" item in API call

**URL:** <https://forum.mautic.org/t/encoding-html-to-pass-through-customhtml-item-in-api-call/26166>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [November 23, 2022, 4:36am UTC](https://forum.mautic.org/t/encoding-html-to-pass-through-customhtml-item-in-api-call/26166 "2022-11-23T04:36:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![entrepositive](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/entrepositive/32/9645_2.png) [@entrepositive](https://forum.mautic.org/u/entrepositive)\
**Post date:** [November 23, 2022, 4:36am UTC](https://forum.mautic.org/t/encoding-html-to-pass-through-customhtml-item-in-api-call/26166/1 "2022-11-23T04:36:05Z")

</div>

I am reading in content in markdown, convert to HTML, then need to pass that into a Mautic segment email. I set up an API call to create a new segment/list email. It seems to work although not 100% correctly.

If I pass the full-email HTML through the “customHtml” item in the JSON to Mautic, the request fails, presumably because of the “quotes”. If I encode the HTML, it works and builds the HTML correctly in Mautic.

So my question is: **How do I encode this HTML programmatically?**

EP

> **Your software**  
> My Mautic version is: 4.1.2  
> My PHP version is: 7.4.30  
> My Database type and version is: Mysql 8.0.30
