Skip to main content
POST/emails/send/

Send an email

Email messages using API

From now on you can send email messages using our API. To do so, you'll need to set subject, content and receivers for the message. If you want to send your messages using specific settings, you should specify smtp id, or campaign id, otherwise we will use our default smtp to deliver your messages.

If you want to use content instead of template, just leave only the content attribute in payload. Using both attributes will in turn use template and ignore the content attribute.

HTML is allowed inside of email message content. For example, as a content we can set:

Hi <b>user</b>, enjoy our product!

The email message will be shown as follow:

Hi user, enjoy our product!

Attributes

Optional unless marked required

authorinteger / stringrequired
This can be an email (string) or ID (integer) of an author.
contentstringrequired
A content of your email message.
receiversintegerrequired
A list of user ids separated by commas.
smtp/campaigninteger
A unique identifier of your SMTPSettings or Campaign automatically generated by User.
subjectstringrequired
A subject of your email message.
templateintegerrequired
An email template unique identifier.

ID for the receivers, can be found by requesting, single user details or by searching his email address.

Author can determine who's the sender of this email, it can be owner or any agent of the app.

Request​

curl -X POST "https://<your_app_subdomain>.user.com/api/public/emails/send/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"author": 2,
"receivers": 12345,
"subject": "Your weekly summary",
"content": "<p>Here is what happened in your account this week.</p>",
"template": 165
}'

Response examples​

{
"campaign": 880
}

This response means that the email has been sent correctly.

Response fields​

Fields returned in the 201 Created response body.

campaigninteger
ID of the campaign the email belongs to.
note

Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.