[go: up one dir, main page]

Skip to content

SendTextStatus#

Test

Beta version

The functionality is in beta mode. Features are subject to change and may also work unstably. There may be additional charges for functionality in the future.
You can request access to the functionality via Green API support

The method is aimed for sending a text status. The status will be added to the queue. The status will be kept for 24 hours in the queue until instance will be authorized. The rate at which statuses are sent from the queue is managed by Message sending delay parameter.

Important

In order for the recipient to see the sender’s statuses, both parties must save the numbers of the interlocutors to the contact list

The contact list is fetched using the GetContacts method based on the contactName field. To get an updated contact list, you need to rename a contact and re-authorize by rescanning the QR code.

Statuses are sent only to the first 1024 contacts from the GetContacts method with a valid contactName field.

Request#

To send a text status, you have to execute a request at:

POST
{{apiUrl}}/waInstance{{idInstance}}/sendTextStatus/{{apiTokenInstance}}

For apiUrl, idInstance and apiTokenInstance request parameters, refer to Before you start section.

Request parameters#

Parameter Type Mandatory Description
message string Yes Message text. Emoji 😃 characters supported. Requires UTF-8 encoding without BOM
backgroundColor string No Message background. Default: #FFFFFF. Example site for getting the background color value. Important! The background color should be changed to anything other than white. The status text is published in white characters.
font string No Text font. Accepts values:
SERIF - Here is how your text will look
SANS_SERIF - Here is how your text will look
NORICAN_REGULAR - Here is how your text will look
The font is used only for Latin letters
BRYNDAN_WRITE - Here is how your text will look
OSWALD_HEAVY - Here is how your text will look
participants array No An array of strings with contact IDs for whom the status will be available. If the field value is empty,"participants": [], the status will be available to all contacts.

The maximum length of a text message is 500 characters

If non-existent numbers are added to the participants field, the status will not be sent to these numbers

Request body example#

Sending a status:

{
    "message": "I use Green-API to send this Status!",
    "backgroundColor": "#228B22", // (#FFFFFF) It is not recommended to use a white background
    "font": "SERIF",
    "participants": ["70000001234@c.us", "440000001234@c.us"] // status will be available only to the specified contacts
}

Response#

Response parameters#

Parameter Type Description
idMessage string Sent message Id

Response body example#

{
    "idMessage": "3EB0C767D097B7C7C030"
}

SendTextStatus errors#

For a list of errors common to all methods, refer to Common errors section

HTTP code Error identifier Description
403 Forbidden There is no access to the functionality of the beta version of the status methods. You can request access to the functionality via Green API support

Request examples#

import requests  
import json  

url = "{{apiUrl}}/waInstance{{idInstance}}/sendTextStatus/{{apiTokenInstance}}"

payload = json.dumps({
"message": "I use Green-API to send this Status!",
"backgroundColor": "#228B22",
"font": "SERIF",
"participants": [
    "70000001234@c.us", 
    "440000001234@c.us"
]
})
headers = {
'Content-Type': 'application/json'
}

response = requests.post(url, json=payload)

print(response.text.encode('utf8'))
<?php
//The apiUrl, idInstance and apiTokenInstance values are available in console, double brackets must be removed
$url = '{{apiUrl}}/waInstance{{idInstance}}/sendTextStatus/{{apiTokenInstance}}';

//chatId is the number to send the message to (@c.us for private chats, @g.us for group chats)
$data = array(
    "message": "I use Green-API to send this Status!",
    "backgroundColor": "#228B22",
    "font": "SERIF",
    "participants": ["70000001234@c.us", "440000001234@c.us"]
);

$options = array(
    'http' => array(
        'header' => "Content-Type: application/json\r\n",
        'method' => 'POST',
        'content' => json_encode($data)
    )
);

$context = stream_context_create($options);

$response = file_get_contents($url, false, $context);

echo $response;
?>
curl --location '{{apiUrl}}/waInstance{{idInstance}}/sendTextStatus/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "message": "I use Green-API to send this Status!",
    "backgroundColor": "#228B22",
    "font": "SERIF",
    "participants": ["70000001234@c.us", "440000001234@c.us"]
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/sendTextStatus/")
    .append({{apiTokenInstance}});

var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);

var jsonBody = "{\r\n\t    \"message\": \"I use Green-API to send this Status!\",\r\n\t    \"backgroundColor\": \"#228B22\",\r\n\t    \"font\": \"SERIF\",\r\n\t    \"participants\": [\"70000001234@c.us\", \"440000001234@c.us\"]\r\n}";

var requestEntity = new HttpEntity<>(jsonBody, headers);

var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/sendTextStatus/")
    .append({{apiTokenInstance}});

var response = Unirest.post(requestUrl.toString())
    .header("Content-Type", "application/json")
    .body("{\r\n\t    \"message\": \"I use Green-API to send this Status!\",\r\n\t    \"backgroundColor\": \"#228B22\",\r\n\t    \"font\": \"SERIF\",\r\n\t    \"participants\": [\"70000001234@c.us\", \"440000001234@c.us\"]\r\n}")
    .asString();

System.out.println(response);