LIVE SUPPORTNeed assistance? Chat directly on WhatsApp or submit a ticket.WhatsApp +19863561218 →
Documentation Menu
Production Ready1 min read

OTP (Transactional Code Emails)

Fast, rate-limited OTP delivery via API keys + templates.

Module:dashboard/emails/otp

What it is#

OTP is a dedicated transactional endpoint designed for speed and safety. It supports:

  • Redis rate limits per recipient and per org
  • {{variables}} templating (including {{otp}})

Endpoint#

POST /api/v1/emails/otp

Required headers#

Create the key in the dashboard under API keys (not via Swagger). Then:

  • X-API-Key: eg_... or Authorization: Bearer eg_...
  • Content-Type: application/json

Do not use a dashboard JWT for this endpoint.

Required body fields#

  • to (recipient email)
  • otp (code) or templateId + variables (depending on your template workflow)

Production notes (deliverability + safety)#

  • from must use a domain your org has verified; unverified domains are rejected (e.g. DOMAIN_NOT_VERIFIED).
  • When rate limits are exceeded, the API returns 429 Too Many Requests.

Example (curl)#

BASH
curl -X POST "$PUBLIC_API_URL/api/v1/emails/otp" \
  -H "X-API-Key: eg_••••" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@gmail.com",
    "from": "noreply@yourdomain.com",
    "otp": "482913",
    "subject": "Your login code",
    "html": "<p>Code: <strong>{{otp}}</strong></p>"
  }'

Replace $PUBLIC_API_URL with your API origin (e.g. https://prod-api.mailchamp.org).

Related Documentation

Explore interconnected guides and API endpoints.

Have a question about this guide?

Contact our engineering and deliverability support team anytime.