POST

/v1/send

Unified endpoint to send a message on any channel.

Endpoint

POST https://api.yoursend.dev/v1/send

Requires an Authorization: Bearer ys_live_... header. Use a ys_test_... key to run in sandbox mode — requests are validated and logged but nothing is delivered or billed.

Request Body

FieldTypeRequiredDescription
channelstringYes"email" | "sms" | "voice" | "whatsapp" | "auto"
tostringYesRecipient (email or E.164 phone)
subjectstringCond.Email subject (or comes from the template)
htmlstringCond.HTML body (email only)
textstringNoPlain text body (email fallback)
bodystringCond.Message body (SMS/voice/WhatsApp)
template_idstringCond.Template ID (alternative to inline content)
dataobjectNoMerge-tag values for {{...}} placeholders
fallbackstringNoChannel to try if the primary one fails
fallback_tostringNoAddress for the fallback channel
media_urlsarrayNoUp to 10 https media URLs (MMS/RCS/WhatsApp)

Omit subject, html, text, body, and template_id to send an OTP — YourSend generates and delivers the code. The sender address comes from your verified domain; there is no from field.

Response

200 OK
{
  "message_id": "8f14e45f-ceea-467a-9b3a-1d2c3e4f5a6b",
  "status": "sent",
  "channel": "email",
  "to": "user@example.com"
}
400 Bad Request
{
  "error": {
    "code": "invalid_request",
    "message": "Missing required field: to",
    "status": 400
  }
}
403 Forbidden
{
  "error": {
    "code": "invalid_api_key",
    "message": "Invalid API key.",
    "status": 403
  }
}

Examples

Send email

curl -X POST https://api.yoursend.dev/v1/send \
  -H "Authorization: Bearer ys_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "email",
    "to": "user@example.com",
    "subject": "Welcome!",
    "html": "<h1>Hello</h1>"
  }'

Send SMS OTP

No body or template means YourSend generates and sends the code.

curl -X POST https://api.yoursend.dev/v1/send \
  -H "Authorization: Bearer ys_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "channel": "sms",
    "to": "+14155551234"
  }'