Manage Devices
TIP
In the documentation, device = Phone number.
Register
Before we start sending message we will need to register our device
WARNING
Note: Under no circumstances you should deploy the WAPI in a datacenter IP. To be able to deploy it on a server/vps you will need to set up proxy when adding your device. proxy used must be a static residential one, otherwise your phone number will get banned.
Request
POST http://localhost:7000/devices
content-type: application/json
{
"phone": "<PHONE_NUMBER>",
"webhook_url": "https://webhook_url.com", // required in case you want to receive events(messages), otherwise optional
"proxy": "https://myproxy.com" // optional
}
Response
HTTP/1.1 200 OK
Date: Sat, 13 May 2023 18:04:17 GMT
Content-Type: application/json
Content-Length: 294
Connection: close
{
"code": "SUCCESS",
"message": "device added successfully",
"data": {
"id": "1psmjd07jvm80xp",
"jid": "",
"phone": "<PHONE_NUMBER>",
"wapi_user_id": "y8qm873600wcsfl",
"webhook_url": "https://webhook_url.com",
"proxy": "https://myproxy.com",
"created": "2023-05-13 18:04:17.600Z",
"updated": "2023-05-13 18:04:17.600Z"
}
}
List
Request
GET http://localhost:7000/devices
Response
HTTP/1.1 200 OK
Date: Mon, 08 May 2023 12:27:09 GMT
Content-Type: application/json
Content-Length: 350
Connection: close
{
"code": "SUCCESS",
"message": "devices fetched successfully",
"data": [
{
"id": "wezreqo45vl3vnd",
"jid": "************.0:14@s.whatsapp.net",
"phone": "***********",
"wapi_user_id": "ep3b2ge51up9toh",
"webhook_url": "https://webhook_url.com",
"proxy": "https://myproxy.com",
"created": "2023-05-02 14:20:09.887Z",
"updated": "2023-05-02 15:26:19.357Z"
}
]
}
List by ID
Request
GET http://localhost:7000/devices/{device_id}
Response
HTTP/1.1 200 OK
Date: Mon, 08 May 2023 13:10:12 GMT
Content-Type: application/json
Content-Length: 345
Connection: close
{
"code": "SUCCESS",
"message": "device fetch successfully",
"data": {
"id": "wezreqo45vl3vnd",
"jid": "************.0:14@s.whatsapp.net",
"phone": "***********",
"wapi_user_id": "ep3b2ge51up9toh",
"webhook_url": "https://webhook_url.com",
"proxy": "https://myproxy.com",
"created": "2023-05-02 14:20:09.887Z",
"updated": "2023-05-02 15:26:19.357Z"
}
}
Update
Request
PATCH http://localhost:7000/devices/{device_id}
content-type: application/json
{
"phone": "<RECEIVER_PHONE_NUMBER>"
}
Response
HTTP/1.1 200 OK
Date: Sat, 13 May 2023 18:08:00 GMT
Content-Type: application/json
Content-Length: 77
Connection: close
{
"code": "SUCCESS",
"message": "you've been logged out, please login in again."
}
Delete
Request
DELETE http://localhost:7000/devices/{device_id}
Response
HTTP/1.1 200 OK
Date: Sat, 13 May 2023 18:08:40 GMT
Content-Type: application/json
Content-Length: 58
Connection: close
{
"code": "SUCCESS",
"message": "device successfully removed"
}
Webhook toggle
We can toggle webhook on/off without updating a device. Setting enable=false
will disable webhook.
Request
PATCH http://localhost:7000/devices/{device_id}/webhook?enable=true
Response
HTTP/1.1 200 OK
Date: Sat, 13 May 2023 18:08:40 GMT
Content-Type: application/json
Content-Length: 58
Connection: close
{
"code": "SUCCESS",
"message": "webhook is ON"
}