SendVoiceStatus#
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 voice status. The status will be added to the send 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.
- Recommended audio format is MP3.
If the audio is longer than one minute, it will be cut to one minute when uploaded.
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.
Request#
To send a voice status, you have to execute a request at:
{{apiUrl}}/waInstance{{idInstance}}/sendVoiceStatus/{{apiTokenInstance}}
For this method use direct link to media file, not a link to download a file
If you use a link to download the file for method, you receive HTTP 200 OK code, but the sender not reciving this file as status.
The links may looks the same, but you cannot find any differences without opening them in your browser.
How to check the type of link?
- When you click on a direct link, you will see your file in the browser window. When you click on a link to download the file, you will see your file in download folder soon.
- With developer tools, it is easy to notice that a direct link to a file has the field:
content-type: audio/wave
or identical, but a link for downloading has the field:content-type: application/octet-stream
.
How to avoid problems with external links?
- Generate links using the UploadFile.
For apiUrl
, idInstance
and apiTokenInstance
request parameters, refer to Before you start section.
Request parameters#
Parameter | Type | Mandatory | Description |
---|---|---|---|
urlFile | string | Yes | Link to outgoing file |
fileName | string | Yes | File name. Must contain the file extension. Requires UTF-8 encoding without BOM. Supported formats: .mp3 , .wav |
backgroundColor | string | No | Message background. Default: #FFFFFF . Example site for getting the background color value |
participants | array<string> | 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 |
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:
{
"urlFile": "https://my.site.com/img/horse.mp3",
"fileName": "horse.mp3",
"backgroundColor": "#228B22",
"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"
}
SendVoiceStatus 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}}/sendVoiceStatus/{{apiTokenInstance}}"
payload = json.dumps({
"urlFile": "https://sw-media.storage.greenapi.net/1101000000/537157f6-4e24-4c4e-b5c6-9406c702f196.mp3",
"fileName": "music.mp3",
"backgroundColor": "#228B22",
"participants": [
"70000001234@c.us",
"440000001234@c.us"
]
})
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, json=payload)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/sendVoiceStatus/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"urlFile": "https://sw-media.storage.greenapi.net/1101000000/537157f6-4e24-4c4e-b5c6-9406c702f196.mp3",
"fileName": "music.mp3",
"backgroundColor": "#228B22",
"participants": [
"70000001234@c.us",
"440000001234@c.us"
]
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/sendVoiceStatus/")
.append({{apiTokenInstance}});
var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
var jsonBody = "{\r\n\t \"urlFile\": \"https://sw-media.storage.greenapi.net/1101000000/537157f6-4e24-4c4e-b5c6-9406c702f196.mp3\",\r\n\t \"fileName\": \"music.mp3\",\r\n\t \"backgroundColor\": \"#228B22\",\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("/sendVoiceStatus/")
.append({{apiTokenInstance}});
var response = Unirest.post(requestUrl.toString())
.header("Content-Type", "application/json")
.body("{\r\n\t \"urlFile\": \"https://sw-media.storage.greenapi.net/1101000000/537157f6-4e24-4c4e-b5c6-9406c702f196.mp3\",\r\n\t \"fileName\": \"music.mp3\",\r\n\t \"backgroundColor\": \"#228B22\",\r\n\t \"participants\": [\"70000001234@c.us\", \"440000001234@c.us\"]\r\n}")
.asString();
System.out.println(response);