> ## Documentation Index
> Fetch the complete documentation index at: https://docs.antryk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send WhatsApp Message

Send WhatsApp messages programmatically using the Antryk WhatsApp Service.

This endpoint allows you to send WhatsApp messages directly from your application using your connected WhatsApp Business service. It is suitable for transactional notifications, customer communication, alerts, reminders, and automated messaging workflows.

Authentication is handled securely through request headers, ensuring your API credentials are not exposed in the request body.

<Note>
  {" "}

  For generating your x-access-key and x-secret-key values, login into you
  Antryk's dashboard go to Api Keys section on side bar and create new api key .
  There you will be provided with your access key and secret key.{" "}
</Note>

## Send a WhatsApp Message

Use the `https://ses.antryk.com/api/v1/whatsapp/send` endpoint to send a WhatsApp message to a customer.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://ses.antryk.com/api/v1/whatsapp/send \
    --header "Content-Type: application/json" \
    --header "x-access-key: YOUR_ACCESS_KEY" \
    --header "x-secret-key: YOUR_SECRET_KEY" \
    --data '{
      "clientId": "YOUR_WHATSAPP_SERVICE_ID",
      "to": "+919340487676",
      "type": "text",
      "content": {
        "body": "Hi, your order has been shipped!"
      }
    }'
  ```

  ```javascript Javascript theme={null}
  fetch("https://ses.antryk.com/api/v1/whatsapp/send", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "x-access-key": "YOUR_ACCESS_KEY",
      "x-secret-key": "YOUR_SECRET_KEY",
    },
    body: JSON.stringify({
      clientId: "YOUR_WHATSAPP_SERVICE_ID",
      to: "+919340487676",
      type: "text",
      content: {
        body: "Hi, your order has been shipped!",
      },
    }),
  });
  ```

  ```python Python theme={null}
  # pip install requests

  import requests

  url = "https://ses.antryk.com/api/v1/whatsapp/send"

  headers = {
  "Content-Type": "application/json",
  "x-access-key": "YOUR_ACCESS_KEY",
  "x-secret-key": "YOUR_SECRET_KEY",
  }

  data = {
  "clientId": "YOUR_WHATSAPP_SERVICE_ID",
  "to": "+919340487676",
  "type": "text",
  "content": {
  "body": "Hi, your order has been shipped!"
  }
  }

  response = requests.post(url, headers=headers, json=data)

  print(response.status_code)
  print(response.json())

  ```
</CodeGroup>

<Note>
  {" "}

  Authentication is handled through the `x-access-key` and `x-secret-key`
  headers. Do not include your API credentials inside the request body.{" "}
</Note>

<Note>
  {" "}

  Keep your API credentials on your backend or another secure server-side
  environment. Do not expose your access key or secret key in frontend
  applications or publicly accessible code.{" "}
</Note>

## Request Parameters

<ParamField header="x-access-key" type="string" required>
  {" "}

  Your Antryk access key used for API authentication.{" "}
</ParamField>

<ParamField header="x-secret-key" type="string" required>
  {" "}

  Your Antryk secret key used to securely authorize the request.{" "}
</ParamField>

<ParamField body="clientId" type="string" required>
  {" "}

  The ID of your configured WhatsApp service in Antryk. This identifies which
  connected WhatsApp Business number should send the message.{" "}
</ParamField>

<ParamField body="to" type="string" required>
  {" "}

  The recipient's WhatsApp phone number in international E.164 format, including
  the country code. For example, `+919340487676` for an Indian phone
  number.{" "}
</ParamField>

<ParamField body="type" type="string" required>
  {" "}

  The type of WhatsApp message to send. Use `text` for text messages. Other
  message types can be used for supported media or file messages.{" "}
</ParamField>

<ParamField body="content" type="object" required>
  {" "}

  The content of the WhatsApp message. The fields inside `content` depend on the
  selected message type.{" "}
</ParamField>

<ParamField body="content.body" type="string" required>
  {" "}

  The text content of the WhatsApp message when `type` is `text`.{" "}
</ParamField>

<Tip>
  {" "}

  Use the recipient's complete international phone number, including the country
  code. For example, use `+919340487676` rather than `9340487676`.{" "}
</Tip>

<Warning>
  {" "}

  Make sure the recipient number is a valid WhatsApp number. Invalid or
  incorrectly formatted numbers may result in an API or delivery error.{" "}
</Warning>

## Request Example

A basic text message request looks like this:

```code theme={null}
{
"clientId": "YOUR_WHATSAPP_SERVICE_ID",
"to": "+919340487676",
"type": "text",
"content": {
"body": "Hi"
}
}
```

### Request Headers

Content-Type: application/json
x-access-key: YOUR\_ACCESS\_KEY
x-secret-key: YOUR\_SECRET\_KEY

### Parameter Examples

<ParamField header="x-access-key" type="string" required>
  {" "}

  Example: `YOUR_ACCESS_KEY`{" "}
</ParamField>

<ParamField header="x-secret-key" type="string" required>
  {" "}

  Example: `YOUR_SECRET_KEY`{" "}
</ParamField>

<ParamField body="clientId" type="string" required>
  {" "}

  Example: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`{" "}
</ParamField>

<ParamField body="to" type="string" required>
  {" "}

  Example: `+919340487676`{" "}
</ParamField>

<ParamField body="type" type="string" required>
  {" "}

  Example: `text`{" "}
</ParamField>

<ParamField body="content.body" type="string" required>
  {" "}

  Example: `Your order has been shipped!`{" "}
</ParamField>

### Message Types

The type field determines the kind of WhatsApp message you want to send.

### Text Messages

Use type: "text" to send a standard WhatsApp text message.

```json theme={null}
{
  "clientId": "YOUR_WHATSAPP_SERVICE_ID",
  "to": "+919340487676",
  "type": "text",
  "content": {
    "body": "Hi, your order has been shipped!"
  }
}
```

The message text is provided through content.body.

### File and Media Messages

The type field can also be used for supported file or media message types.

For example:

```json theme={null}
{
  "clientId": "YOUR_WHATSAPP_SERVICE_ID",
  "to": "+919340487676",
  "type": "file",
  "content": {
    "body": "Your requested document is attached."
  }
}
```

The exact content fields required for file or media messages depend on the supported WhatsApp message type. Refer to the relevant message type documentation for the required payload structure.

## Response

A successful request returns a confirmation that the WhatsApp message has been accepted for processing.

### Example:

```json theme={null}
{
  "success": true,
  "messageId": "msg_5QZ9S6",
  "to": "+919340487676",
  "queuedAt": "2026-08-21T09:14:30.000Z"
}
```

The messageId can be used to correlate the message with delivery status events and webhook notifications.

### Delivery Status

Sending a WhatsApp message successfully means that Antryk accepted the request for processing. It does not necessarily mean that the message has already been delivered to the recipient.

Use WhatsApp webhooks to track message delivery status.

A message can progress through statuses such as:

* sent
* delivered
* read
* failed

### For example:

sent → delivered → read

A failed message may include additional error information in the Antryk dashboard and logs.

## Error Scenarios

Common API errors include:

* 401 invalid credentials — Invalid x-access-key or x-secret-key.
* 400 invalid request — Required fields are missing or the request payload is invalid.
* 400 invalid recipient — The to phone number is missing or incorrectly formatted.
* 404 service not found — The clientId does not identify an active WhatsApp service.
* 400 unsupported message type — The requested type is not supported or the content does not match the selected message type.
* 429 rate limited — Too many requests were sent within a short period or the service has exceeded its applicable quota.
* 500 provider unavailable — An upstream WhatsApp provider or service is temporarily unavailable.

#### Error Response Example

```json theme={null}
{
  "success": false,
  "errors": [
    {
      "message": "Invalid recipient",
      "code": 400
    }
  ]
}
```

<Warning>
  {" "}

  Always validate recipient phone numbers and handle API errors appropriately.
  When retrying failed requests, use reasonable backoff to avoid duplicate
  messages and rate limiting.{" "}
</Warning>

### Best Practices

* Keep your x-access-key and x-secret-key credentials secure.
* Use the API from your backend rather than exposing credentials in frontend code.
* Store credentials in environment variables or a secure secret manager.
* Always provide the recipient's full international phone number.
* Validate recipient numbers before sending messages.
* Keep transactional messages clear and relevant.
* Avoid unnecessary or duplicate messages.
* Handle API errors and rate limits gracefully.
* Use webhooks to monitor delivery and read status.
* Use the returned messageId to correlate messages with delivery events.

## Environment Variables

For backend applications, store your Antryk credentials as environment variables.

For example:

```
ANTRYK_ACCESS_KEY=your_access_key
ANTRYK_SECRET_KEY=your_secret_key
WHATSAPP_SERVICE_ID=your_whatsapp_service_id
```

Then use these values in your application instead of hard-coding credentials.

<Note>
  {" "}

  Never commit production API credentials to Git repositories or expose them in
  client-side JavaScript.{" "}
</Note>
