Email
Send email over API

Send Email over API

You can use the Email API (opens in a new tab) as another way of sending emails to your customers.

Prerequisites

To send an email with Infobip, your domain needs to be active in the Infobip system. Verify your email domain on the User Profile in your Infobip account (opens in a new tab).

Fully-Featured Email

To send a fully-featured email⁠ - send one or more email messages with attachments to one or more destination addresses. For more details, see Send a Fully Featured Email (opens in a new tab) reference documentation.

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

    curl -s --user user:password \
    https://./3/send \
    -F from='Jane Smith ' \
    -F to='[email protected]' \
    -F to='[email protected]' \
    -F cc='[email protected]' \
    -F cc='[email protected]' \
    -F bcc='[email protected]' \
    -F bcc='[email protected]' \
    -F subject='Mail subject text' \
    -F text='Mail body text' \
    --form-string html='Html bodyRich HTML message body.' \
    -F attachment=@files/image1.jpg

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 the Infobip 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 Template language within your HTML content and define the placeholder values in the to parameter of the request. Add any of the available Template language constructs in the HTML content to solve substitutions, conditional statements, or iterations.

To use the new Template language constructs in an API request, provide the parameter templateLanguageVersion=2.

If you prefer to use the old handlebar {{helpers}} in your HTML, do not specify the TemplateLanguageVersion parameter in the API request. The following table shows examples for the handlebar {{helpers}}.

See: Send Fully Featured Email (opens in a new tab) reference documentation.

Handlebar helper examples

HTML REQUESTTO JSON REQUESTRESOLVED HTML
Helper Example: #eq
 {{#eq name "Bob"}}         Dear {{name}}   {{else}}       Hi {{name}}   {{/eq}} {    "to": "[email protected]",    "placeholders": {    "name": "Bob"    }  } Dear Bob
Helper Example: #each
 {{#each friends}}      Hi {{this}} {{/each}}{    "to": "[email protected]",    "placeholders": { "friends":["Bob","John","Jack"]  }  } Hi Bob Hi John Hi Jack
Helper Example: #unlessEq
   {{#unlessEq name "Bob"}}     Dear {{name}}   {{else}}    Hi {{name}}  {{/unlessEq}}{    "to": "[email protected]",    "placeholders": {    "name": "Bob"    }  } Hi Bob
Helper Example: #default
 Hi {{name}}{    "to": "[email protected]",    "placeholders": {    "name": "Bob"    }  }Hi Bob
Helper Example: #gt
  {{#gt age 12}}    Welcome {{name}}!  {{else}}    Hey {{name}}, you are under age  {{/gt}}{    "to": "[email protected]",    "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": "[email protected]",    "placeholders": {    "name": "Bob" , "age":10   }  }  Welcome Bob!
Helper Example: #equalsIgnoreCase
  {{#equalsIgnoreCase gender "male"}}    Dear Mr {{name}}  {{else}}    Dear customer  {{/equalsIgnoreCase}}{    "to": "[email protected]",    "placeholders":{    "name": "Bob" , "gender": "MALE"   }  } Dear Mr Bob
Helper Example: #gte
  {{#gte age 12}}    Welcome {{name}}!  {{else}}    Hey {{name}}, you are under age  {{/gte}}{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "age":10   }  } Hey Bob, you are under age
Helper Example: #lte
 {{#lte age 12}}    Welcome {{name}}!  {{else}}    Sorry {{name}}, This is kids arena  {{/lte}} {    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "age":10   }  }Welcome Bob!
Helper Example: #compare
 {{#compare name "!=" "Bob"}}Hi {{name}}{{else}} Dear Bob{{/compare}}{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Jane" , "age":10   }  }Hi Jane
Helper Example: #equals
 {{#equals name "Bob"}}         Dear {{name}}   {{else}}       Hi {{name}}   {{/equals}} {    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob"    }  } Dear Bob
Helper Example: #lessThan
{{#lessThan  age 12}}    Welcome {{name}}!  {{else}}    Sorry {{name}}, This is kids arena  {{/lessThan}}{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "age":10   }  } Welcome Bob!
Helper Example: #lessThanOrEquals
{{#lessThanOrEquals age 12}}    Welcome {{name}}!  {{else}}    Sorry {{name}}, This is kids arena  {{/lte}}{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "age":10   }  }Welcome Bob!
Helper Example: #greaterThan
{{#greaterThan  age 12}}    Welcome {{name}}!  {{else}}    Hey {{name}}, you are under age  {{/greaterThan }}{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "age":10   }  } Hey Bob, you are under age
Helper Example: #greaterThanOrEquals
{{#greaterThanOrEquals age 12}}    Welcome {{name}}!  {{else}}    Hey {{name}}, you are under age{{/greaterThanOrEquals }}{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "age":10   }  } Hey Bob, you are under age
Helper Example: #when
{{#when name "!=" "Bob"}} Hi {{name}}{{else}}Dear Bob{{/when}}{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Jane" , "age":10   }  } Hey Jane
Helper Example: #contains
{{#contains friends "Bob"}}      Hi {{this}} {{/each}}{    "to": "john.smith@somedomain.com",    "placeholders": { "friends":["Bob","John","Jack"]  }  }Hi Bob
Helper Example: #and
{{#and great magnificent}}Bob{{else}}Jane{{/and}} {    "to": "john.smith@somedomain.com",    "placeholders": { "great": true, "magnificent": true }  } Hi Bob
Helper Example: #formatNumber
{{#formatNumber price}} {{/formatNumber}}{    "to": "john.smith@somedomain.com",    "placeholders": { "price":10000 }  }10,000
Helper Example: #isTruthy
{{#isTruthy Male}}Hi Bob{{else}}Hi Jane{{/isTruthy}}{    "to": "john.smith@somedomain.com",    "placeholders": { "Male": true }  } Hi Bob
Helper Example: #isFalsey
{{#isFalsey Male}}Hi Bob{{else}}Hi Jane{{/isFalsey}}{    "to": "john.smith@somedomain.com",    "placeholders": { "Male": true }  } Hi Jane
Helper Example: #ifEven
{{#ifEven age}}Hi Bob{{else}}Hi Jane{{/ifEven}}{    "to": "john.smith@somedomain.com",    "placeholders": { "age": 20 }  } Hi Bob
Helper Example: #ifOdd
{{#ifOdd age}}Hi Bob{{else}}Hi Jane{{/ifOdd}}{    "to": "john.smith@somedomain.com",    "placeholders": { "age": 20 }  } Hi Jane
Helper Example: #ifNth
{{#ifNth age balance}}Hi Bob{{else}}Hi Jane{{/ifNth}}{    "to": "john.smith@somedomain.com",    "placeholders": { "age": 20, "balance": 20000 }  } Hi Bob
Helper Example: #is
{{#is name "Bob"}}Dear {{name}}{{else}}Hi {{name}}{{/is}}{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "age":10   }  } Dear Bob
Helper Example: #isnt
{{#isnt name "Bob"}}Dear {{name}}{{else}}Hi {{name}}{{/isnt}}{    "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "age":10   }  } Hi Bob
Helper Example: #neither
{{#neither great magnificent}}A{{else}}B{{/neither}}{    "to": "john.smith@somedomain.com",    "placeholders": { great: true, magnificent: false }  }B
Helper Example: #not
{{#not great}}A {{else}} B{{/not}}{    "to": "john.smith@somedomain.com",    "placeholders": { great: true, magnificent: false }  } B
Helper Example: #or
{{#or great magnificent}}A{{else}}B{{/or}}{    "to": "john.smith@somedomain.com",    "placeholders": { great: true, magnificent: false }  } A
Helper Example: #unlessGt
{{#unlessGt physics chemistry}}Hi {{name}}your score in Physics :{{physics}}{{else}}Hi {{name}}your score in Chemistry : {{chemistry}}{{/unlessGt}}{   "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "physics": 70 , "chemistry": 75 }  } Hi Bob your score in Physics : 70
Helper Example: #unlessLt
{{#unlessLt physics chemistry}}Hi {{name}}your score in Physics : {{physics}}{{else}}Hi {{name}}your score in Chemistry : {{chemistry}}{{/unlessLt}}{   "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "physics": 70 , "chemistry": 75 }  } Hi Bob your score in Chemistry : 75
Helper Example: #unlessGteq
{{#unlessGteq physics chemistry}}Hi {{name}}your score in Physics : {{physics}}{{else}}Hi {{name}}your score in Chemistry : {{chemistry}}{{/unlessGteq}}{   "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "physics": 70 , "chemistry": 75 }  } Hi Bob your score in Physics : 70
Helper Example: #unlessLteq
{{#unlessLteq physics chemistry}}Hi {{name}}your score in Physics : {{physics}}{{else}}Hi {{name}}your score in Chemistry : {{chemistry}}{{/unlessLteq}}{   "to": "john.smith@somedomain.com",    "placeholders": {    "name": "Bob" , "physics": 70 , "chemistry": 75 }  } Hi Bob your score in Chemistry : 75

Email Delivery Reports

The Email deliver reports (opens in a new tab) method allows you to get one-time delivery reports for sent emails.

NOTE

The delivery report is returned only once. Additional delivery report requests return an empty collection.

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

The Get Email logs (opens in a new tab) 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 is 200 OK  and the message logs are returned.

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

If you use this method too many times in a short period of time, you receive 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

The fields from, to, and limit accept a single parameter, which is used to filter response message logs.

Get Logs With Date Range and General Status Filters

The fields sentSince and generalStatus accept a single parameter, which is used to filter response message logs.

Get Logs Bulk ID

To use this method, use the bulkId returned in the response for an email/emails you wish to filter message logs for.

Tracking Notifications

If trackingUrl is passed, you are 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

json
 
    {
      "notificationType": "OPENED",
      "domain": "sendingdomain.com",
      "recipient": "[email protected]",
      "sendDateTime": 1517652288663,
      "messageId": "zl3cf7frmy48ueavnnxy",
      "callbackData": "Email open and click callback data",
      "bulkId": "8pok2duu132mojj587zc",
      "recipientInfo": {
        "deviceType": "Desktop",
        "os": "Windows XP",
        "deviceName": "PC"
      }
    }
 

Click Notifications

json
 
    {
      "notificationType": "CLICKED",
      "domain": "sendingdomain.com",
      "recipient": "[email protected]",
      "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"
      }
    }
 

Need assistance

Explore Infobip tutorials

Encountering issues

Contact our support

What's new? Check out

Release notes

Unsure about a term? See

Glossary

Research panel

Help shape the future of our products
Service Terms & ConditionsPrivacy policyTerms of use