# Create email API?

**URL:** <https://forum.mautic.org/t/create-email-api/23818>\
**Category:** General Discussion\
**Created:** [April 21, 2022, 4:03am UTC](https://forum.mautic.org/t/create-email-api/23818 "2022-04-21T04:03:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oguruma](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/oguruma/32/1003_2.png) [@oguruma](https://forum.mautic.org/u/oguruma)\
**Post date:** [April 21, 2022, 4:03am UTC](https://forum.mautic.org/t/create-email-api/23818/1 "2022-04-21T04:03:08Z")

</div>

I’m trying to make a new email with the API. I’m using the code below. I get no errors, but the email doesn’t get created. If I use the API with the same user (the user has full permissions for the purpose of testing), the API will create a user. It doesn’t create an email for testing, however.

```auto
function makeEmail() {
	$loginname = 'login';
	$password = 'sectet';
	$siteurl = 'my.mautic.com';
	$curl = curl_init();
// Set some options - we are passing in a user agent too here
  curl_setopt_array($curl, array(
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_URL => "https://".$loginname.":".$password."@".$siteurl."/api/emails/new",
  CURLOPT_USERAGENT => 'Mautic Email Maker',
  CURLOPT_POST => 1,
// posting the payload
  CURLOPT_POSTFIELDS => array(
    'fromName' => 'Joe',
    'name' => 'The email name',
    'subject' => 'I am the subject',
    'language' => 'English',
    'emailType' => 'list',
    'isPublished' => 0,
    'customHtml' => '<h1> Hello World </h1>',
    'plainText' => '',
    'createdBy' => 1,
    'createdByUser' => 'Auto', 
   'category' => null,
    'useOwnerAsMailer' => 0,
    'lists[]' => 1,
     'publishUp' => date("Y-m-d").' 16:00:00', 
     'publishDown' => date("Y-m-d").' 18:00:00',
    'unsubscribeForm' => null
  )
));
curl_exec($curl);
}

makeEmail();
?>

```

---

<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:** [April 21, 2022, 12:48pm UTC](https://forum.mautic.org/t/create-email-api/23818/2 "2022-04-21T12:48:28Z")

</div>

Oh yes.  
I had the same issue. Nothing worked. Until I tried to add:

‘template’ =\> ‘blank’,

Let me know if it solves your problem.

Joey

---

<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:** [April 21, 2022, 12:49pm UTC](https://forum.mautic.org/t/create-email-api/23818/3 "2022-04-21T12:49:59Z")

</div>

Also: language should be “en”
