# Using (REST-API) tokens in template mails with newlines or HTML tags?

**URL:** https://forum.mautic.org/t/using-rest-api-tokens-in-template-mails-with-newlines-or-html-tags/22589
**Category:** Product Support
**Tags:** mautic-3
**Created:** [February 4, 2022, 7:26am UTC](https://forum.mautic.org/t/using-rest-api-tokens-in-template-mails-with-newlines-or-html-tags/22589 "2022-02-04T07:26:41Z")
**Posts on this page:** 1
**Showing post:** 8

<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:30am UTC](https://forum.mautic.org/t/using-rest-api-tokens-in-template-mails-with-newlines-or-html-tags/22589/8 "2022-11-23T04:30:15Z")

</div>

@imog @khalid_zamer

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 (also within n8n) 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. 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?**

EDIT: I started a new thread on this [here](https://forum.mautic.org/t/encoding-html-to-pass-through-customhtml-item-in-api-call/26166).

EP

---

_[View the full topic](https://forum.mautic.org/t/using-rest-api-tokens-in-template-mails-with-newlines-or-html-tags/22589)._
