Skip to content

SendMediaStatus#

Test Postman

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 pictures or video status. The status will be added to the send queue. Statuses will be kept for 24 hours in the queue until instance will be authorized.
The rate at which status 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.

For the method to work correctly, we recommend using files with the following parameters:

  • Recommended audio format is MP3.

    If the audio is longer than one minute, it will be cut to one minute when uploaded.

  • Recommended video format is MP4.

    If the video is longer than one minute, it will be cut to one minute when uploaded.

  • Recommended aspect ratio for the picture is 9:16 (vertical picture)

Request#

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

POST
{{apiUrl}}/waInstance{{idInstance}}/sendMediaStatus/{{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: image/jpeg or identical, but a link for downloading has the field: content-type: application/octet-stream.

How ​​to avoid problems with external links?

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. For example: test.jpg
caption string No Media status caption. The maximum field length is 1024 characters
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.png",
    "fileName": "horse.png",
    "caption": "Little horse",
    "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"
}

SendMediaStatus 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}}/sendMediaStatus/{{apiTokenInstance}}"

payload = json.dumps({
"urlFile": "https://sw-media.storage.greenapi.net/1101000000/537157f6-4e24-4c4e-b5c6-9406c702f196.png",
"fileName": "horse.png",
"caption": "Little horse",
"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}}/sendMediaStatus/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "urlFile": "https://sw-media.storage.greenapi.net/1101000000/537157f6-4e24-4c4e-b5c6-9406c702f196.png",
    "fileName": "horse.png",
    "caption": "лошадка",
    "participants": [
    "70000001234@c.us", 
    "440000001234@c.us"
]
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
    .append({{apiUrl}})
    .append("/waInstance").append({{idInstance}})
    .append("/sendMediaStatus/")
    .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.png\",\r\n\t\"fileName\": \"horse.png\",\r\n\t\"caption\": \"little horse\",\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("/sendMediaStatus/")
    .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.png\",\r\n\t\"fileName\": \"horse.png\",\r\n\t\"caption\": \"little horse\",\r\n\t\"participants\": [\"70000001234@c.us\", \"440000001234@c.us\"]\r\n}")
    .asString();

System.out.println(response);