# WaSMS API WaSMS (https://wasms.net) lets a business send and receive WhatsApp, SMS and email messages from one place. This API lets your own software send messages through the WhatsApp number the business has connected to WaSMS. ## Address and sign-in Base address: https://wasms.net/api/public/v1 Every request carries the API key in a header: Authorization: Bearer YOUR_WASMS_API_KEY A key starts with "wasms_". It is created, and can be copied again, in the WaSMS dashboard under Developers, API keys (https://wasms.net/dashboard/api-keys). Keep it on the server; never put it in a web page or a mobile app. Sending needs a key with the "messages:send" permission. ## Send a WhatsApp message POST https://wasms.net/api/public/v1/whatsapp/send Content-Type: application/json Body fields: to required recipient phone with country code, digits only (a leading + is accepted), e.g. "923001234567" message required unless media_url is given the text; with media_url it is the caption media_url optional public https address of a file to send (image, video, audio or document) media_type optional "image", "video", "audio" or "document"; worked out from the address when left out filename optional name shown for a document whatsapp_id optional which connected number to send from (its id from GET https://wasms.net/api/public/v1/whatsapp/accounts); the organization's connected number is used when left out Example: curl -X POST https://wasms.net/api/public/v1/whatsapp/send \ -H "Authorization: Bearer YOUR_WASMS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"to": "923001234567", "message": "Hello from my software"}' Success (HTTP 200): { "success": true, "data": { "sent": true, "id": "", "to": "923001234567", "type": "text", "whatsapp_id": "", "account_phone": "", "message_id": "" } } Keep "id". It is how you find out later whether the message was delivered and read (see "Delivered and read" below). It is absent only when WhatsApp gave no id for the message. ## Errors Every failure has the same shape, with an HTTP status that is not 200: { "success": false, "error": "", "code": "", "message": "" } 400 INVALID_BODY "to" is missing, or neither "message" nor "media_url" was given 400 INVALID_ACCOUNT_ID "whatsapp_id" is not a valid id 401 UNAUTHORIZED the key is missing, mistyped or revoked 403 INSUFFICIENT_SCOPE the key does not have the "messages:send" permission 403 PLAN_LIMIT the plan's sending limit is used up 409 WHATSAPP_DISCONNECTED the number was signed out of WhatsApp and must be connected again 429 RATE_LIMITED the key made more requests this minute than it is allowed; wait the number of seconds in the "Retry-After" header 502 GATEWAY_CLOSED the WaSMS app that sends for this number is not running 502 GATEWAY_ERROR the WaSMS app reported a problem; "message" says what 503 NO_CONNECTED_ACCOUNT no WhatsApp number is connected to the organization Show "message" to a person; branch on "code". A 429, 502 or 503 can be tried again later; a 400, 401, 403 or 409 will fail the same way until the request, the key, the plan or the connection changes. ## How many requests Each key may make a set number of requests a minute (60 unless changed; it can be set from 1 to 1000 on the API keys page). Every reply carries "X-RateLimit-Limit" and "X-RateLimit-Remaining". One request too many gets 429 RATE_LIMITED with "Retry-After: ". ## Other routes All under https://wasms.net/api/public/v1, same header, same error shape. Fields for each are in the full reference. POST /sms/send send an SMS (messages:send) POST /email/send send an email (messages:send) POST /whatsapp/bulk send up to 1000 WhatsApp messages in one call (messages:send) GET /whatsapp/accounts the connected WhatsApp numbers (accounts:read) GET /messages messages sent and received, on every channel; pass since=