Text-Based Message

Use this API to send messages using the Text based message.

📘

Note:

  1. Sending Marketing Templates through MM Lite for enhanced delivery optimization. For more details, refer to MM Lite document.
  2. To send a text-based message template, make a POST call to /PHONE_NUMBER_ID/messages and attach a message object with type=template. Then, add a template object.
  3. Substitute the placeholder properties below using the properties table.

Request Parameters

Key Value Description Data type Required/Optional Constraints

Authorization

{{PARTNER_APP_TOKEN}}

Access Token for the application

String

Required

Should be a valid
Partner App Access
Token.

appId

{{APP_ID}}

App ID to fetch the
access token

String

Required

The ID should be a valid app Id of Gupshup.

messaging_product

whatsapp

Messaging product

String

Required

recipient_type

individual

Recipient type

String

Required

to

91785876xxxx

Destination phone number where the message needs to be sent

String

Required

Must be a valid phone number

type

template

Messaging type

String

Required

The type should be template to send a template message.

template

{ "name": "TEMPLATE_NAME", "language": { "code": "LANGUAGE_AND_LOCALE_CODE" }, "components": [ "<NAMED_PARAMETER_INPUT>" OR "<POSITIONAL_PARAMETER_INPUT>" ] }

Template message inside body

Object

Required

<NAMED_PARAMETER_
INPUT>
Required when you have used named parameters in your
template's body text.

<POSITIONAL_PARAMT
ER_INPUT>

Required when you have used positional
parameters in your template's body text.

Sample Request

curl --location 'https://partner.gupshup.io/partner/app/{{APP_ID}}/v3/message' \
--header 'accept: application/json' \
--header 'Authorization: {{PARTNER_APP_TOKEN}}' \
--header 'Content-Type: application/json' \
--data '{
		"messaging_product": "whatsapp",
		"recipient_type": "individual",
    "to": "PHONE_NUMBER",
    "type": "template",
    "template": {
    		"name": "TEMPLATE_NAME",
        "language": {
        		"code": "LANGUAGE_AND_LOCALE_CODE"
				},
				"components": [
        		"<NAMED_PARAMETER_INPUT>",
            "<POSITIONAL_PARAMETER_INPUT>"
        ]
		}
}' 

Sample Response

{			
	"messages": [		
		{		
			"id":	"GUPSHUP_MESSAGE_ID"	
		}		
 		],	
		"messaging_product": "whatsapp",	
		"contacts": [	
		{	
			"input": "DESTINATION_PHONE_NO",	
			"wa_id": "DESTINATION_PHONE_NO"	
		}	
	]	
}	

Status Codes

Status CodeResponseComments
Success
200{ "messages": [ { "id": "GUPSHUP_MESSAGE_ID" } ], "messaging_product": "whatsapp", "contacts": [ { "input": "DESTINATION_PHONE_NO", "wa_id": "DESTINATION_PHONE_NO" } ] }
Error
400{ "message": "Callback Billing must be enabled for this API", "status": "error" }if Callback billing is not enabled for the app
400{ "message": "Invalid App Details", "status": "error" }if app details are not found
401{ "status": "error", "message": "Authentication Failed" }When API key authentication fails
Language
Click Try It! to start a request and see the response here!