Send Email (Single)

POST /email/Single/

This endpoint is used to send a single email to a single recipient. The emails can be sent immediately or scheduled for delivery at a later date and time.

Usage scenario for this endpoint:

This endpoint is especially useful for sending recipient-specific one-time alert emails or updates.

Method Details
HTTP Method POST
Content type Application/json
Requires authentication? YES
Rate limited? YES
Headers User-Agent
Module Email
End Point

https://apiemail.mainbrainer.com/email/single

Required Parameters Usage Description
Access Token or API Key Authorization: Bearer {token} header Pass the API key in the request header for request authentication. Read more about our authentication process.
Recipient Included email "[email protected]" This parameter specifies the email address at which you want to send the email.
Sender Name From Email Name This parameter specifies the name that you want to display as the sender name for the email. This name helps the email recipients identify who sent them the email.
Sender From From Email address Example. [email protected] This parameter specifies the email address you want to display as the sender address for the email and the name that you want to display as the sender name for the email.
These details helps the email recipients identify who sent them the email.
Note: By default, you can only use [email protected] as the sender email for your emails. In case you wish to use your domain address as the sender email, please write to us at [email protected].
Reply to email reply-to emails This parameter specifies the email address at which you would like to receive replies from your email recipients, and the display name that you wish to use for the address.
Subject Use Nice and catchy Subject lines (you can also use Personailization in your subject lines) This parameter specifies the text that you would like to appear in the email's subject field.
Preheader Preheader can be Dynamic using Personailization tags This parameter specifies the text you would like to appear in the email's preheader area, i.e., the area after the subject line.
Email Campaign ID Use Email Template ID of your MainBrainer Account If you are using the MainBrainer Email Creator to design your email, pass the Email Template ID of the email you want to send as the parameter value.
Email Template ID is the unique identifier for an email campaign created in your MainBrainer account.
HTML Body Use your own HTML If you are designing your email in HTML, encode it into Base64 format and pass it as the parameter value.
Webhook URL Delivery Status Use this parameter to specify the webhook URL where you want to receive delivery status updates for the email being sent. When the destination email client returns a delivery status, a status is instantly posted to this webhook URL. Using a Webhook enables your application to receive delivery updates as they happen, in an easily parsable JSON format.
Updates will be sent for the following delivery statuses:
+ Processed
+ Dropped
+ Deferred
+ Bounce
+ Delivered
+ Open
+ Click
+ Spam Report
+ Unsubscribe
Note

To define the content of the email you wish to send, it is mandatory to specify either the parameter- Email Body or the parameter - Email Campaign ID.

Note:

To identify the recipients for the email sending, it is mandatory to specify either the parameter - List ID or the parameter - recipients.

Note:

Emails will only be sent to contacts if their emailOptIn status is true.

Optional Parameters Usage Description
Personalization Substitution Tags personalizationSubstitutionTags : { "tagName": "[name]", "tagValue": "Sink" } These tags help you insert dynamic data at the time of email sending. In order to substitute the data at the time of the sending, follow the pattern "substitution_tag":"value to substitute" for the key/value pairs. In case you use the parameter 'recipients' to identify the email recipients, the substitutions will work as specified. But in case you use the parameter 'listID' to identify the recipients, the data will get substituted on the basis of the information stored in the MainBrainer CRM for the recipient email address.
ScheduledDate-time RFC3339 format (Y-m-d\TH:i:sP) Pass the scheduled date and time of the email distribution in RFC3339 format (Y-m-d\TH:i:sP). The date and time passed in this parameter will be converted as per the offset value specified in your account settings.
Note:

The scheduled date and time of the email distribution should be specified in the RFC3339 format (Y-m-d\TH:i:sP)

Email and Email Template ID

Every email campaign created in MainBrainer is assigned an Email Campaign ID that acts as a unique identifier for the email campaign.

To read more about creating email campaigns on MainBrainer, refer to our detailed article series on it here.

Response

In case there is a problem with the data in the request body, or if there are no properties included in the request, we'll return a 400 and 422 response along with additional details listing the cause.

Response Codes and their meanings

Response Code Code Meaning
202 Success, This endpoint returns a 202 Accepted response on success along with the details of the sent email. (As demonstrated below in the sample response body
400 Error - Bad Request The endpoint returns a 400 response if the API request had an incorrect syntax.
422 Error - Unprocessable Entity Response The endpoint returns a 422 response if the API request had invalid data.
Copy
Copied

This example demonstrates how to send a single email. 


post url: https://apiemail.mainbrainer.com/email/single

{
"recipient": {
  "to": "[email protected]",
  "personalizationSubstitutionTags": [
    {
      "tagName": "[name]",
      "tagValue": "Sink"
    }
  ]
},
"senderFrom": {
  "email": "[email protected]",
  "displayName": "MainBrainer"
},
"replyTo": {
  "email": "[email protected]",
  "displayName": "MainBrainer"
},
"subject": "hi [name] Weekend Discount Sale upoto 40% Off",
"preHeaderText": "Grab 40% Discount only for next 2 hours ",
"emailBody": "Your email HTML encoded in base64 format",         
"scheduleDateTime": "2021-10-24T14:15:22Z",
"emailCampaignId": "00000000-0000-0000-0000-000000000000",
"webHookUrl": "https://webhook-url.yourdomain.com"
}

Returns a 202 Accepted response with content on success.
    

Response Body

Copy
Copied
{
"status": "Success",
"message": "Successfully accepted.",
"data": {
    "QueueId": "d6704765-7a6e-4f03-a6fd-10b2cd651482",
    "QueuedTimestamp": 1630487627367
}
}