XM

Communication - Send Email

Path:

POST /email/send

Users want to be notified on important events, particularly, order shipment. This endpoint faciliates sending notification emails based on a defined template. Other templates can be added to faciliate user engagement, such as feedback, new promotions and offers.

Headers

x-api-key :d41d8cd98f00b204e9800998ecf8427e

Content-Type :application/json

Consumes

  • application/json

Produces

  • application/json

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]"]
}

Response

Response Code: 200

Message: OK

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

Sample

[
{
"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