Set WhatsApp Status
This endpoint will let you set a status on your WhatsApp account, like the "away" or "only calls" texts.
These values will remain assigned until you change them.
Parameters
These parameters should be sent as JSON payload in the request body.
| Field | Description | Example values |
|---|---|---|
status | The value of the status | My cool new status |
Invocation
Make a POST request to https://api.p.2chat.io/open/whatsapp/set-status/<number> where <number> is the phone number that you have connected to 2Chat.
- cURL
- Python
- JavaScript
- PHP
curl --location --request POST 'https://api.p.2chat.io/open/whatsapp/set-status/+595981048478' \
--header 'X-User-API-Key: your_api_key_here' \
--header 'Content-Type: application/json' \
--data-raw '{
"status": "My cool new status"
}'
import requests
import json
url = "https://api.p.2chat.io/open/whatsapp/set-status/+595981048478"
payload = json.dumps({
"status": "My cool new status"
})
headers = {
'X-User-API-Key': 'your_api_key_here',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
var axios = require('axios');
var data = JSON.stringify({
"status": "My cool new status"
});
var config = {
method: 'post',
url: 'https://api.p.2chat.io/open/whatsapp/set-status/+595981048478',
headers: {
'X-User-API-Key': 'your_api_key_here',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.p.2chat.io/open/whatsapp/set-status/+595981048478',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"status": "yeah!"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'X-User-API-Key: your_api_key_here'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response
The API will return whether it succeded or not to queue the request for processing
{
"success": true,
"batched": true
}