Skip to main content
POST
/
v1
/
sms
/
verify
/
send
Send Verification Code
curl --request POST \
  --url https://api.example.com/v1/sms/verify/send \
  --header 'Content-Type: application/json' \
  --data '
{
  "phone": "<string>",
  "template": "<string>",
  "code_length": 123,
  "expiry_minutes": 123,
  "metadata": {}
}
'
{
  "id": "<string>",
  "phone": "<string>",
  "status": "<string>",
  "expires_at": "<string>"
}

Request Body

phone
string
required
The phone number to verify. Include country code (e.g., +14155551234)
template
string
Custom message template. Use {code} for the code and {minutes} for expiry time. Default: "Your verification code is: {code}. Valid for {minutes} minutes."
code_length
number
Length of the verification code (4-8 digits). Default: 6
expiry_minutes
number
How long the code is valid (1-60 minutes). Default: 10
metadata
object
Custom metadata to store with the verification

Response

id
string
The verification ID
phone
string
The normalized phone number
status
string
sent or failed
expires_at
string
ISO 8601 timestamp when the code expires

Examples

Basic OTP

curl -X POST https://www.unosend.co/api/v1/sms/verify/send \
  -H "Authorization: Bearer un_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+14155551234"
  }'

Custom Template

curl -X POST https://www.unosend.co/api/v1/sms/verify/send \
  -H "Authorization: Bearer un_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+14155551234",
    "template": "Your Acme login code: {code}",
    "code_length": 4,
    "expiry_minutes": 5
  }'

Response Example

{
  "id": "ver_abc123",
  "phone": "+14155551234",
  "status": "sent",
  "expires_at": "2025-01-02T15:30:00.000Z"
}

Rate Limits

  • One active verification per phone number per organization
  • Sending a new code invalidates any existing pending codes

Use Cases

  • User signup phone verification
  • Two-factor authentication (2FA)
  • Password reset verification
  • Transaction confirmation
  • Account recovery