# Issues with sending emails via API

**URL:** <https://forum.mautic.org/t/issues-with-sending-emails-via-api/17754>\
**Category:** Product Support\
**Created:** [January 12, 2021, 5:37pm UTC](https://forum.mautic.org/t/issues-with-sending-emails-via-api/17754 "2021-01-12T17:37:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![da644](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/da644/32/4386_2.png) [@da644](https://forum.mautic.org/u/da644)\
**Post date:** [January 12, 2021, 5:37pm UTC](https://forum.mautic.org/t/issues-with-sending-emails-via-api/17754/1 "2021-01-12T17:37:42Z")

</div>

**Your software**  
My Mautic version is: 3.2.2  
My PHP version is: 7.4  
My Database type and version is: 8.0.18

**Your problem**  
I’m trying to use the API to create an email and schedule it to send and most things are working except two. For now, I’m just using Postman to do this so I can get the structure right before coding it into the system that will be generating the email contents. There are two fields, however, that I just cannot get to work, these are `isPublished` and `category`.

`isPublished` is a boolean, so I’ve tried `true` and `1` but the field is always set to `false` in the response and when viewed in the Mautic interface.

`category` says its type is “object” and I’ve tried passing all manner of things in that field, but the only thing I’ve found that partially works is to set the key to `category[]` as you do for an array and whilst this then sets a category, it always sets it to the value of category ID 1. I’ve tried `category[0]['id']` and `category['id']` as well, with the value set to other valid ID’s, e.g. 3, 4, 5, etc… but it always just sets it to 1.

Can someone please point me in the right direction or maybe to a guide as to how the API excepts none string values to be passed (I only found out about the array one from another forum post about the `lists` value). I’m thinking it might be a PHP specific thing as I’m not all that familiar with PHP and Mautic is build on PHP, so I guess it is how PHP expects the values to be passed in the POST data.

Thanks.

Andrew.

---

<div class="post-metadata">

**Author:** ![da644](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/da644/32/4386_2.png) [@da644](https://forum.mautic.org/u/da644)\
**Post date:** [January 13, 2021, 11:34am UTC](https://forum.mautic.org/t/issues-with-sending-emails-via-api/17754/2 "2021-01-13T11:34:41Z")

</div>

I’ve managed to work out one of these, which appears to be a bug in Mautic. The user role I created only had permission to “Publish Own”, however, to get `isPublished` to be accepted as `1` (true) I had to add the permission “Publish Others” to the role. As it is all done in one call, it is the users own email they are publishing, so surely “Publish Own” should be enough permission.

Still no joy with the category.

---

<div class="post-metadata">

**Author:** ![da644](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/da644/32/4386_2.png) [@da644](https://forum.mautic.org/u/da644)\
**Post date:** [January 14, 2021, 10:39am UTC](https://forum.mautic.org/t/issues-with-sending-emails-via-api/17754/3 "2021-01-14T10:39:58Z")

</div>

Have another issue now with the `utmTags` fields, which are not even in the documentation for emails but can be set in the interface and are returned in the API when you create an email as:

```auto
        "utmTags": {
            "utmSource": null,
            "utmMedium": null,
            "utmCampaign": null,
            "utmContent": null
        },

```

But there seems to be no way to set them via the API. Sending them with the key name like `utmTags['utmSource']` returns an error:

```auto
{
    "errors": [
        {
            "code": 400,
            "message": "utmTags: This form should not contain extra fields.",
            "details": {
                "utmTags": [
                    "This form should not contain extra fields."
                ]
            }
        }
    ]
}

```

and sending with the key name like `utmTags->utmSource` they are just ignored, so similar to the `category` issue above.

Has anyone got any insight on this?
