Skip to main content

Send an email notification

Send an email notification to a user with the specified email address.

Request
POST {{base_url}}/messages
Content-Type: application/json
api_key: {{API_KEY}}

1. Send an Email notification (default content type = text)

POST {{base_url}}/messages
content-type: application/json
api_key: {{api_key}}

{
"message": {
"type": "email",
"email": "someone@example.com",
"subject": "One Time Password",
"content": "Your OTP code is 1234"
}
}

2. Send an Email notification (explicit content type = text)

POST {{base_url}}/messages
content-type: application/json
api_key: {{api_key}}

{
"message": {
"type": "email",
"content_type": "text",
"email": "someone@example.com",
"subject": "One Time Password",
"content": "Your OTP code is 1234"
}
}

3. Send an Email notification (explicit content type = html)

If sending an email with html content, failure to explicitly declare a content_type of email will have your email being sent as a normal text email

POST {{base_url}}/messages
content-type: application/json
api_key: {{api_key}}

{
"message": {
"type": "email",
"content_type": "html",
"email": "someone@example.com",
"subject": "One Time Password",
"content": "<html><body><div>Your OTP code is 1234</div></body></html>"
}
}

Request sample (cURL)

curl --request POST \
--url https://messenger.stg.cashia.com/api/messages \
--header 'api_key: L2aAVtBsfhGzk5S5BA1SelgvM49r8gSpS2_Uhok98I_' \
--header 'content-type: application/json' \
--data '{"message": {"type": "email","email": "someone@example.com","subject": "One Time Password","content": "Your OTP code is 1234"}}'

1. Plain Text Email (Default)

curl --request POST \
--url https://messenger.stg.cashia.com/api/messages \
--header 'api_key: f1Vlg_4z4t4MhoS_zsUGgk2L8SI8v5ah7Sz9SBUPBBk' \
--header 'content-type: application/json' \
--data '{"message": {"type": "email","email": "someone@example.com","subject": "One Time Password","content": "Your OTP code is 1234"}}'

2. HTML Email

curl --request POST \
--url https://messenger.stg.cashia.com/api/messages \
--header 'api_key: YOUR_API_KEY' \
--header 'content-type: application/json' \
--data '{
"message": {
"type": "email",
"content_type": "html",
"email": "recipient@example.com",
"subject": "One Time Password",
"content": "<html><body><h1>OTP Code</h1><p>Your OTP code is 1234</p></body></html>"
}
}'

Responses sample

200 Success message
{
"status": "success",
"message": "Email sent successfully"
}
400 Bad request
{
"status": "error",
"message": "Bad request"
}
500 Bad request
"Recipient email address is invalid"