Skip to content

Messages

Messages use the messages scope: messages:read to list and get, messages:write to send.

SMS goes to Nepal mobile numbers and is billed per part from your wallet.

Terminal window
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.

Free text works for 24 hours after the person last wrote to you.

Terminal window
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:

Terminal window
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.

Terminal window
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.

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.

StatusMeaning
400Bad number, empty body, or both body and template.
402Not enough credit for the SMS.
403A test key tried to send SMS.
409WhatsApp is not connected, or the 24-hour window is closed.