Send a One-Time Password (OTP)
Send a one-time password (OTP) to verify a sign-in, confirm a sensitive action, or approve a transaction. OTP is the highest-frequency transactional pattern on Mailtarget. The combination is straightforward: Transmission API, plain template, short body, no tracking.
Who this is for
Developers wiring authentication, payment confirmation, or sensitive-action approval into an application.
The Mailtarget surface
| Component | Used for |
|---|---|
| Transmission API | The send |
| Authentication | API key with Send via API scope |
| Sending Domains | Verified domain for the from address |
| Webhooks | Delivery confirmation, bounce detection |
OTP does not need Email Marketing campaigns or templates. Inline body is faster.
Execution
curl https://transmission.mailtarget.co/v1/layang/transmissions \
-X POST \
-H "Authorization: Bearer $MAILTARGET_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"subject": "Your verification code",
"from": { "email": "noreply@your-verified-domain.com", "name": "Your App" },
"to": [ { "email": "user@example.com" } ],
"bodyText": "Your code is 482915. It expires in 5 minutes.",
"bodyHtml": "<p>Your code is <strong>482915</strong>. It expires in 5 minutes.</p>",
"metadata": {
"user_id": "u_abc",
"purpose": "sign_in_otp",
"expires_at": "2026-05-08T15:35:00Z"
},
"optionsAttributes": {
"trackOpens": false,
"trackClicks": false
}
}'
Disable tracking. OTP recipients are not engagement signals; tracking adds latency and a tracking pixel they did not ask for.
The response includes transmissionId. Store it alongside the OTP record so you can correlate webhook events.
Common mistakes
| Symptom | Cause | Fix |
|---|---|---|
| OTP delayed by minutes | Heavy template engine. Fix: inline plain body, skip tracking | Use simple HTML and bodyText |
| OTP marked spam | OTP from same address as marketing sends | Use a dedicated subdomain like auth.your-domain.com for OTPs |
| User reports never received OTP | Address on suppression list (hard bounce or complaint history) | Check suppression API. Fall back to SMS or alternative auth path |
| Code visible in preview pane | Subject line includes the code | Keep code in body, not subject |
Outcome to track
- Delivery rate above 99 percent. Below this, your domain has a deliverability issue. Read Deliverability Operations.
- Time from request to delivery under 5 seconds at p95. Above this, network or queue issue. Open a support ticket if persistent.
- Bounce rate under 0.5 percent on OTP traffic. Higher rates indicate stale email lists.
Related
- API Quickstart for first-send walkthrough.
- Errors and Rate Limits for retry strategy.
- Webhooks for delivery confirmation.