POST /api/message/send.php
This endpoint can be used to send a single message to one (or multiple) recipient(s). Attachments can also be added.
Major difference between this and Trigger automation workflow endpoint is that while the endpoint utilizes automation workflows for templating the message, it does not trigger the automation workflow, i.e. filters and delays do not work.
Note! In order to send messages with attachments, the attachments feature must be enabled by Smaily Customer Support.
Request parameters
Request body must be a JSON serialized string. Maximum allowed request body is 64MB.
Parameter | Value |
autoresponder_id | Automation workflow ID. Required. |
from | Sender address. Structure is described in the "From parameter structure" section. Sender data falls back to autoresponder configured values, if parameter is omitted from request. |
reply_to | Reply-To address. Structure is described in the "Reply-To parameter structure" section. Reply-To address falls back to Sender's email address, if parameter is omitted from request. |
to | List of message recipients. Required. |
context | Object of message context variables. Structure is described in the "Context parameter structure" section. |
attachments | List of message attachment objects. Object structure is described in the "Attachments parameter structure" section. |
From parameter structure
Parameter | Value |
Sender email address. Required. |
|
name | Sender name. Required. |
Reply-To parameter structure
Parameter | Value |
Reply-To email address. Required. |
Context parameter structure
Parameter | Value |
... | Value will be normalized to string. |
Attachments parameter structure
The content type of the attachment will be automatically detected.
Parameter | Value |
content | Attachment content in Base64 encoding. |
url | Public, not password protected URL to file. Only http and https protocols are allowed. |
filename | Attachment name in message. Required. |
Note! Either content
or url
parameter is allowed. Using both will fail.
Response parameters
All possible response codes and their descriptions can be found in the “Response codes” page.
Parameter | Value |
code | Response code. |
message | Human-readable response message. |
message_ids | List of queued message IDs. Each value is an unsigned 64-bit long. Only included with successful API requests. |
fields | Validation errors. Only included when an invalid email address is present in to request parameter. |
Example
$ curl -X POST -u "${USERNAME}:${PASSWORD}" \ -H "Content-Type: application/json" \ -d '{"autoresponder_id": 1, "from": {"email": "offers@domain.tld", "name": "Offers"}, "to": ["recipient+1@domain.tld", "recipient+2@domain.tld"], "context": {"name": "John Doe", "city": "Tallinn"}, "attachments": [{"content": "dGVzdA==", "filename": "File 1.txt"}, {"url": "https://domain.tld/path/to/attachment.pdf", "filename": "File 2.pdf"}]}' \ "https://${SUBDOMAIN}.sendsmaily.net/api/message/send.php"
(JavaScript/JSON)
{ "code": 101, "message": "OK", "message_ids": [140737488355328] }
{ "code": 203, "message": "Invalid data submitted - Invalid email address in 'to' field", "fields": { "to": { "0": "Value is not a valid email address", "2": "Hostname of email address is not valid" } } }