Send message with the WhatsApp API

Sends a message from a business phone number and returns its id in messages[0].id. Free-form types (text, image, video, document, audio) only reach someone who wrote to the number in the last 24 hours; to start a conversation, send type template with an approved template from List message templates. Meta bills messages to the account according to its WhatsApp pricing.

Identifier
whatsapp_send_message

The request

POST https://connect.reportei.com/api/tools/whatsapp_send_message/execute
Authorization: Bearer <merchant token>
x-customer-token: <customer token>
Content-Type: application/json
Accept: application/json

{
  "customer_toolkit": "<connection UUID>",
  "arguments": {
    "phone_number_id": "<phone_number_id>",
    "messaging_product": "whatsapp",
    "recipient_type": "individual",
    "to": "<recipient_number_with_country_code>",
    "type": "text",
    "text": {
      "body": "Hello! This is an example message.",
      "preview_url": false
    }
  }
}

Your system sends your customer's connection id and the tool arguments. The headers are the same as the rest of the Connect API: your product's token and your customer's token.

Illustrative example. Replace the tokens, connection UUID and destination values with your own. This page does not execute the request.

Before executing

  • For type=text, include text.body. The recipient number must contain the country code and digits only. Use the connected business account's phone_number_id.
  • Free-form text is for conversations within 24 hours of the user's message. To start a conversation outside that window, use type=template with an approved template, language and its required parameters.
  • The returned ID identifies a message accepted by the API; it does not confirm delivery. Inspect api_error.body for provider HTTP errors.

Parameters

ParameterTypeRequiredDescription
phone_number_idstringYesId of the business phone number that sends, from List phone numbers.
messaging_productstringYesAlways whatsapp.Values: whatsapp
recipient_typestringYesindividual for a person, group for a WhatsApp group of the number.Values: individual, group
tostringYesPhone number of the person with country code, digits only, for example 5511987654321, or the id of the group.
typestringYesKind of message. Send the object with the same name, such as text or template.Values: text, template, image, video, document, audio
textobjectYes, if type=textFor type text.
templateobjectYes, if type=templateFor type template.
imageobjectYes, if type=imageFor type image: a JPEG or PNG at a public URL.
videoobjectYes, if type=videoFor type video: an MP4 or 3GP at a public URL.
documentobjectYes, if type=documentFor type document: a file at a public URL, such as a PDF.
audioobjectYes, if type=audioFor type audio: an audio file at a public URL.

Supported connections

Your customer connects their WhatsApp account once, with one of the modes below. The same connection serves every tool of the toolkit.

API key

Your customer pastes the app's key on a Connect screen, or your system sends the key with POST /api/customer-toolkits, with no screen.

The response

On success, Connect preserves the app's response status and body. HTTP errors returned by the app use the {error, api_error} envelope; authentication or validation can fail before execution. The X-Toolkit-Execution-Id header identifies the recorded execution, available at GET /api/tools/executions/{uuid}.

Illustrative success format

{
  "messaging_product": "whatsapp",
  "messages": [
    {
      "id": "wamid.EXAMPLE"
    }
  ]
}

The content below is an example, not a recorded execution. Save X-Toolkit-Execution-Id when returned to look up the execution. Connect provides no retries or idempotency: repeating a POST may send the message again.

Ready for AI agents

This tool's input is a JSON Schema, available at GET /api/tools/whatsapp_send_message. It becomes your agent's tool definition with no conversion.

Other WhatsApp tools

See all 10 tools

Toolkits in the same category

See all 100 toolkits

See Connect applied to your product.

Try it for 15 days with no card, or walk our team through your use case.