Contents

WhatsApp2 endpoints

WhatsApp Business Platform messages.

Base URLhttps://sms21.in

Send a WhatsApp text

post/v1/whatsapp/send

Scopewhatsapp:send

Free-form (session) text through the WhatsApp Business Platform, optionally with an image, video or document (media, with text as the caption). WhatsApp only delivers it within 24 hours of the recipient's last message to you; outside that window the message is rejected — use a template. With the WhatsApp Official plugin active, messages are sent from your own WhatsApp Business Account, using the templates synced from it; 409 WA_ACCOUNT_NOT_CONNECTED means the plugin is on but no account is connected.

Parameters1

  • Idempotency-Keyheaderstring

    Makes the request safe to retry: repeating it with the same key and body returns the original result (with Idempotent-Replayed: true) instead of sending again. Use one key per logical message, e.g. derived from your order or login-attempt ID. Reusing a key with a different body is 409 IDEMPOTENCY_KEY_REUSED.

Body3

  • tostringrequired

    Recipient in international format.

  • textstringrequired

    Delivered only within 24 hours of the recipient's last message to you; otherwise WhatsApp rejects it. With media, it is the caption (max 1024 characters).

  • mediaWaMedia

    A file sent with the message; text becomes its caption (max 1024 characters). SMS21 downloads it from a public https URL when the message is sent (no redirects).

    3 nested fields
    • typestringrequired

      image: JPEG, PNG or WebP · video: MP4 or 3GPP · document: any file but HTML.

      imagevideodocument

    • urlstring (uri)required
    • filenamestring

      Documents: the name the recipient sees.

Responses

  • 202

    Accepted and queued.

  • 400

    Invalid request.

    Example
    Response 400
    {
      "success": false,
      "error": {
        "code": "INVALID_RECIPIENT",
        "message": "The recipient is not a valid mobile number",
        "details": [
          {
            "field": "to",
            "message": "to must be a mobile number in international format, e.g. 919876543210"
          }
        ]
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 401

    The API key is missing, malformed, unknown, revoked or expired.

    Example
    Response 401
    {
      "success": false,
      "error": {
        "code": "AUTHENTICATION_REQUIRED",
        "message": "An API key is required; send it in the X-API-Key header or as \"Authorization: Bearer <key>\""
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 402

    Live keys only: the wallet cannot cover the message. Add funds; retrying will not help.

    Example
    Response 402
    {
      "success": false,
      "error": {
        "code": "INSUFFICIENT_BALANCE",
        "message": "Insufficient wallet balance"
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 403

    The key may not do this: missing scope, IP not on the allow-list, company, project or key suspended by SMS21, project archived, wallet suspended or destination blocked.

    Example
    Response 403
    {
      "success": false,
      "error": {
        "code": "INSUFFICIENT_SCOPE",
        "message": "This API key does not have the required scope",
        "details": [
          {
            "message": "requires scope sms:send"
          }
        ]
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 409

    Conflicting state.

    Example
    Response 409
    {
      "success": false,
      "error": {
        "code": "IDEMPOTENCY_KEY_REUSED",
        "message": "This Idempotency-Key was already used with a different request"
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 429

    Rate limited. Wait Retry-After seconds, then retry with the same Idempotency-Key.

    Example
    Response 429
    {
      "success": false,
      "error": {
        "code": "RATE_LIMITED",
        "message": "Rate limit exceeded for this API key"
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 503

    Temporarily unavailable, or live sending paused by SMS21. Retry later with the same Idempotency-Key.

    Example
    Response 503
    {
      "success": false,
      "error": {
        "code": "SERVICE_UNAVAILABLE",
        "message": "Service temporarily unavailable"
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
curl -X POST "https://sms21.in/v1/whatsapp/send" \
  -H "X-API-Key: $SMS21_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"919876543210","text":"Your table is ready."}'
Response 202
{
  "success": true,
  "messageId": "msg_01k55q8y4m3d9v7x2c6b0n1r8t",
  "status": "queued",
  "channel": "whatsapp",
  "type": "transactional",
  "environment": "live",
  "to": "919876543210",
  "templateId": null,
  "whatsappTemplateId": null,
  "segments": 1,
  "encoding": "gsm7",
  "failure": null,
  "queuedAt": "2026-09-15T10:30:00.000Z",
  "submittedAt": null,
  "sentAt": null,
  "deliveredAt": null,
  "failedAt": null
}

Send a WhatsApp template

post/v1/whatsapp/template

Scopewhatsapp:send

Approved utility or marketing template, registered in SMS21 exactly as Meta approved it. Templates with a media header take the file in media. OTPs use POST /otp/send with channel: "whatsapp". With the WhatsApp Official plugin active, messages are sent from your own WhatsApp Business Account, using the templates synced from it; 409 WA_ACCOUNT_NOT_CONNECTED means the plugin is on but no account is connected.

Parameters1

  • Idempotency-Keyheaderstring

    Makes the request safe to retry: repeating it with the same key and body returns the original result (with Idempotent-Replayed: true) instead of sending again. Use one key per logical message, e.g. derived from your order or login-attempt ID. Reusing a key with a different body is 409 IDEMPOTENCY_KEY_REUSED.

Body4

  • tostringrequired

    Recipient in international format.

  • templateIdstringrequired

    Approved utility or marketing template. Authentication templates are sent with POST /otp/send.

  • variablesobject

    Values for the template variables, by name.

  • mediaWaMedia

    Templates with an IMAGE, VIDEO or DOCUMENT header: the file for the header (required for them, refused for others).

    3 nested fields
    • typestringrequired

      image: JPEG, PNG or WebP · video: MP4 or 3GPP · document: any file but HTML.

      imagevideodocument

    • urlstring (uri)required
    • filenamestring

      Documents: the name the recipient sees.

Responses

  • 202

    Accepted and queued.

  • 400

    Invalid request.

    Example
    Response 400
    {
      "success": false,
      "error": {
        "code": "INVALID_RECIPIENT",
        "message": "The recipient is not a valid mobile number",
        "details": [
          {
            "field": "to",
            "message": "to must be a mobile number in international format, e.g. 919876543210"
          }
        ]
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 401

    The API key is missing, malformed, unknown, revoked or expired.

    Example
    Response 401
    {
      "success": false,
      "error": {
        "code": "AUTHENTICATION_REQUIRED",
        "message": "An API key is required; send it in the X-API-Key header or as \"Authorization: Bearer <key>\""
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 402

    Live keys only: the wallet cannot cover the message. Add funds; retrying will not help.

    Example
    Response 402
    {
      "success": false,
      "error": {
        "code": "INSUFFICIENT_BALANCE",
        "message": "Insufficient wallet balance"
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 403

    The key may not do this: missing scope, IP not on the allow-list, company, project or key suspended by SMS21, project archived, wallet suspended or destination blocked.

    Example
    Response 403
    {
      "success": false,
      "error": {
        "code": "INSUFFICIENT_SCOPE",
        "message": "This API key does not have the required scope",
        "details": [
          {
            "message": "requires scope sms:send"
          }
        ]
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 404

    The template does not exist in this company.

    Example
    Response 404
    {
      "success": false,
      "error": {
        "code": "NOT_FOUND",
        "message": "Template not found",
        "details": [
          {
            "field": "templateId",
            "message": "no such template"
          }
        ]
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 409

    Conflicting state.

    Example
    Response 409
    {
      "success": false,
      "error": {
        "code": "IDEMPOTENCY_KEY_REUSED",
        "message": "This Idempotency-Key was already used with a different request"
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 429

    Rate limited. Wait Retry-After seconds, then retry with the same Idempotency-Key.

    Example
    Response 429
    {
      "success": false,
      "error": {
        "code": "RATE_LIMITED",
        "message": "Rate limit exceeded for this API key"
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
  • 503

    Temporarily unavailable, or live sending paused by SMS21. Retry later with the same Idempotency-Key.

    Example
    Response 503
    {
      "success": false,
      "error": {
        "code": "SERVICE_UNAVAILABLE",
        "message": "Service temporarily unavailable"
      },
      "requestId": "0199491c-8f3a-7c2e-9b1d-5e7f3a2c4b6d"
    }
curl -X POST "https://sms21.in/v1/whatsapp/template" \
  -H "X-API-Key: $SMS21_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"919876543210","templateId":"wtpl_01k55q8y4m3d9v7x2c6b0n1r8t","variables":{"name":"Asha","order":"1042"}}'
Response 202
{
  "success": true,
  "messageId": "msg_01k55q8y4m3d9v7x2c6b0n1r8t",
  "status": "queued",
  "channel": "whatsapp",
  "type": "transactional",
  "environment": "live",
  "to": "919876543210",
  "templateId": null,
  "whatsappTemplateId": "wtpl_01k55q8y4m3d9v7x2c6b0n1r8t",
  "segments": 1,
  "encoding": "gsm7",
  "failure": null,
  "queuedAt": "2026-09-15T10:30:00.000Z",
  "submittedAt": null,
  "sentAt": null,
  "deliveredAt": null,
  "failedAt": null
}