Skip to main content

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

ComponentUsed for
Transmission APIThe send
AuthenticationAPI key with Send via API scope
Sending DomainsVerified domain for the from address
WebhooksDelivery 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

SymptomCauseFix
OTP delayed by minutesHeavy template engine. Fix: inline plain body, skip trackingUse simple HTML and bodyText
OTP marked spamOTP from same address as marketing sendsUse a dedicated subdomain like auth.your-domain.com for OTPs
User reports never received OTPAddress on suppression list (hard bounce or complaint history)Check suppression API. Fall back to SMS or alternative auth path
Code visible in preview paneSubject line includes the codeKeep 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.