# API call to send email with JSON Body and TWIG Template Module

**URL:** <https://forum.mautic.org/t/api-call-to-send-email-with-json-body-and-twig-template-module/29473>\
**Category:** Product Support\
**Created:** [September 28, 2023, 1:36pm UTC](https://forum.mautic.org/t/api-call-to-send-email-with-json-body-and-twig-template-module/29473 "2023-09-28T13:36:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adzzz](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@adzzz](https://forum.mautic.org/u/adzzz)\
**Post date:** [September 28, 2023, 1:36pm UTC](https://forum.mautic.org/t/api-call-to-send-email-with-json-body-and-twig-template-module/29473/1 "2023-09-28T13:36:35Z")

</div>

**Your software**  
My Mautic version is: 4.4.8  
My PHP version is: 7  
My Database type and version is: MySQL 5.7.43

**Your problem**  
My problem is:

I am having an issue evaluating JSON that has been sent in an API request to send an email while using the MTC Extendee TWIG template module.

/api/emails/144/contact/692034/send  
I am calling the send email API with a JSON body :

{  
“tokens”: {  
“cart”: [{“sku”:“A100”,“name”:“Item 1”},{“sku”:“Z200”,“name”:“Item 2”}]  
}  
}

and on the twig template side:

{% for item in cart %}  
Name: {{ item.name }}  
SKU: {{ item.sku }}  
{% endfor %}

however in my email, it does not evaluate this TWIG and print the items in the array. Could you please tell me if I am doing something incorrect.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [September 29, 2023, 8:37am UTC](https://forum.mautic.org/t/api-call-to-send-email-with-json-body-and-twig-template-module/29473/2 "2023-09-29T08:37:31Z")

</div>

MTC extendee twig works differently.  
You need to place the json in a variable (for example in abandoned cart contact variable)  
Then you add to your Twig Template:

{% for item in cart %}  
Name: {{ item.name }}  
SKU: {{ item.sku }}  
{% endfor %}

Then you send the email with using the token for that twig template: {twigtemplate=1} for example.
