Skip to content

The send API

One call to send an e-mail, what it checks, and how to send many safely.

Applies to EngineCloud
View as Markdown
On this page
  1. What it checks before answering
  2. Idempotency
  3. Many e-mails
  4. Tags
TypeScript
const { id } = await mail.send({
  from: 'La Espiga <pedidos@laespiga.co>',
  to: ['ana@example.com'],
  replyTo: 'hola@laespiga.co',
  subject: 'Tu pedido #1042 está listo',
  html: '<p>Hola Ana, ya puedes recogerlo.</p>',
  text: 'Hola Ana, ya puedes recogerlo.',
  tags: { kind: 'order-ready', order: '1042' },
  idempotencyKey: 'order-ready-1042',
});

What it checks before answering

CheckIf it fails
the key’s scope includes send403 forbidden
the from domain is verified in the project422 domain_not_verified
no recipient is on the suppression listthat recipient is skipped and reported in suppressed[]; if all are, 422 all_suppressed
at most 50 recipients across to, cc and bcc400 too_many_recipients
size with attachments at most 10 MB413 too_large
the project’s rate and daily limit429 rate_limited with retry-after

The answer is 202 Accepted with { id, suppressed }. Accepted means queued, not delivered: Events tell you the rest.

Idempotency

With idempotencyKey, sending the same key again within 24 hours returns the first e-mail’s id and sends nothing. Use it whenever a retry could repeat a send.

Many e-mails

mail.sendBatch([...]) takes up to 100 messages in one call, each with its own recipient and data, and returns an id per message. Every message is personal: one recipient, one e-mail. Batches still count against the rate limit.

Tags

tags are up to 10 keys of your own; they come back on every event of the e-mail and you can filter the log by them.

  1. What it checks before answering
  2. Idempotency
  3. Many e-mails
  4. Tags

    Search pages, sections and terms