Pingtochat Docs

Pingtochat Docs

Did You Know?

You can create any type of product documentation with Docy

leafleafleafDocy banner shape 01Docy banner shape 02Man illustrationFlower illustration

Message with parameter and attachment

Estimated reading: 3 minutes 78 views

Description:

Send a template message with dynamic text parameters and an image attachment in the header.

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.

Example:

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "91xxxxxxxxxx",
  "type": "template",
  "template": {
    "name": "utility_variables_attachment",
    "language": {
      "code": "en"
    },
    "components": [
        {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "12345"
          }
        
        ]
      },
        {
            "type": "header",
            "parameters": [
            {
                "type": "image",
                "image": {
                "link": "https://chat.pingtochat.com/template_media/1736424548.png"
                }
            }
            ]
        }
    ]
  }
}

Field Descriptions

General Fields

  • messaging_product: (string) Always whatsapp.
  • recipient_type: (string) Set to individual for one-to-one messages.
  • to: (string) The recipient’s phone number in E.164 format (e.g., 91xxxxxxxxxx).
  • type: (string) Always template.

Template Object

  • name: (string) The name of the pre-approved template (e.g., utility_variables_attachment).
  • language: (object) Specifies the language for the template.
    • code: (string) The language code (e.g., en for English).

Components Array

  1. Header:
    • type: (string) Always header for attachments.
    • parameters: (array) Holds the media or placeholders for the header.
      • type: (string) Always image for images.
      • image: (object) Contains the image details.
        • link: (string) URL of the image (e.g., https://chat.pingtochat.com/template_media/1736424548.png).
  2. Body:
    • type: (string) Always body for the main text content.
    • parameters: (array) Holds the placeholders to populate the template.
      • type: (string) Always text.
      • text: (string) The value to replace placeholders (e.g.,"12345").

Response

A successful request will return an HTTP status code of 200 OK along with the following response structure:

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

Field Descriptions

  1. messaging_product:
    • Type: String
    • Description: Indicates the messaging platform. Always returns whatsapp for messages sent via the WhatsApp Business API.
  2. contacts:
    • Type: Array
    • Description: Contains information about the message recipient(s).
    • Fields:
      • input:
        • Type: String
        • Description: The phone number input used in the API request (e.g., 91xxxxxxxxxx).
      • wa_id:
        • Type: String
        • Description: The WhatsApp ID associated with the input phone number.
      • status_id:
        • Type: String
        • Description: A unique identifier for the status of the message.
  3. messages:
    • Type: Array
    • Description: Contains details about the sent message.
    • Fields:
      • id:
        • Type: String
        • Description: A unique identifier for the message sent (e.g., M2s4da2y4P).
      • message_status:
        • Type: String
        • Description: The status of the message at the time of the response. Example values include:
          • accepted: The message was successfully accepted by the system.

Sample codes

Leave a Comment

Share this Doc

Message with parameter and attachment

Or copy link

CONTENTS