Pingtochat Docs

Pingtochat Docs

Did You Know?

Docy turns out that context is a key part of learning.

leafleafleafDocy banner shape 01Docy banner shape 02Man illustrationFlower illustration

Parameter with header-body-footer , buttons – quick-replay,visit-website,phone-number,copy-code

Estimated reading: 4 minutes 72 views

Overview

  • A header with a personalized text greeting.
  • A body containing the main message text.
  • A Quick Reply Button that allows users to opt out of promotional messages.
  • A Copy Code Button that enables users to copy a predefined code.

The footer example payload does not need to be included in the example payload, as it is already in the template; it will function correctly on its own.

This template is ideal for marketing campaigns while giving users an easy way to opt out and use a promotional code.

Endpoint:

http://{{your_domain}}/api/v1.0/{{phone_number_id}}/{{key}}/messages
Replace placeholders:

{{key}}: Your API key for authentication.How to create key

{{your_domain}}: Your domain URL where the API is hosted.

{{phone_number_id}}: The unique identifier of the phone number used for sending messages.

Method:

POST

Headers:

  • Content-Type: application/json
  • Authorization: Bearer <your_access_token>

Example Payload:

{
    "messaging_product": "whatsapp",
    "recipient_type": "individual",
    "to": "91xxxxxxxxxx",
    "type": "template",
    "template": {
        "name": "marketing_y",
        "language": {
            "code": "en_us"
        },
        "components": [
            {
                "type": "header",
                "parameters": [
                    {
                        "type": "text",
                        "text": "Hi user"
                    }
                ]
            },
            {
                "type": "body",
                "parameters": [
                    {
                        "type": "text",
                        "text": "Our"
                    },
                    {
                        "type": "text",
                        "text": "whatsapp message app"
                    }
                ]
            },
            {
                "type": "button",
                "sub_type": "quick_reply",
                "index": 0,
                "parameters": [
                    {
                        "type": "text",
                        "text": "Unsubscribe from Promos"
                    }
                ]
            },
            {
                "type": "button",
                "sub_type": "copy_code", 
                "index": 1,
                "parameters": [
                    {
                        "type": "text",
                        "text": "WRETTT" 
                    }
                ]
            }
        ]
    }
}

Key Components in the Payload

messaging_product

  • Type: String
  • Description: Specifies the messaging platform. Always set to "whatsapp".

recipient_type

  • Type: String
  • Description: Defines the recipient type. Use "individual" for one-on-one messaging.

to

  • Type: String
  • Description: The recipient’s WhatsApp number in international format (e.g., "91xxxxxxxxxx").

type

  • Type: String
  • Description: Defines the type of message. Always set to "template".

template.name

  • Type: String
  • Description: Specifies the pre-approved WhatsApp template name. In this case, it is "marketing_y".

template.language.code

  • Type: String
  • Description: Language code for the template. Must match the approved template settings.
  • Example: "en_us" for English (United States).

components

  • Type: Array
  • Description: Defines the interactive elements in the template.
Header
  • Type: header
  • Description: The header section of the template message.
  • parameters:
    • type: "text" – Specifies that the header contains text.
    • text: "Hi user" – The actual content of the header.
Body
  • Type: body
  • Description: The main content of the template message.
  • parameters:
    • type: "text"
    • text: "Our" – First part of the message.
    • text: "whatsapp message app" – Second part of the message.
Quick Reply Button
  • Type: button
  • Description: Adds an interactive Quick Reply button.
  • sub_type: "quick_reply"
  • index: 0 (First button in the list)
  • parameters:
    • type: "text"
    • text: "Unsubscribe from Promos" – The text displayed on the button.
Copy Code Button
  • Type: button
  • Description: Adds a Copy Code button.
  • sub_type: "copy_code"
  • index: 1 (Second button in the list)
  • parameters:
    • type: "text"
    • text: "WRETTT" – The predefined code for the user to copy.

Response

If the request is successful, the API returns a 200 OK response with the following JSON structure:

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "91xxxxxxxxxx",
      "wa_id": "91xxxxxxxxxx",
      "status_id": "NTg0MTc="
    }
  ],
  "messages": [
    {
      "id": "M2s4da2y4P",
      "message_status": "accepted"
    }
  ]
}

Response Field Descriptions

messaging_product

  • Type: String
  • Description: Always returns "whatsapp".

contacts

  • Type: Array
  • Description: Contains recipient details.
Fields within contacts:
  • input: The phone number used in the API request.
  • wa_id: WhatsApp ID linked to the phone number.
  • status_id: A unique identifier for message status.

messages

  • Type: Array
  • Description: Contains details about the sent message.
Fields within messages:
  • id: A unique message identifier.
  • message_status: Indicates the message processing status.
    • "accepted": The message was successfully processed.

Sample codes

Leave a Comment

Share this Doc

Parameter with header-body-footer , buttons – quick-replay,visit-website,phone-number,copy-code

Or copy link

CONTENTS