Send Email over API

You can use API as another way of sending emails to your customers.

Fully-Featured Email

To send a fully-featured email⁠ - send one or more email message with attachments to one or more destination addresses - refer to the Send a Fully Featured Email article on the Infobip API developer hub.

Property name

Type

Description

from

string

Email address with optional sender name. Example: "Jane Doe <jane.doe@somecompany.com>".

to

string

Email address of the recipients with optional placeholder values for personalized content.

replyTo

string

Email address to which recipients of the email can reply.

subject

string

Message subject.

text

string

Body of the message.

html

string

HTML body of the message. If html and text fields are present, text field will be ignored and html will be delivered as message body.

templateId

int

Template identifier based on which the email message is generated. Create the template in the web interface. If the templateId is present then html and text values are ignored. This field supports value of broadcast templateId only. Content templateId is not supported.

defaultPlaceholders

string

Default placeholder values used for all recipients. The values are used to generate the email message.

attachment

file

File attachment.

bulkId

string

The ID uniquely identifies the sent Email request. This filter will enable you to query delivery reports for all the messages using just one request. You will receive a bulkId in the response after sending an Email request. If you don't set your own bulkId, unique ID will be generated by our system and returned in the API response.

messageId

string

The ID that uniquely identifies the message sent for a recipient.

sendAt

datetime

Date and time when the message is to be sent. Used for scheduled Email (Email is not sent immediately, but at scheduled time).

intermediateReport

boolean

The real-time Intermediate delivery report that will be sent on your callback server. Can be true or false.

notifyUrl

string

The URL on your callback server on which the Delivery report will be sent.

notifyContentType

string

Preferred Delivery report content type. Can be application/json or application/xml.

callbackData

string

Additional client's data that will be sent on the notifyUrl. The maximum value is 4000 characters.

track

boolean

Enable or disable open and click tracking. Can be true or false.Default value is true. Passing true will only enable tracking and the statistics would be visible in web portal interface alone. This can be explicitly overridden by trackopens and trackclikcs.

trackopens

boolean

This parameter enables or disables track open feature. Can be true or false.

trackclicks

boolean

This parameter enables or disables track click feature. Can be true or false.

trackingUrl

string

The URL on your callback server on which the open and click notifications will be sent. If you are passing this parameter then track=true will be assigned, you don't need to pass track=true separately. See Tracking Notifications for more details.

inlineImage string Using an inline image, it is possible to insert the image file inside the HTML code of the email by using cid:FILENAME instead of providing any external link to image.

Request example

curl -s --user user:password \
https://e6jqr.api.infobip.com/email/1/send \
-F from='Jane Smith <jane.smith@somecompany.com>' \
-F to='john.smith@somedomain.com' \
-F replyTo='all.replies@somedomain.com' \
-F subject='Mail subject text' \
-F text='Mail body text' \
--form-string html='<h1>Html body</h1><p>Rich HTML message body.</p>' \
-F attachment=@files/image1.jpg \
-F bulkId='customBulkId' \
-F intermediateReport='true' \
-F notifyUrl='https://www.example.com/email/advanced' \
-F notifyContentType = 'application/json' \
-F callbackData = 'DLR callback data'

Send Email to Multiple Recipients

Send the same email to multiple recipient addresses by including more than one to parameters in the request. 

Send an Email With Multiple Attachments

To send an email with more than one attachment, add multiple attachment parameters in the request. 

Send Email to Multiple To, Cc, Bcc Recipients

Send the same email to multiple recipient addresses by including more than one to, cc, bcc parameters in the request.

curl -s --user user:password \
https://e6jqr.api.infobip.com/email/2/send \
-F from='Jane Smith <jane.smith@somecompany.com>' \
-F to='john.smith@somedomain.com' \
-F to='jane.smith@somedomain.com' \
-F cc='juliet.smith@somedomain.com' \
-F cc='abram.smith@somedomain.com' \
-F bcc='joy.smith@somedomain.com' \
-F bcc='clare.smith@somedomain.com' \
-F subject='Mail subject text' \
-F text='Mail body text' \
--form-string html='<h1>Html body</h1><p>Rich HTML message body.</p>' \
-F attachment=@files/image1.jpg

DISCLAIMER

  • If all recipients in the to field are rejected, then the entire request will be rejected.
  • Placeholders are not allowed when cc/bcc is provided.
  • Tracking of clicks and opens events are not supported when cc/bcc is provided.
  • Duplicate email addresses across to/cc/bcc is not supported and will result in undefined behavior. Validation/filters will be added later to remove duplicates.
  • Resource https://e6jqr.api.infobip.com/email/1/send does not support cc/bcc feature.

Send Personalized Emails Using Templates

Send personalized emails by adding placeholder values within the to parameter of the request. If you want to send the message based on a previously defined template, pass the template identifier value in the templateId parameter. To manage Templates login to Infobip Portal web interface

Send an Email With Custom MessageID

Send emails with custom messageId by including your unique messageId within the to parameter of the request.

Send Emails With Dynamic Content

To send email with dynamic content use the handlebar helpers within your HTML content and define the placeholder values in the to parameter of the request. Add any of the available handlebar {{helpers}} in the HTML content to solve for substitution, conditional statements or iterations.

Refer to the Send Fully Featured Email article on the Infobip API Developer Hub for more information.

Handlebar helper examples

HTML REQUEST

TO JSON REQUEST

RESOLVED HTML

Helper Example: #eq

   {{#eq name "Bob"}}   Dear {{name}}   {{else}}   Hi {{name}}   {{/eq}}    Dear Bob 

  {{#eq name "Bob"}}

    Dear {{name}}

  {{else}}

    Hi {{name}}

  {{/eq}}

{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob"    }  }

 Dear Bob

Helper Example: #each

 {{#each friends}}

      Hi {{this}}

   {{/each}}

{    "to": "john.smith@somedomain.com",    "placeholders": { "friends":["Bob","John","Jack"]  }  }

 Hi Bob Hi John Hi Jack

Helper Example: #unlessEq

   {{#unlessEq name "Bob"}}

     Dear {{name}}

   {{else}}

    Hi {{name}}

  {{/unlessEq}}

{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob"    }  }

 Hi Bob

Helper Example: #default

 Hi {{name}}

{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob"    }  }

Hi Bob

Helper Example: #gt

  {{#gt age 12}}

    Welcome {{name}}!

  {{else}}

    Hey {{name}}, you are under age

  {{/gt}}

{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "age":10   }  }

  Hey Bob, you are under age

Helper Example: #lt

  {{#lt age 12}}

    Welcome {{name}}!

  {{else}}

    Sorry {{name}}, This is kids arena

  {{/lt}}

{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "age":10   }  }

  Welcome Bob!

Helper Example: #equalsIgnoreCase

  {{#equalsIgnoreCase gender "male"}}

    Dear Mr {{name}}

  {{else}}

    Dear customer

  {{/equalsIgnoreCase}}

{    "to": "john.smith@somedomain.com",    "placeholders":

{    "name": "Bob" , "gender": "MALE"   }  }

 

 

Email Delivery Reports

This method allows you to get one-time delivery reports for sent emails.

NOTE

Delivery report will be returned only once. Additional delivery report request will return an empty collection.

Parameters

Property name

Type

Description

bulkId

string

The ID uniquely identifies a group of Email requests. This filter will enable you to query delivery reports for all the messages with the same bulk id using just one request.

messageId

string

Message ID for which report is requested.

limit

int

Maximum number of reports.

 

GET /email/1/reports

                  

 

 

 

 

 

 

Get Reports by Message ID

GET /email/1/reports?messageId=

Get the Initial Two Delivery Reports

GET /email/1/reports?limit=2 HTTP/1.1

Get Reports by Bulk ID

GET /email/1/reports?bulkId=lrzkq6gatdkxouhrkgni HTTP/1.1

Email Messages Logs

This method allows you to get logs for email messages. None of the query parameters is mandatory for this request. Any combination of parameters can be used to filter results. Some examples are shown below.

LOGS AVAILABILITY

Email logs are available for the last 48 hours!

Response format 
If successful, the response header HTTP status code will be 200 OK and the message logs will be returned. 

If you try to send a message without authorization, you will get a response with HTTP status code 401 Unauthorized.

If you use this method too many times in a short period of time, you will get the 429 Too Many Requests status code. This prevents misusing logs in cases where reports would be more appropriate. 

Get Logs With Multiple Messageid Filters

From, to and limit accept a single parameter which will be used to filter response message logs. 

Get Logs With Date Range and General Status Filters

SentSince and generalStatus accept a single parameter which will be used to filter response message logs.

Get Logs Bulk ID

To use this method to get logs for your email messages, check out the Email Message Logs article on the Infobip API Developer Hub.

Tracking Notifications

If trackingUrl is passed, you will be notified whenever the email is opened or an URL in the email is clicked by the recipient. The structure of the data passed in the open and click notifications is shown below.

Open Notifications

{
  "notificationType": "OPENED",
  "domain": "sendingdomain.com",
  "recipient": "john.smith@somecompany.com",
  "sendDateTime": 1517652288663,
  "messageId": "zl3cf7frmy48ueavnnxy",
  "callbackData": "Email open and click callback data",
  "bulkId": "8pok2duu132mojj587zc",
  "recipientInfo": {
    "deviceType": "Desktop",
    "os": "Windows XP",
    "deviceName": "PC"
  }
}

Click Notifications

{
  "notificationType": "CLICKED",
  "domain": "sendingdomain.com",
  "recipient": "jane.smith@somecompany.com",
  "url": "http://www.example.com/landingpage.html",
  "sendDateTime": 1517652288646,
  "messageId": "zsf6q5vjgn1y6qqn65g7",
  "callbackData": "Email open and click callback data",
  "bulkId": "8pok2duu132mojj587zc",
  "recipientInfo": {
    "deviceType": "Desktop",
    "os": "Windows XP",
    "deviceName": "PC"
  }
}