Skip to main content
Send WhatsApp messages programmatically using the Antryk WhatsApp Service. This endpoint lets you send WhatsApp messages directly from your application using your connected WhatsApp Business service. It supports four message types: text, template, image, and document. Use it for transactional notifications, customer communication, alerts, reminders, and automated messaging workflows. Authentication is handled through request headers, so your API credentials are never exposed in the request body.
To generate your x-access-key and x-secret-key values, log in to your Antryk dashboard, open the API Keys section in the sidebar, and create a new API key. Your access key and secret key are shown there.

Endpoint

Quickstart: send a text message

Authentication is handled through the x-access-key and x-secret-key headers. Do not include your API credentials inside the request body.
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.

Request Parameters

Headers

string
required
Must be application/json.
string
required
Your Antryk access key used for API authentication.
string
required
Your Antryk secret key used to securely authorize the request.

Body

string
required
The ID of your configured WhatsApp service in Antryk. This identifies which connected WhatsApp Business number sends the message. Example: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
string
required
The recipient’s WhatsApp phone number in international E.164 format, including the country code. Example: +919340487676 for an Indian phone number.
string
required
The type of message to send. Supported values: text, template, image, and document. See Message types.
object
required
The message content. The fields inside content depend on the selected type. See the sections below for the exact structure of each type.
Use the recipient’s complete international phone number, including the country code. For example, use +919340487676 rather than 9340487676.
Make sure the recipient number is a valid WhatsApp number. Invalid or incorrectly formatted numbers may result in an API or delivery error.

Message types

The type field determines the kind of message you send and the shape of content.

Text messages

Use type: "text" to send a standard WhatsApp text message. The message text goes in content.body.
string
required
The text of the message. Example: Your order has been shipped!

Template messages

Use type: "template" to send a message template that has been approved in WhatsApp Manager. The content object holds the template name, the language, and the variable values if the template has any.
string
required
The name of the approved template, exactly as it appears in WhatsApp Manager.
object
required
The template language. Contains a code field, for example { "code": "en" }. The code must match the approved language of the template exactly.
array
The variable values for the template. Required only if the template contains variables. Each component has a type (for example body) and a parameters array.
Which case applies depends on the variables in your template.
Use this when the template text is fixed and contains no placeholders. Omit components.
string
required
The parameter type. Use text for text variables.
string
required
The value that replaces the placeholder.
string
The variable name, for example first_name. Required only for templates that use named variables. Omit it for numbered variables.
How to tell which variable style a template uses: open the template in WhatsApp Manager and check its text. {{1}} is numbered. {{first_name}} is named.
Template requests must match the approved template exactly:
  • The number of values must match the number of variables in the template.
  • The language code must match the approved language exactly. en and en_US are different codes.

Image messages

Use type: "image" to send an image.

Document messages

Use type: "document" to send a file such as a PDF.

Media content fields

These fields apply to image and document messages.
A publicly reachable HTTPS URL of the file to send. Provide either link or id, never both.
string
The ID of an existing, previously uploaded media file. To use a media ID, replace "link": "..." with "id": "<media_id>". Provide either link or id, never both.
string
Optional caption shown with the file. Up to 1024 characters. Supported for images and documents.
string
The file name shown to the recipient. Documents only. Include the file extension, for example invoice-123.pdf.
Using an existing media ID instead of a link:

Media requirements

SVG, WebP, and GIF are not supported as images. WhatsApp may silently drop these files even though the API returns a message ID. Convert them to JPEG or PNG before sending.
URLs passed in link must be publicly reachable. Files behind a login, firewall, or expiring private link cannot be fetched and will not be delivered.

Response

A successful request returns a confirmation that the WhatsApp message has been accepted for processing.
Use the messageId to correlate the message with delivery status events and webhook notifications.

Delivery status

A successful response means Antryk accepted the request for processing. It does not necessarily mean the message has been delivered to the recipient. Use WhatsApp webhooks to track delivery. A message can progress through these statuses:
  • 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 in 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

Always validate recipient phone numbers and handle API errors appropriately. When retrying failed requests, use reasonable backoff to avoid duplicate messages and rate limiting.

Troubleshooting

Check the image format. Only JPEG and PNG are supported, up to 5 MB. SVG, WebP, and GIF files may be silently dropped by WhatsApp even though the API accepts the request. Also confirm the link is publicly reachable.
Verify that:
  • content.name matches the approved template name exactly.
  • language.code matches the approved language exactly (en and en_US are different).
  • The number of parameters matches the number of variables in the template.
  • For named variables, every parameter_name matches a variable in the template.
Open the template in WhatsApp Manager. {{1}} and {{2}} are numbered variables, so send values in order. {{first_name}} is a named variable, so send each value with its parameter_name.

Best practices

  • Keep your x-access-key and x-secret-key credentials secure.
  • Call 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.
  • Use template messages for notifications you send proactively, and keep transactional messages clear and relevant.
  • Use a stable, publicly hosted URL for media, or reuse an uploaded media id.
  • 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:
Then use these values in your application instead of hard-coding credentials.
Never commit production API credentials to Git repositories or expose them in client-side JavaScript.