Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/rahul-baberwal/django-meta-whatsapp/llms.txt

Use this file to discover all available pages before exploring further.

The messaging API provides three endpoints for sending WhatsApp messages programmatically, plus one endpoint for reading recent conversations. All endpoints use POST (or GET for reads) and require the X-API-Key header. See Authentication for setup instructions.

POST /whatsapp/api/send-message/

Send a plain text WhatsApp message to any phone number.

Request Body

{
  "phone": "919876543210",
  "message": "Hello from the API!",
  "account_id": 1
}
phone
string
required
Recipient phone number including country code, without a leading + prefix. Example: "919876543210" for an Indian number.
message
string
required
The text message body to send. Supports plain text up to WhatsApp’s standard character limit.
account_id
integer
Primary key of the WhatsAppAccount to send from. When omitted, the view passes account=None to the send utility, which will use the default configured account.

Example

curl -X POST https://yourdomain.com/whatsapp/api/send-message/ \
  -H "X-API-Key: your-key" \
  -H "Content-Type: application/json" \
  -d '{"phone": "919876543210", "message": "Hello!"}'

Success Response

{
  "status": "sent",
  "result": {
    "messaging_product": "whatsapp",
    "contacts": [{"input": "919876543210", "wa_id": "919876543210"}],
    "messages": [{"id": "wamid.ABC123"}]
  }
}

POST /whatsapp/api/send-location/

Send a location pin message. The recipient will see an interactive map card in their chat.

Request Body

{
  "phone": "919876543210",
  "latitude": 28.6139,
  "longitude": 77.2090,
  "name": "Our Office",
  "address": "Connaught Place, New Delhi"
}
phone
string
required
Recipient phone number with country code, no + prefix.
latitude
number
required
Latitude in decimal degrees. Example: 28.6139 for New Delhi.
longitude
number
required
Longitude in decimal degrees. Example: 77.2090 for New Delhi.
name
string
Location name displayed as the card title in chat. Example: "Our Office".
address
string
Address text displayed below the map pin. Example: "Connaught Place, New Delhi".

Example

curl -X POST https://yourdomain.com/whatsapp/api/send-location/ \
  -H "X-API-Key: your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "919876543210",
    "latitude": 28.6139,
    "longitude": 77.2090,
    "name": "Our Office"
  }'

Success Response

{
  "status": "sent",
  "result": {
    "messaging_product": "whatsapp",
    "contacts": [{"input": "919876543210", "wa_id": "919876543210"}],
    "messages": [{"id": "wamid.DEF456"}]
  }
}

POST /whatsapp/api/send-template/

Send an approved WhatsApp template message with optional variable substitution. Templates must be submitted through the dashboard and approved by Meta before use.

Request Body

{
  "phone": "919876543210",
  "template_name": "order_update",
  "language": "en",
  "body_params": ["Rahul", "ORD-999"],
  "header_params": ["Order Shipped"]
}
phone
string
required
Recipient phone number with country code, no + prefix.
template_name
string
required
Exact name of the approved template as registered on Meta. Must match the name shown in Templates in your dashboard.
language
string
default:"en"
BCP-47 language code for the template. Examples: "en", "hi", "en_US". Defaults to "en" when omitted.
body_params
string[]
Ordered list of values to substitute into the template body’s {{1}}, {{2}}, etc. placeholders. The first element fills {{1}}, the second fills {{2}}, and so on. Passed to build_template_components(body_params=...).
header_params
string[]
Ordered list of values for variables in the template header component, using the same positional convention as body_params. Passed to build_template_components(header_params=...).

Example

curl -X POST https://yourdomain.com/whatsapp/api/send-template/ \
  -H "X-API-Key: your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "919876543210",
    "template_name": "order_update",
    "language": "en",
    "body_params": ["Rahul", "ORD-999"]
  }'

Success Response

{
  "status": "sent",
  "result": {
    "messaging_product": "whatsapp",
    "contacts": [{"input": "919876543210", "wa_id": "919876543210"}],
    "messages": [{"id": "wamid.GHI789"}]
  }
}

GET /whatsapp/api/chats/

Retrieve the 50 most recent conversations, ordered by the time of the last message.

Example

curl https://yourdomain.com/whatsapp/api/chats/ \
  -H "X-API-Key: your-key"

Success Response

{
  "conversations": [
    {
      "id": 1,
      "phone_number": "919876543210",
      "label": null,
      "unread_count": 2,
      "last_message_at": "2024-01-15T10:30:00Z"
    }
  ]
}

Response Fields

conversations
array
List of the 50 most recent conversation objects, sorted descending by last_message_at.

Build docs developers (and LLMs) love