Send an email as the mailbox holder
/api/v1/mailbox/messages/sendSends from this mailbox's own address and files a copy in Sent. Send JSON, or multipart/form-data when you attach files (repeat a field for each value: to, cc, bcc, attachments).
Retrying safely. Send an Idempotency-Key header of the form <app>-<ULID> (for example crm-01JBT8XQ2M9WYC3K4F6R7S8T9V; one per email, saved before the first try). A retry with the same key within 24 hours returns the first answer, with Idempotency-Replayed: true, instead of sending again; while the first is still sending it answers 409 with Retry-After.
Scheduling. With send_at, the message waits in the Scheduled folder and the answer carries send_at; cancel it with DELETE /messages/scheduled/{id}.
Errors
| Status | When |
|---|---|
401 |
No token, or the session expired or was signed out. Sign in again with POST /mailbox-auth/login. |
403 |
The account has a temporary password: until POST /security/password succeeds, every other call answers this with error_code: password_change_required. |
403 |
You do not have permission to send from that address (a from this mailbox may not use), or read-only access to a shared mailbox. |
409 |
A send with this Idempotency-Key is still in progress. Wait for Retry-After, then retry with the same key. |
422 |
Add at least one valid recipient, The message has no content, too many or too large attachments, an invalid send_at, an Idempotency-Key that is not <app>-<ULID>, or one reused for a different email. |
Parameters
| Name | In | Type | Description |
|---|---|---|---|
Idempotency-Key | header | string | Makes a retry safe. Must look like <app>-<ULID>: your app's name in lowercase, a dash, then a ULID. One per email, sent again on every retry of it. Any other shape is a 422. |
Request body
toarray<string>Recipient addresses. At least one recipient across
to,ccandbcc.ccarray<string>Copy recipients: everyone sees them.
bccarray<string>Blind copies: delivered, but no recipient sees them.
subjectstringThe subject line.
body_textstringThe plain-text body. Send this,
body_html, or both.body_htmlstringThe HTML body.
in_reply_tostringThe Message-ID being answered, to thread the reply.
in_reply_to_idstringThat message's id here (
INBOX:4821), so it is flagged answered.referencesstringThe References header of the message being answered.
send_atstringISO 8601 (UTC). Schedule instead of sending now.
fromstringA shared mailbox to send as; must be one this mailbox may send from (see capabilities).
mentionsarray<string>Addresses @-mentioned in the body.
forward_attachments_fromstringForwarding: the message id whose attachments to include.
attachment_indexesarray<integer>Forwarding: which of its attachments (from its
attachments).attachmentsarray<string>Files, multipart only: up to 20, 25 MB in total.
Request
/api/v1/mailbox/messages/sendcurl -X POST 'https://courier.mailyte.com/api/v1/mailbox/messages/send' \
-H 'Authorization: Bearer MAILBOX_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"to": [
"tunde@example.com"
],
"subject": "The Q3 figures",
"body_text": "Hi Tunde,\n\nThe figures are below.\n\nAda"
}'const response = await fetch('https://courier.mailyte.com/api/v1/mailbox/messages/send', {
method: 'POST',
headers: {
Authorization: 'Bearer MAILBOX_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"to": [
"tunde@example.com"
],
"subject": "The Q3 figures",
"body_text": "Hi Tunde,\n\nThe figures are below.\n\nAda"
}),
});
const { data } = await response.json();import requests
response = requests.post(
"https://courier.mailyte.com/api/v1/mailbox/messages/send",
headers={"Authorization": "Bearer MAILBOX_TOKEN"},
json={
"to": [
"tunde@example.com"
],
"subject": "The Q3 figures",
"body_text": "Hi Tunde,\n\nThe figures are below.\n\nAda"
},
)
data = response.json()["data"]<?php
$response = Http::withToken('MAILBOX_TOKEN')
->post('https://courier.mailyte.com/api/v1/mailbox/messages/send', [
'to' => [
'tunde@example.com',
],
'subject' => 'The Q3 figures',
'body_text' => 'Hi Tunde,
The figures are below.
Ada',
]);
$data = $response->json('data');require "net/http"
require "json"
uri = URI("https://courier.mailyte.com/api/v1/mailbox/messages/send")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer MAILBOX_TOKEN"
request["Content-Type"] = "application/json"
request.body = {
"to": [
"tunde@example.com"
],
"subject": "The Q3 figures",
"body_text": "Hi Tunde,\n\nThe figures are below.\n\nAda"
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }Response
Sent, or scheduled.
dataobjectidstring or nullThe copy in Sent (
Sent:413), or in Scheduled. Null if it was sent but could not be filed.message_idstringThe Message-ID the email went out with.
answered_idstring or nullThe message flagged answered, for a reply.
folderstringScheduled only.
send_atstringScheduled only.
application/json{
"type": "success",
"msg": "Message sent",
"data": {
"id": "Sent:413",
"message_id": "<9f86d081.idem@yourdomain.com>",
"answered_id": null
}
}Returned inside the standard envelope.
Errors
| Status | When |
|---|---|
401 | No token, or the session expired or was signed out. Sign in again with `POST /mailbox-auth/login`. |
403 | `You do not have permission to send from that address` (a `from` this mailbox may not use), or read-only access to a shared mailbox. |
409 | A send with this `Idempotency-Key` is still in progress. Wait for `Retry-After`, then retry with the same key. |
422 | `Add at least one valid recipient`, `The message has no content`, too many or too large attachments, an invalid `send_at`, an `Idempotency-Key` that is not `<app>-<ULID>`, or one reused for a different email. |
Every status, with what causes it and what to do, is on the error reference.