Documentação

O Autometa Mailer implementa a API REST do Resend. Se você já usa o Resend, basta trocar a base URL e a API key.

1. Use o SDK oficial do Resend

Nenhuma mudança de código: só aponte a base URL para o Autometa Mailer.

Defina as variáveis de ambiente da sua aplicação:

RESEND_API_KEY=re_xxxxxxxxx      # sua API key do Autometa Mailer
RESEND_BASE_URL=https://mailer.autometa.com.br/api

Node.js / TypeScript:

import { Resend } from "resend";

const resend = new Resend(process.env.RESEND_API_KEY);

const { data, error } = await resend.emails.send({
  from: "Acme <[email protected]>",
  to: ["[email protected]"],
  subject: "Olá!",
  html: "<strong>Funciona!</strong>",
});

Python (resend):

import resend
resend.api_key = "re_xxxxxxxxx"
resend.api_url = "https://mailer.autometa.com.br/api"   # ou env RESEND_API_URL

resend.Emails.send({"from": "Acme <[email protected]>", "to": ["[email protected]"], "subject": "Olá", "html": "<p>Oi</p>"})

PHP (resend/resend-php): Resend::client('re_xxx', 'mailer.autometa.com.br/api') · Laravel: RESEND_BASE_URL.

2. Ou chame a REST API diretamente

curl -X POST 'https://mailer.autometa.com.br/api/emails'   -H 'Authorization: Bearer re_xxxxxxxxx'   -H 'Content-Type: application/json'   -H 'Idempotency-Key: pedido-123'   -d '{
    "from": "Acme <[email protected]>",
    "to": ["[email protected]"],
    "subject": "Pedido confirmado",
    "html": "<p>Seu pedido foi confirmado!</p>",
    "tags": [{ "name": "categoria", "value": "pedido" }],
    "scheduled_at": "in 10 min"
  }'

Se você publicar o app em um subdomínio api. (ex.: api.seudominio.com), as rotas também funcionam sem o prefixo /api, exatamente como api.resend.com.

Endpoints suportados

POST /emails
GET /emails
GET /emails/:id
PATCH /emails/:id
POST /emails/:id/cancel
POST /emails/batch
POST /domains
GET /domains
GET /domains/:id
PATCH /domains/:id
POST /domains/:id/verify
DELETE /domains/:id
POST /api-keys
GET /api-keys
DELETE /api-keys/:id
POST /audiences
GET /audiences
GET /audiences/:id
DELETE /audiences/:id
POST /audiences/:id/contacts
GET /audiences/:id/contacts
GET|PATCH|DELETE /audiences/:id/contacts/:idOrEmail
POST /broadcasts
GET /broadcasts
GET|PATCH|DELETE /broadcasts/:id
POST /broadcasts/:id/send
POST /webhooks
GET /webhooks
GET|PATCH|DELETE /webhooks/:id

Webhooks

Mesmo formato de payload e assinatura Svix do Resend.

import { Webhook } from "svix";
const wh = new Webhook(process.env.WEBHOOK_SECRET); // whsec_...
const event = wh.verify(rawBody, {
  "svix-id": req.headers["svix-id"],
  "svix-timestamp": req.headers["svix-timestamp"],
  "svix-signature": req.headers["svix-signature"],
});
// event.type: email.sent | email.delivered | email.bounced | email.opened | email.clicked ...

Limites e erros

Erros seguem o formato do Resend: { "statusCode": 422, "name": "validation_error", "message": "..." }

Códigos: missing_api_key (401), invalid_api_key (403), restricted_api_key (401), validation_error (422/403), not_found (404), rate_limit_exceeded, daily_quota_exceeded, monthly_quota_exceeded (429).

O rate limit por segundo e as cotas diária/mensal dependem do seu plano.