SendTemplate The method is intended for sending a template message. To send this message, you need to have or pre-create a message template. You can create a message template using the method CreateTemplate . The message will be added to the send queue. Messages will be kept for 24 hours in the queue until account will be authorized.
If you don't have your template, we can help you. Please contact us by mail support@green-api.com or in another convenient way.
Request To send a template message, you have to execute a request to:
POST {{apiUrl}}/waInstance{{{idInstance}}/sendTemplate/{{apiTokenInstance}}}
For idInstance
, apiTokenInstance
and apiUrl
request parameters, refer to Before you start section.
Request parameters Parameter Type Mandatory Description chatId
string Yes Chat Id templateId
string Yes Identifier of a previously created, existing template. You can use GetTemplates method to find id params
array No Array of parameters used in the template. Mandatory if the template uses parameters
Request parameters Parameter Type Mandatory Description chatId
string Yes Chat Id templateId
string Yes Identifier of a previously created, existing template. You can use GetTemplates method to find id params
array Yes Array of parameters used in the template. Mandatory if the template uses parameters message
object No Additional data for the template. Used for media templates with the type IMAGE, VIDEO, DOCUMNET, LOCATION, CAROUSEL postbackTexts
array No List of objects containing postback information
Structure of the message object for a template with the IMAGE type Parameter Type Description Example type
string Message type image image
object An image object containing an identifier or reference. See below for the detailed structure.
Structure of the image object Parameter Type Description Example link
string Link to image
Structure of the message object for a template with the VIDEO type Parameter Type Description Example type
string Message type video video
object Video object containing the link. See the detailed structure below
Structure of the video object Parameter Type Description Example link
string Link to the video
Structure of the message object for the DOCUMENT template type Parameter Type Description Example type
string Message type document document
object Document object containing the link. See below for detailed structure
Structure of the document object Parameter Type Description Example link
string Link to document filename
string Document file name
Structure of the message object for a template with the LOCATION type Parameter Type Description Example type
string Message type location location
object Geolocation object containing the ID or link. See below for detailed structure
Location object structure Parameter Type Description Example longitude
string Longitude of location -79.0896492 latitude
string Latitude of location 42.5950661 name
string Text that will appear under the map Miles Morales address
string The address of the location that will appear under the map New York 10019
Structure of the message object for a template with the CAROUSEL type Parameter Type Description Example type
string Message type carousel cardHeaderType
string Header type IMAGE / VIDEO cards
array List of cards in the carousel See the detailed structure below
Structure of the cards object Parameter Type Description Example link
string Image or video URL postbackTexts
array List of objects containing postback information See below for detailed structure
Structure of postbackTexts object Parameter Type Description Example index
number Button index (numbering starts with 0) 0 text
string Feedback text for the button hello
Request body example Sending a message to a personal chat:
{
"chatId" : "11001234567@c.us" ,
"templateId" : "2522g44c-c2e4-4416-b506-4bghdd456e5g" ,
"params" : [ "John" , "15" , "14.02.2024" , "GW-r4-aB" ],
"message" : {
"type" : "image" ,
"image" : {
"link" : "https://green-api.com/docs/news/2024/09/tech_solution_day.jpg"
}
}
}
Response Response parameters Parameter Type Description idMessage
string Sent message Id
Response body example {
"idMessage" : "3EB0C767D097B7C7C030"
}
SendTemplate errors For a list of errors common to all methods, refer to Common errors section.
Example