Messages
Messages use the messages scope: messages:read to list and get, messages:write to send.
Send an SMS
Section titled “Send an SMS”SMS goes to Nepal mobile numbers and is billed per part from your wallet.
curl https://app.airfone.app/v1/messages \ -H "Authorization: Bearer $AIRFONE_KEY" \ -H "Idempotency-Key: order-1042-sms" \ -H "Content-Type: application/json" \ -d '{"channel": "sms", "to": "9800000000", "body": "Your order 1042 is on its way."}'status is sent when the carrier accepted it, or refused or failed with a reason in status_detail. SMS has no delivery receipts, and the text is not kept after sending.
Send a WhatsApp message
Section titled “Send a WhatsApp message”Free text works for 24 hours after the person last wrote to you.
curl https://app.airfone.app/v1/messages \ -H "Authorization: Bearer $AIRFONE_KEY" \ -H "Content-Type: application/json" \ -d '{"channel": "whatsapp", "to": "+9779800000000", "body": "Thanks, we have your request."}'Outside that window the API answers 409. Send an approved template instead:
curl https://app.airfone.app/v1/messages \ -H "Authorization: Bearer $AIRFONE_KEY" \ -H "Content-Type: application/json" \ -d '{"channel": "whatsapp", "to": "+9779800000000", "template": {"name": "order_update", "language": "en", "parameters": ["1042", "tomorrow"]}}'WhatsApp messages start as queued and move to sent, delivered and read, or failed.
List and get
Section titled “List and get”curl "https://app.airfone.app/v1/messages?channel=whatsapp&limit=20" \ -H "Authorization: Bearer $AIRFONE_KEY"
curl https://app.airfone.app/v1/messages/MESSAGE_ID \ -H "Authorization: Bearer $AIRFONE_KEY"Lists are newest first and page with next_cursor, passed back as starting_after.
Test keys
Section titled “Test keys”A test key never reaches a phone. WhatsApp sends are recorded and returned with "test": true. SMS is refused with 403; use a live key.
Errors
Section titled “Errors”| Status | Meaning |
|---|---|
| 400 | Bad number, empty body, or both body and template. |
| 402 | Not enough credit for the SMS. |
| 403 | A test key tried to send SMS. |
| 409 | WhatsApp is not connected, or the 24-hour window is closed. |