curl --location 'https://api.weya.live/backend/api/whatsapp/add-agent-in-whatsapp-number' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"phoneNumberId": "6891f1d0c45d123456789abc",
"agentId": "6894a98a7fcde123456789ab"
}'
{
"status": true,
"code": 200,
"message": "Agent added to phone number successfully",
"errorMessage": null,
"data": []
}
Phone Numbers
Assign Agent to WhatsApp Number
Assign a WhatsApp agent to one of your connected WhatsApp numbers.
POST
/
api
/
whatsapp
/
add-agent-in-whatsapp-number
curl --location 'https://api.weya.live/backend/api/whatsapp/add-agent-in-whatsapp-number' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"phoneNumberId": "6891f1d0c45d123456789abc",
"agentId": "6894a98a7fcde123456789ab"
}'
{
"status": true,
"code": 200,
"message": "Agent added to phone number successfully",
"errorMessage": null,
"data": []
}
Overview
Assign a WhatsApp agent to one of your WhatsApp integrations, so the agent handles conversations on that number. A number has one agent; assigning another one replaces it. While assigning, Weya sets up the AiSensy webhook for the number so incoming messages reach the agent. For apro integration, the credentials are checked with AiSensy first. If this setup fails, the agent isn’t assigned.
Prerequisites
- An API key for your workspace
- The integration ID (
_idfrom Get WhatsApp Numbers) - A WhatsApp agent ID, from Get WhatsApp Agents
Request
curl --location 'https://api.weya.live/backend/api/whatsapp/add-agent-in-whatsapp-number' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"phoneNumberId": "6891f1d0c45d123456789abc",
"agentId": "6894a98a7fcde123456789ab"
}'
Response
{
"status": true,
"code": 200,
"message": "Agent added to phone number successfully",
"errorMessage": null,
"data": []
}
Error Handling
Errors returnstatus: false, with the reason in errorMessage.
- 400 Bad Request –
phoneNumberIdoragentIdis missing or not a valid ID, orFailed to configure WhatsApp provider webhook: …(basic plan). - 401 Unauthorized – Missing or invalid API key.
- 404 Not Found –
WhatsApp number not found: it doesn’t exist or wasn’t connected by the user who owns the API key. - 429 Too Many Requests – More than 1,000 WhatsApp requests in 15 minutes from your IP address.
- 500 Internal Server Error – Unexpected server error, or the AiSensy check failed (
proplan).
To undo the assignment, use Remove Agent from WhatsApp Number.
Was this page helpful?

