1. Home
  2. Docs
  3. REST API
  4. API Guides
  5. Transactional email request example

Transactional email request example

Send an immediate email to your contacts
with or without parameters,
with or without attachments.

The sending can be done synchronously – this is the default mode.
Or asynchronously – in this case you will only get the “queued” response and sending will be done later with a background service.

POST /transactional/emails/send

Request URL:

https://api.inwise.com/rest/v1/transactional/emails/send

*A parallel and almost identical method for sending and email with an HTML that is pre-save in inwise as a template:
POST /transactional/emails/sendTemplate )

Example 1 – Send attach file, using async mode

{
"message": {
    "html": "Hi",
    "subject": "This is the subject",
    "from_email": "newsletter@return-email.com",
    "reply_to": "replyToThis@yopmail.com",
    "from_name": "from rest test",
    "charset": "utf-8",
    "content_type": "html",
    "to": [
      {
        "email": "EmailTest12@yopmail.com",
        "name": "John",
        "type": "to"
      }
    ]
,"attachments":[
{ "type": "text/plain"
,"name":"testtxt.txt",
"content": "this is the content of the text file"
}
]
  }  ,"async": true
}

Example 2 – Basic sending, using async mode

{
"message": {
"html": "html code",
    "text": "body string",
    "subject": "subject string",
    "from_email": "newsletter@return-email.com",
    "reply_to": "test@a.com",
    "from_name": "from me",
    "charset": "utf-8",
    "content_type": "html",
    "to": [
      {
        "email": "ravitb@inwise.com",
        "name": "Ravit",
        "type": "to"
      }
    ],
  }
, "async": true
}

Example 3 – Send template, using tags and parameters, Using sync mode

{
"template_id":20052,
  "message": {
    "subject": "This is the title of the message",
    "from_email": "newsletter@return-email.com",
    "reply_to": "replyToThis@yopmail.com",
    "from_name": "from rest test",
    "charset": "utf-8",
    "content_type": "html",
    "to": [
      {
        "email": "EmailTest12@yopmail.com",
        "name": "Rebecca",
        "type": "to"
      },
   {
        "email": "EmailTest3@yopmail.com",
        "name": "Lily",
        "type": "to"
      }
    ]

,"field_vars": [
   {
         "rcpt": "EmailTest12@yopmail.com",
	"fields": [
	{
	"name": "#field1#",
	"content": "Rebecca"
	}
	]
   }
  , {
         "rcpt": "EmailTest3@yopmail.com",
	"fields": [
	{
	"name": "#field1#",
	"content": "Lily"
	}
	]
   }
]
,"tags":["SendBill"]
  }
}

Example 4 – Send image in the html as an embedded image

{
{ "message": { "html": "hi. this is the pic \"Girl ", "subject": "This is the subject", "reply_to": "replyToThis@yopmail.com", "from_name": "from rest test", "charset": "utf-8", "content_type": "html", "to": [ { "email": "EmailTest21@yopmail.com", "name": "John", "type": "to" } ] , "images": [ { "type": "png", "name": "Untitled.png", "content": "iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAAAAAAcD2kOAAADDUlEQVR4Xu2NQY4cMQwD9/+fTpDVuFym7M4hwA4CDw9uiiy1vn69SV8Z/JQuPfy1U+V+oyXkZ8Aeu6p5quONlrA8SYxd1TzV8UZLWJ4kxq5qNjSJuLwRFXkk5+rqw/UvPInNA4w8nuHP4aUe0KZCfaXDPfkcbvVLBiKMMf7g0Mnlh634Sw8ReehUjeTew11A//h2/Tl56+EHCc3wVEVy0N+w09//88P+Rf+jK0KSCEliq3Lx9x72Wo2EPaeyJ+F91L2HvVCjl53gexit1/2fssvMK2IC0fYwWq/7P2WXmVfEBKLtYbRe93/Kzpm0v+iBiYrk0H4ORz0XQmAGuve4mksPO4IoH6NNvN14hcWR3HtY0cujSvyWAXb42mkMLVl2eMQCbxlgh6+dxtCSZYdHLPCWAXb42mkMLdmmo3YSbYROagzGuzWN70gDJYk2Qic1BuPdmsZ3pIGSRBuhkxqD8W5NSwTKyPtsGNntI0nZZQZl5H02jOz2kaTsMoMy8j4bRnb7SFJ2RrwIbtsaKO8XuZW593BFXpvFriqDKuG1OYS3H67XnEdE6BXUsfAVyF50eLuzfTvQt2I0I3/v4QHP0Wv2xhhtQgfy0sOoLxB6dOjFDker/NLDVbCAcdVDftRDV24F3Hu4c4OY3m1X8H5jpYIFpRj1bAFMWsH7jZUKFpRi1LMFMGkF7zdWKpipa++gXoUxgLbAtYfpKOy31VzTT92a2e1efZiib6L+C1ZQwD0pSziL6ryA3NpYAfekLOEsqvMCcmtjBdyTsknwOoy1bRsyAyZ/6eGTCoLmL5FD9pVo5S89XFzIqEPezoQ5wbXx/ew0kTXk7UyYE1wb389OE1lD3s6EOcG18f1kuiy47T/CGzbA1ppffXgsvvzKpU6YjeWq+kl3iLHrhNlYrqqfdIcYu06YjeWq+kmfoFPbSY8neACfwwuN+jJkzwk9miw7Z6PbhcBgIif0aLLsnI1uFwKDiZzQo8myMY+43XDiFbfICUAlI7/3cJegyeBjKxgS8wauPfwOfQ7/mN52+Dfgq4YutrVOMwAAAABJRU5ErkJggg==" } ], } ,"async": false }

Response code

200 Success Request (without exception)
400 unknown exception

(in this case you can try again a few minutes later)

423 ResourceUseIsAccountLimited
403 Forbidden
409 Conflict
402 PaymentRequired
404 NotFound
500 InternalServerError

(in this case you can try again a few minutes later)

422 UnprocessableEntry

For example with response body: “Parameter value ‘message.from_email’ is not allowed.”

429 APICallWasRateLimited
401 Unauthorized

 

Response body

The response is dependent on your request mode (synchronously sending versus asynchronously sending).
In Sync mode you will get the result immediately.

 

Mode (sync / Async) Scenario Status Reject_reason Transaction_id :
is included
Async When the send request was successful, the email will be later sent from the queue.   queued Not included Yes, included
Sync + Async error in the email format invalid invalid-email Not included
Sync was sent immediately with success Sent Not included Yes, included
Sync The email is in the unsubscribe list rejected unsubscribe Yes, included
sync The email is in the bounce list rejected bounced Yes, included
sync No credit rejected insufficient-funds

 

* There are more reject reasons as: exception, bounce, unsubscribed, no_credit, , cancelled_by_user

*When a sending is Queued or Sent, It is possible to get a later bounce result (because of a failure response from the destination server), That result will appear in the results methods / result webhook.

Get analytics

You can monitor the result of your Async send and Sync send:

How can we help?