XM

Communication - Send Email

Path:

POST /email/send

Customers want to be notified on important events, particularly, the ones related to their orders. This API faciliates sending template-driven email notification. Other types of templates can be added for customer engagement such as feedback, new promotions and offers, etc.

Headers

Content-Type : application/json

x-site-context : { "date": "2020-08-28T02:35:27.787Z", "channel": 12, "account": 5f493c9f30ec2a0007a94fc8", "stage": "sandbox" }

x-api-key :d41d8cd98f00b204e9800998ecf8427e

Parameters

Type: Body

Name: Recipient email address, email subject, and email template.

Required: true

Sample Request

{
"subject": "Example email",
"template": "<h1>Hello World</h1><p> Hello, </p><p> This is a test email.</p>",
"recipientEmail": ["[email protected]"]
}

Sample Response

Response Code: 200

Message: OK

Description: You will see this message when the notification email is successfully sent.

[
{
"statusCode": 202,
"headers": {
"server": "nginx",
"date": "Mon, 20 Jul 2020 11:15:19 GMT",
"content-length": "0",
"connection": "close",
"x-message-id": "mtahAGtDTSGqqkZ0xx-bfg",
"access-control-allow-origin": "https://sendgrid.api-docs.io",
"access-control-allow-methods": "POST",
"access-control-allow-headers": "Authorization, Content-Type, On-behalf-of, x-sg-elas-acl",
"access-control-max-age": "600",
"x-no-cors-reason": "https://sendgrid.com/docs/Classroom/Basics/API/cors.html"
},
"request": {
"uri": {
"protocol": "https:",
"slashes": true,
"auth": null,
"host": "api.sendgrid.com",
"port": 443,
"hostname": "api.sendgrid.com",
"hash": null,
"search": null,
"query": null,
"pathname": "/v3/mail/send",
"path": "/v3/mail/send",
"href": "https://api.sendgrid.com/v3/mail/send"
},
"method": "POST",
"headers": {
"Accept": "application/json",
"User-agent": "sendgrid/6.5.5;nodejs",
"Authorization": "Bearer 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",
"content-type": "application/json",
"content-length": 236
}
}
},
null
]

Response Code: 400

Message: Bad Request

Description: You will see this message when the data is invalid or there are no items specified in the email.

Sample

{
"code": "REQUEST_VALIDATION",
"message": "Invalid data in body: /recipientEmail should NOT have fewer than 1 items"
}

Changelog

  • Last updated - July 2020