wagswan API
Last updated 8 November 2026
The API reads and sends WhatsApp messages for one workspace, and webhooks tell your system about new messages as they happen. It is what the Zoho CRM and Zoho Desk extensions use, and any other integration can use it the same way. Base URL:
https://wagswan.com/api/v1A machine-readable OpenAPI 3.1 description of every endpoint and webhook is at /api/v1/openapi.json.
Authentication
An owner or admin creates a key in Settings > API. The key starts with wsk_live_ and is shown once, so store it in your integration's secret settings. Send it on every request:
Authorization: Bearer wsk_live_...A key belongs to one workspace and sees only that workspace's data. Revoking it in Settings > API stops it at once.
Requests, responses and errors
Bodies are JSON. Successful responses wrap the result in data. Errors use the HTTP status and a stable code you can branch on:
{
"error": {
"code": "window_closed",
"message": "The 24 hour customer service window is closed"
}
}| HTTP | code | When |
|---|---|---|
| 400 | invalid_json | The body is not JSON. |
| 401 | unauthorized | The key is missing, wrong or revoked. |
| 403 | read_only | The workspace trial or subscription ended, so sending is paused. |
| 404 | not_found | No such record in this workspace (records of other workspaces look the same). |
| 409 | window_closed | Free-form text outside the 24 hour customer service window. Send a template. |
| 409 | opted_out | A marketing template to a contact who opted out. |
| 409 | number_disconnected | The WhatsApp number is disconnected. |
| 409 | contact_exists | A contact with that phone number already exists. details.id is its id. |
| 409 | idempotency_in_progress | A request with the same Idempotency-Key is still running. |
| 422 | invalid_request | A field is missing or wrong. details lists each field. |
| 422 | invalid_phone | The phone number could not be read. |
| 422 | invalid_cursor | The cursor is not a nextCursor value from the same endpoint. |
| 422 | unknown_label | A label name does not exist in the workspace. details.labels lists them. |
| 422 | template_unavailable | No approved, supported template with that name and language on the number. |
| 422 | missing_variables | A template variable, header value, button value or header media is missing. |
| 422 | invalid_header | The header given does not match the template header (text, image, video or document). |
| 422 | invalid_button | buttons names an index that is not a URL button with a variable. |
| 422 | invalid_file | The uploaded file type or size is not allowed for a template header. |
| 502 | upload_failed | Meta refused the media upload. |
| 422 | phone_number_required | The workspace has several numbers. Give phoneNumberId. |
| 422 | unknown_member | The email is not a member of the workspace. |
| 422 | idempotency_mismatch | The Idempotency-Key was used with a different body. |
| 429 | rate_limited | Too many requests. Wait for Retry-After seconds. |
| 500 | internal_error | Our fault. Retry with the same Idempotency-Key. |
Rate limits
Each key may make 120 requests per minute. Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (Unix seconds). Past the limit you get 429 rate_limited with a Retry-After header in seconds.
Endpoints
GET/numbers
The WhatsApp numbers connected to the workspace. Use id as phoneNumberId when sending.
curl https://wagswan.com/api/v1/numbers -H "Authorization: Bearer $WAGSWAN_KEY"{
"data": [
{
"id": "cmh1number0001",
"displayNumber": "+60 10-000 0000",
"verifiedName": "Demo Shop",
"status": "connected",
"qualityRating": "GREEN"
}
]
}GET/contacts?phone=|bsuid=|ref=&label=&consent=&q=&updatedSince=&cursor=&limit=
List contacts, oldest change first, so a sync can keep the last updatedAt and pass it as updatedSince (ISO 8601) next time. Look one up with at most one of phone (international numbers with + or 00 work anywhere; a local number without them takes the workspace's default phone country from Settings, so 012-345 6789 in a Malaysian workspace becomes 60123456789), bsuid (the WhatsApp user id for customers who use a username), or ref (see External references). Filters combine: label is a label name, consent is opted_in, unknown or opted_out, q searches name, email and phone. limit is 1 to 100, default 50. Pass nextCursor as cursor for the next page; it is null on the last page.
curl "https://wagswan.com/api/v1/contacts?label=VIP&updatedSince=2026-11-01T00:00:00%2B08:00" -H "Authorization: Bearer $WAGSWAN_KEY"{
"data": [
{
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
}
],
"nextCursor": null
}POST/contacts
Create a contact. phone is required (a local number takes the workspace's default phone country); name, email, consent, labels (existing label names) and customFields (by field key, see GET /contact-fields) are optional. Every bad field is listed in details at once. A phone that already exists answers 409 contact_exists with its id.
curl -X POST https://wagswan.com/api/v1/contacts -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" \
-d '{"phone":"0100000001","name":"Demo Customer","email":"[email protected]","labels":["VIP"],"customFields":{"tier":"Gold"}}'{
"data": {
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
}
}GET PATCH DELETE/contacts/:id
Read, change or delete one contact. PATCH changes only what you send: name, email, consent, labels (replaces the set) or addLabels and removeLabels, and customFields, which merges (send null to clear a field). DELETE also removes the contact's conversations, messages and notes.
curl -X PATCH https://wagswan.com/api/v1/contacts/cmh1contact0001 -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" -d '{"consent":"opted_in","addLabels":["VIP"],"customFields":{"birthday":null}}'{
"data": {
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
}
}GET/contact-fields
The workspace's custom contact fields. key is fixed and is what customFields uses. Values are text: numbers as plain decimals, dates as YYYY-MM-DD, select values as one of options.
curl https://wagswan.com/api/v1/contact-fields -H "Authorization: Bearer $WAGSWAN_KEY"{
"data": [
{
"key": "tier",
"label": "Membership tier",
"type": "select",
"options": [
"Gold",
"Silver"
]
}
]
}GET/labels
Labels of the workspace. Contacts and conversations refer to labels by name.
curl https://wagswan.com/api/v1/labels -H "Authorization: Bearer $WAGSWAN_KEY"{
"data": [
{
"id": "cmh1label0001",
"name": "VIP",
"color": "amber"
}
]
}PUT/contacts/:id/refs
Save your own record id on a contact. One ref per system; a second PUT for the same system replaces it.
curl -X PUT https://wagswan.com/api/v1/contacts/cmh1contact0001/refs -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" \
-d '{"system":"zoho_crm","refId":"5725767000000412001","url":"https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"}'{
"data": {
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
}
}GET/conversations?phone=|contactId=|ref=&status=&limit=
Conversations, newest activity first. Filters combine. status is open, pending or closed. limit is 1 to 100, default 50.
curl "https://wagswan.com/api/v1/conversations?ref=zoho_desk:1092000000123" -H "Authorization: Bearer $WAGSWAN_KEY"{
"data": [
{
"id": "cmh1conv0001",
"status": "open",
"number": {
"id": "cmh1number0001",
"displayNumber": "+60 10-000 0000"
},
"contact": {
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
},
"assignee": {
"email": "[email protected]",
"name": "Demo Agent"
},
"labels": [
"Paid"
],
"unreadCount": 1,
"windowOpen": true,
"windowClosesAt": "2026-11-08T02:15:00.000Z",
"lastInboundAt": "2026-11-07T02:15:00.000Z",
"lastMessageAt": "2026-11-07T02:15:00.000Z",
"refs": [
{
"system": "zoho_desk",
"refId": "1092000000123",
"url": "https://desk.zoho.com/agent/demo/tickets/1092000000123"
}
],
"createdAt": "2026-11-07T02:15:00.000Z"
}
]
}GET/conversations/:id
One conversation. windowOpen says whether free-form text can be sent right now.
curl https://wagswan.com/api/v1/conversations/cmh1conv0001 -H "Authorization: Bearer $WAGSWAN_KEY"{
"data": {
"id": "cmh1conv0001",
"status": "open",
"number": {
"id": "cmh1number0001",
"displayNumber": "+60 10-000 0000"
},
"contact": {
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
},
"assignee": {
"email": "[email protected]",
"name": "Demo Agent"
},
"labels": [
"Paid"
],
"unreadCount": 1,
"windowOpen": true,
"windowClosesAt": "2026-11-08T02:15:00.000Z",
"lastInboundAt": "2026-11-07T02:15:00.000Z",
"lastMessageAt": "2026-11-07T02:15:00.000Z",
"refs": [
{
"system": "zoho_desk",
"refId": "1092000000123",
"url": "https://desk.zoho.com/agent/demo/tickets/1092000000123"
}
],
"createdAt": "2026-11-07T02:15:00.000Z"
}
}GET/conversations/:id/messages?before=&limit=
Messages, newest first. limit is 1 to 100, default 50. Pass nextCursor as before to get the next older page; it is null on the last page.
curl "https://wagswan.com/api/v1/conversations/cmh1conv0001/messages?limit=20" -H "Authorization: Bearer $WAGSWAN_KEY"{
"data": [
{
"id": "cmh1msg0001",
"conversationId": "cmh1conv0001",
"direction": "in",
"origin": "customer",
"type": "text",
"text": "Hi, is the large size still available?",
"templateName": null,
"media": null,
"status": "received",
"error": null,
"sentBy": null,
"timestamp": "2026-11-07T02:15:00.000Z"
}
],
"nextCursor": "cmh1msg0000"
}POST/messages
Send to a conversation (conversationId) or a phone number (to). Give text for a free-form message, which only works inside the 24 hour window, or template with name, language and variables (a list for {{1}}, {{2}}, or an object for named variables). A template to a phone with no conversation starts one; give phoneNumberId when the workspace has more than one number. senderEmail (optional) shows the message as sent by that member; without it the message shows as automated. Marketing templates are refused for contacts who opted out. To send an image or document, give media with type (image or document), an https url WhatsApp can download (jpeg or png images up to 5 MB; documents up to 100 MB), and optional caption and filename; like text, it only works inside the 24 hour window, and a link WhatsApp cannot fetch arrives later as a failed message.status. Send an Idempotency-Key header so a retry never sends twice: the same key and body within 24 hours returns the first response with Idempotent-Replayed: true.
Template headers and buttons: template.header is {"text":"..."} for a text header with a variable, or {"type":"image"|"video"|"document","link":"https://..."} for a media header. In place of link, give mediaId from POST /media (uploaded on the same number). filename is optional and shown for documents. template.buttons fills URL buttons that end in a variable: [{"index":0,"value":"A-1001"}], where index is the button's position in the template (see buttonVariables on GET /templates).
curl -X POST https://wagswan.com/api/v1/messages -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" -H "Idempotency-Key: desk-reply-8812" \
-d '{"conversationId":"cmh1conv0001","text":"Yes, we have it in large.","senderEmail":"[email protected]"}'
curl -X POST https://wagswan.com/api/v1/messages -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"0100000001","template":{"name":"order_ready","language":"en","variables":["Demo Customer","A-1001"]}}'
curl -X POST https://wagswan.com/api/v1/messages -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"0100000001","template":{"name":"invoice_ready","language":"en","variables":["Demo Customer"],
"header":{"type":"document","link":"https://example.com/demo-invoice.pdf","filename":"INV-1001.pdf"},
"buttons":[{"index":0,"value":"INV-1001"}]}}'
curl -X POST https://wagswan.com/api/v1/messages -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" \
-d '{"conversationId":"cmh1conv0001","media":{"type":"document","url":"https://files.demo.example/invoice-1001.pdf","caption":"Your invoice"}}'{
"data": {
"id": "cmh1msg0002",
"conversationId": "cmh1conv0001",
"direction": "out",
"origin": "agent",
"type": "text",
"text": "Yes, we have it in large.",
"templateName": null,
"media": null,
"status": "sent",
"error": null,
"sentBy": {
"email": "[email protected]",
"name": "Demo Agent"
},
"timestamp": "2026-11-07T02:15:00.000Z"
}
}GET/templates?phoneNumberId=
Approved templates that can be sent through the API, with their body variables, header type (text, image, video or document, and whether a text header has a variable), URL buttons that take a value, and the numbers that can send them.
curl https://wagswan.com/api/v1/templates -H "Authorization: Bearer $WAGSWAN_KEY"{
"data": [
{
"name": "invoice_ready",
"language": "en",
"category": "utility",
"body": "Hi {{1}}, your invoice is attached.",
"variables": [
"1"
],
"parameterFormat": "positional",
"header": {
"type": "document"
},
"buttonVariables": [
{
"index": 0,
"text": "View invoice",
"url": "https://example.com/invoices/{{1}}"
}
],
"phoneNumberIds": [
"cmh1number0001"
]
}
]
}POST/media
Upload a template header file as multipart/form-data: file, plus phoneNumberId when the workspace has more than one number, and type (image, video or document) when the extension is ambiguous. Images JPG or PNG up to 5 MB, video MP4 or 3GP up to 16 MB, documents PDF, DOCX or XLSX up to 100 MB. The mediaId works for 30 days, only on that number.
curl -X POST https://wagswan.com/api/v1/media -H "Authorization: Bearer $WAGSWAN_KEY" -F "[email protected]" -F "phoneNumberId=cmh1number0001"{
"data": {
"mediaId": "1234567890123456",
"type": "document",
"filename": "demo-invoice.pdf",
"phoneNumberId": "cmh1number0001"
}
}POST/conversations/:id/assign
Assign to a member by email, or pass null to unassign.
curl -X POST https://wagswan.com/api/v1/conversations/cmh1conv0001/assign -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" -d '{"email":"[email protected]"}'{
"data": {
"id": "cmh1conv0001",
"status": "open",
"number": {
"id": "cmh1number0001",
"displayNumber": "+60 10-000 0000"
},
"contact": {
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
},
"assignee": {
"email": "[email protected]",
"name": "Demo Agent"
},
"labels": [
"Paid"
],
"unreadCount": 1,
"windowOpen": true,
"windowClosesAt": "2026-11-08T02:15:00.000Z",
"lastInboundAt": "2026-11-07T02:15:00.000Z",
"lastMessageAt": "2026-11-07T02:15:00.000Z",
"refs": [
{
"system": "zoho_desk",
"refId": "1092000000123",
"url": "https://desk.zoho.com/agent/demo/tickets/1092000000123"
}
],
"createdAt": "2026-11-07T02:15:00.000Z"
}
}POST/conversations/:id/close and /conversations/:id/reopen
Close or reopen. Closing sends conversation.closed once. A new customer message reopens a closed conversation by itself.
curl -X POST https://wagswan.com/api/v1/conversations/cmh1conv0001/close -H "Authorization: Bearer $WAGSWAN_KEY"{
"data": {
"id": "cmh1conv0001",
"status": "closed",
"number": {
"id": "cmh1number0001",
"displayNumber": "+60 10-000 0000"
},
"contact": {
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
},
"assignee": {
"email": "[email protected]",
"name": "Demo Agent"
},
"labels": [
"Paid"
],
"unreadCount": 1,
"windowOpen": true,
"windowClosesAt": "2026-11-08T02:15:00.000Z",
"lastInboundAt": "2026-11-07T02:15:00.000Z",
"lastMessageAt": "2026-11-07T02:15:00.000Z",
"refs": [
{
"system": "zoho_desk",
"refId": "1092000000123",
"url": "https://desk.zoho.com/agent/demo/tickets/1092000000123"
}
],
"createdAt": "2026-11-07T02:15:00.000Z"
}
}POST/conversations/:id/labels
Add and remove labels by name in one call. Adding a label the conversation already has changes nothing.
curl -X POST https://wagswan.com/api/v1/conversations/cmh1conv0001/labels -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" -d '{"add":["Paid"],"remove":["Awaiting payment"]}'{
"data": {
"id": "cmh1conv0001",
"status": "open",
"number": {
"id": "cmh1number0001",
"displayNumber": "+60 10-000 0000"
},
"contact": {
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
},
"assignee": {
"email": "[email protected]",
"name": "Demo Agent"
},
"labels": [
"Paid"
],
"unreadCount": 1,
"windowOpen": true,
"windowClosesAt": "2026-11-08T02:15:00.000Z",
"lastInboundAt": "2026-11-07T02:15:00.000Z",
"lastMessageAt": "2026-11-07T02:15:00.000Z",
"refs": [
{
"system": "zoho_desk",
"refId": "1092000000123",
"url": "https://desk.zoho.com/agent/demo/tickets/1092000000123"
}
],
"createdAt": "2026-11-07T02:15:00.000Z"
}
}POST/conversations/:id/notes
Add an internal note, which agents see in the details panel and the customer never does. The author is the member named by authorEmail, or else the member who created the API key.
curl -X POST https://wagswan.com/api/v1/conversations/cmh1conv0001/notes -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" -d '{"text":"Refund approved in Zoho Desk"}'{
"data": {
"id": "cmh1note0001",
"conversationId": "cmh1conv0001",
"text": "Refund approved in Zoho Desk",
"author": {
"email": "[email protected]",
"name": "Demo Agent"
},
"createdAt": "2026-11-07T02:20:00.000Z"
}
}PUT/conversations/:id/refs
Link a conversation to your record, for example a Zoho Desk ticket. Same rules as contact refs.
curl -X PUT https://wagswan.com/api/v1/conversations/cmh1conv0001/refs -H "Authorization: Bearer $WAGSWAN_KEY" \
-H "Content-Type: application/json" \
-d '{"system":"zoho_desk","refId":"1092000000123","url":"https://desk.zoho.com/agent/demo/tickets/1092000000123"}'{
"data": {
"id": "cmh1conv0001",
"status": "open",
"number": {
"id": "cmh1number0001",
"displayNumber": "+60 10-000 0000"
},
"contact": {
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
},
"assignee": {
"email": "[email protected]",
"name": "Demo Agent"
},
"labels": [
"Paid"
],
"unreadCount": 1,
"windowOpen": true,
"windowClosesAt": "2026-11-08T02:15:00.000Z",
"lastInboundAt": "2026-11-07T02:15:00.000Z",
"lastMessageAt": "2026-11-07T02:15:00.000Z",
"refs": [
{
"system": "zoho_desk",
"refId": "1092000000123",
"url": "https://desk.zoho.com/agent/demo/tickets/1092000000123"
}
],
"createdAt": "2026-11-07T02:15:00.000Z"
}
}GET/members
Members of the workspace, so you can map your users to wagswan agents by email.
curl https://wagswan.com/api/v1/members -H "Authorization: Bearer $WAGSWAN_KEY"{
"data": [
{
"email": "[email protected]",
"name": "Demo Agent",
"role": "agent"
}
]
}External references
An integration can store its own record id on a conversation or a contact, for example the Zoho Desk ticket a conversation became, or the Zoho CRM contact behind a customer. system is lowercase letters, digits and underscores (zoho_desk, zoho_crm, or your own name); refId is your id; url is an optional http or https link. Refs come back on every conversation and contact, in webhook payloads, and agents see the links in the inbox details panel. Find a record by ref with ?ref=system:refId.
Webhooks
In Settings > API > Webhooks, add an https URL and pick the events. The signing secret (whsec_...) is shown once. Each event is a POST with a JSON body:
{
"id": "evt_5f0c3a9e2b7d4c1e8a6f9b0d1c2e3f4a",
"event": "message.received",
"created_at": "2026-11-07T02:15:01.000Z",
"workspace_id": "cmh1workspace01",
"data": {
"message": {
"id": "cmh1msg0001",
"conversationId": "cmh1conv0001",
"direction": "in",
"origin": "customer",
"type": "text",
"text": "Hi, is the large size still available?",
"templateName": null,
"media": null,
"status": "received",
"error": null,
"sentBy": null,
"timestamp": "2026-11-07T02:15:00.000Z"
},
"conversation": {
"id": "cmh1conv0001",
"status": "open",
"number": {
"id": "cmh1number0001",
"displayNumber": "+60 10-000 0000"
},
"contact": {
"id": "cmh1contact0001",
"phone": "60100000001",
"bsuid": "MY.1000000000000000001",
"username": null,
"name": "Demo Customer",
"profileName": "Demo Customer",
"email": "[email protected]",
"consent": "unknown",
"labels": [
"VIP"
],
"customFields": {
"tier": "Gold",
"birthday": "1990-01-31"
},
"refs": [
{
"system": "zoho_crm",
"refId": "5725767000000412001",
"url": "https://crm.zoho.com/crm/tab/Contacts/5725767000000412001"
}
],
"createdAt": "2026-11-07T02:15:00.000Z",
"updatedAt": "2026-11-07T02:15:00.000Z"
},
"assignee": {
"email": "[email protected]",
"name": "Demo Agent"
},
"labels": [
"Paid"
],
"unreadCount": 1,
"windowOpen": true,
"windowClosesAt": "2026-11-08T02:15:00.000Z",
"lastInboundAt": "2026-11-07T02:15:00.000Z",
"lastMessageAt": "2026-11-07T02:15:00.000Z",
"refs": [
{
"system": "zoho_desk",
"refId": "1092000000123",
"url": "https://desk.zoho.com/agent/demo/tickets/1092000000123"
}
],
"createdAt": "2026-11-07T02:15:00.000Z"
}
}
}- message.received: A customer message arrived. data: { message, conversation }
- message.sent: A message left wagswan: from an agent, the API, an automated reply, a broadcast, or the WhatsApp Business app on the phone. data: { message, conversation }
- message.status: An outgoing message moved to delivered, read or failed. data: { message, conversation }
- conversation.created: The first message with a contact on a number. data: { conversation }
- conversation.closed: Someone closed a conversation. data: { conversation }
- conversation.assigned: The assignee changed: a member, auto-assign or the API. assignee is null when unassigned. data: { conversation }
- conversation.labelled: Labels were added to or removed from a conversation. data: { conversation, added, removed } (label names)
- contact.created: A new contact: a first message from a new customer, an import, or the API. data: { contact }
- contact.updated: A contact was edited in wagswan, by an import that overwrote it, or through the API. data: { contact }
- contact.opted_in: A contact sent START or MULA, or was set to opted in. data: { contact }
- contact.opted_out: A contact sent STOP or BERHENTI, or a member set them to opted out. data: { contact }
- contact.stage_changed:
- csat.received:
- payment.paid:
- sequence.enrolled:
- sequence.completed:
- sequence.stopped:
- order.created:
Headers: X-Wagswan-Signature, X-Wagswan-Event and X-Wagswan-Delivery. The same event id can arrive more than once, so skip ids you have already handled. Events may arrive out of order; use the timestamps. The Send test button posts an event named test.
Verifying the signature
X-Wagswan-Signature looks like t=1793770501,v1=5257a869e7.... v1 is the hex HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with your secret. Check it before trusting the body, and reject timestamps older than 5 minutes so a captured request cannot be replayed. In Node.js:
const crypto = require('node:crypto');
// rawBody: the request body exactly as received (a string), before JSON.parse.
// header: the X-Wagswan-Signature header. secret: the whsec_ value shown when the webhook was created.
function verifyWagswanSignature(rawBody, header, secret, toleranceSeconds = 300) {
const parts = Object.fromEntries(header.split(',').map((part) => part.split('=')));
const timestamp = Number(parts.t);
if (!timestamp || Math.abs(Date.now() / 1000 - timestamp) > toleranceSeconds) return false;
const expected = crypto.createHmac('sha256', secret).update(timestamp + '.' + rawBody).digest('hex');
const a = Buffer.from(expected, 'hex');
const b = Buffer.from(parts.v1 || '', 'hex');
return a.length === b.length && crypto.timingSafeEqual(a, b);
}Retries
Answer with any 2xx within 10 seconds; do slow work after responding. Anything else, a redirect or a timeout counts as a failure and is retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours, then given up. The last 50 deliveries per endpoint, with status code and error, are listed in Settings > API. If an endpoint keeps failing for 3 days with no success, it is turned off and the workspace owners get an email; turning it back on resumes the deliveries still waiting.