POST /messages
Compose — salva rascunho OU envia (interno/externo)
- Acesso: Login
- Serviço:
https://mail-api.axuz.net
Autenticação aceita
sessionCookie— Sessão plena Axuz (cookie de sessão da casa). Sessão restrita é 403 enrollment_required.bearerSession— JWT de acesso da sessão em `Authorization: Bearer`.
- send=false → grava row draft no folder drafts. - send=true interno-only → grava sent no remetente + received em cada destinatário interno (mesma tx). - send=true com destinatário externo → depende do gate MAIL_EXTERNAL_SEND_ENABLED. Ligado: enfileira em mail_outbound_log + dispara Deliver ao MTA. Desligado (default): responde 503 pending_stalwart ANTES de escrever nada. (piso §37.15 / MAIL-03)
Parâmetros
Sem parâmetros.
Corpo da requisição
application/json · Obrigatório
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
account_id | string<uuid> | sim | |
to | array<string<email>> | não | |
cc | array<string<email>> | não | |
bcc | array<string<email>> | não | |
subject | string | não | |
body_html | string | não | |
body_text | string | não | |
in_reply_to | string<uuid> | null | não | |
send | boolean | não |
|
{
"account_id": "00000000-0000-0000-0000-000000000000",
"to": [
"pessoa@example.test"
],
"cc": [
"pessoa@example.test"
],
"bcc": [
"pessoa@example.test"
],
"subject": "string",
"body_html": "string",
"body_text": "string",
"in_reply_to": "00000000-0000-0000-0000-000000000000",
"send": false
}Respostas
201
Rascunho salvo ou mensagem enviada
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
message | MailMessage | sim | |
message.id | string<uuid> | sim | |
message.account_id | string<uuid> | sim | |
message.folder_id | string<uuid> | sim | |
message.thread_id | string<uuid> | sim | |
message.in_reply_to | string<uuid> | null | não | |
message.from_email | string<email> | sim | |
message.from_name | string | não | |
message.to_emails | array<string<email>> | sim | |
message.cc_emails | array<string<email>> | não | |
message.bcc_emails | array<string<email>> | não | |
message.subject | string | sim | |
message.body_html | string | não | Corpo HTML sanitizado (allowlist bluemonday, |
message.body_text | string | não | |
message.read | boolean | sim | |
message.starred | boolean | sim | |
message.labels | array<string> | não | |
message.received_at | string<date-time> | sim | |
message.sent_at | string<date-time> | null | não | |
message.status | string | sim | enum: |
message.internal | boolean | sim | |
message.created_at | string<date-time> | sim | |
message.updated_at | string<date-time> | sim | |
internal | boolean | sim | True quando todos os destinatários bateram em |
external | boolean | sim | True quando pelo menos um destinatário é externo (delegado ao MTA). |
400
Payload inválido
401
Sem credencial valida
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
403
Remetente não pertence ao usuário
404
Account not found
429
Teto de envio (F-019) atingido. Header Retry-After em segundos. Só ocorre com send=true — rascunho não consome cota.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim | |
layer | string | sim | Camada que negou. enum: |
limit | integer | sim | Teto da camada que negou. |
used | integer | sim | Consumido na janela quando negou. |
retry_after | integer | sim | Segundos até a próxima vaga (mínimo 1). |
message | string | sim |
500
Erro interno. Tente de novo com backoff; reporte o X-Request-Id.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim |
503
External send disabled — gate §37.15 rejeitou antes de qualquer INSERT.
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
error | string | sim | |
status | string | sim |
Exemplos
O "Try it" está desligado nesta referência. Use os exemplos com a sua credencial de teste.
curl
curl -sS -X POST 'https://mail-api.axuz.net/messages' \
-H "Authorization: Bearer $AXUZ_TOKEN" \
-H "Content-Type: application/json" \
-d '{"account_id":"00000000-0000-0000-0000-000000000000","to":["pessoa@example.test"],"cc":["pessoa@example.test"],"bcc":["pessoa@example.test"],"subject":"string","body_html":"string","body_text":"string","in_reply_to":"00000000-0000-0000-0000-000000000000","send":false}'Node.js
const res = await fetch("https://mail-api.axuz.net/messages", {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.AXUZ_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"account_id": "00000000-0000-0000-0000-000000000000",
"to": [
"pessoa@example.test"
],
"cc": [
"pessoa@example.test"
],
"bcc": [
"pessoa@example.test"
],
"subject": "string",
"body_html": "string",
"body_text": "string",
"in_reply_to": "00000000-0000-0000-0000-000000000000",
"send": false
}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(await res.json());Python
import os
import requests
res = requests.request(
"POST",
"https://mail-api.axuz.net/messages",
headers={
"Authorization": f"Bearer {os.environ['AXUZ_TOKEN']}",
},
json={
"account_id": "00000000-0000-0000-0000-000000000000",
"to": [
"pessoa@example.test",
],
"cc": [
"pessoa@example.test",
],
"bcc": [
"pessoa@example.test",
],
"subject": "string",
"body_html": "string",
"body_text": "string",
"in_reply_to": "00000000-0000-0000-0000-000000000000",
"send": False,
},
timeout=30,
)
res.raise_for_status()
print(res.json())