POST /messages
Send messages to recipients
The
template
field is required and should be the template slug you wish to send.The
to
field is required to send a message. It should be a single recipient.The
from
field is optional on the API call as long as it is set on either the Template or the Provider. The order of precedence for the from field on a message is:
- 1.
from
attribute in the API call - 2.If not set in API call it will look in Template defaults
- 3.If not set in Template it will look in Provider defaults
- 4.If not set in 1-3 it will return an error and fail to send Message
The
subject
field is optional on the API call as long as it is set in the Template defaults.The
templateVariables
field accepts a hash/object of variables and text to replace in the template.For example if you have the text
Hello {{user}}
in your template and pass { user: "Bob" }
as templateVariables
then the template will render Hello Bob
The recipient of the message
The from address of the message sent
A preview of the body of the message delivered to the recipient
If an error is present you will get a http status of 500 and the error field will contain the error
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: token test_eYLQRrzxLcLAlmb2H5BXIFSUor3h/tRr" \
-d '{
"template": "user-welcome",
"to": "[email protected]",
"from": "Northwind App <[email protected]>",
"subject": "Welcome to Northwind",
"templateVariables": {
"name": "Bob Vance"
}
}' \
"https://api.enveloop.com/messages"
{
"to": "[email protected]",
"from": "Northwind App <[email protected]>",
"body": "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\"><html ... </html>"
}
Last modified 9mo ago