Skip to main content

Get a WhatsApp number status

With this endpoint, you will be able to get the status and latest events related to your WhatsApp number connected to 2Chat.

Parameters

You will need to know the UUID of the number you connected to 2Chat.

You can get it using the List Numbers Endpoint.

Invocation

For the following examples, we will use WPNf3ea6c85-0dca-4d8a-a9a6-2b918f59cc97 as the UUID of the number we want to get the status from.

curl --location 'https://api.p.2chat.io/open/whatsapp/channel/WPNf3ea6c85-0dca-4d8a-a9a6-2b918f59cc97/status' \
--header 'Content-Type: application/json' \
--header 'X-User-API-Key: your_api_key_here'

Response

info

The values of this endpoint are updated every 3 seconds. To get the latest information on your number, you can poll for updated values respecting this 3-second interval.

The API will return a qr_code field in the response if the last event was qr-received. If you don't see a QR Code value, you will need to trigger a Connect Command.

The possible connection_status values are:

FieldDescription
CThe number is connected
DThe number is disconnected
FThe number is in a failure state

The events field in the response contains the last 10 events received for the number.

{
"success": true,
"connection_status": "D",
"qr_code": "2@ZeGOK2LyV3fZwaT5mcmTA7U6I9ynDKgaSXdbQWeHKZ8u2dFH8f3akPbrKp3bHv2CUASRKmmg94EqVQ==,SM0LWwtGkuQTWqRZSYwzEVQKocVK7O0C/CN4aUZZciI=,rImEFm0BBliEdh263TPXULfl4aWXF8w4hM4m++B6hT0=,qm8HQd2pCllPdnLRDUbEZ3FdSHMH4tpn8dTKsTc6jlA=,1",
"events": [
{
"event": "qr-received",
"payload": "{\"qr\": \"2@ZeGOK2LyV3fZwaT5mcmTA7U6I9ynDKgaSXdbQWeHKZ8u2dFH8f3akPbrKp3bHv2CUASRKmmg94EqVQ==,SM0LWwtGkuQTWqRZSYwzEVQKocVK7O0C/CN4aUZZciI=,rImEFm0BBliEdh263TPXULfl4aWXF8w4hM4m++B6hT0=,qm8HQd2pCllPdnLRDUbEZ3FdSHMH4tpn8dTKsTc6jlA=,1\"}",
"created_at": "2023-10-12T17:44:09Z"
},
{
"event": "initializing",
"payload": null,
"created_at": "2023-10-12T17:44:07Z"
}
]
}
tip

To render the QR code value as an image that can be scanned using a camera, you can use any library of your preference.