Platform
Chatbot Builder Bulk Messaging Team Inbox Mini CRM API & Webhooks AI Integration WhatsApp Flows
Industries
E-commerce & D2C Real Estate Education Healthcare Finance & BFSI Logistics Hospitality Retail
Integrations 📚 Learn 📝 Blog 🗂 Codex Pricing Start Free Trial →
Connect  ›  Connect Claude to WhatsApp
AI connection guide

Connect Anthropic Claude to WhatsApp

Claude brings a different auth pattern from OpenAI: an x-api-key header, a required version header, and max_tokens you must always include. This guide covers every field exactly as the Anthropic API expects them.

 Published 21 June 2026  8 min read  Live-researched  Bring your own key

Anthropic's Messages API works well in a WhatsApp chatbot. The setup is close to OpenAI's but with three important differences that catch people out: the auth header is named x-api-key, a second required header called anthropic-version must be present, and max_tokens is not optional. Miss any one of these and the request returns an error with no useful reply.

This guide assumes you know the External API Request step. If not, read the foundation guide first.

Step 1: Get your Anthropic API key

1

Sign in to the Anthropic Console

Go to console.anthropic.com and sign in or create an account. Note: the console and claude.ai share the same login but are separate products with separate billing.
2

Create a key under API Keys

In Settings, open API Keys and create a new key. Name it descriptively (e.g. wa-expert-production). The key starts with sk-ant-. Copy it immediately.
3

Add credits

Under Billing, add a credit card or pre-purchase credits. The API will return authentication or quota errors if your account has no available credits.

 Official source

Current model IDs and pricing: docs.anthropic.com/en/docs/models-overview. Claude model IDs include a date in them; retired model IDs return an error, so check this page if a previously working call breaks.

Step 2: Fill in the External API Request step

External API Request
Method
POST
Request URL
https://api.anthropic.com/v1/messages
Auth Type
API key in header
Header Parameters
x-api-key
YOUR_ANTHROPIC_KEY
anthropic-version
2023-06-01
Content-Type
application/json
Body Type
JSON (raw)
Response Type
Default Response
SaveRun and Save

Method

POST.

Request URL

Request URL
https://api.anthropic.com/v1/messages

Headers (three required, not two)

Header nameValueWhy
x-api-keyYour Anthropic key (sk-ant-...)Authentication
anthropic-version2023-06-01Required API version header. The date is fixed; do not change it.
Content-Typeapplication/jsonTells the API you are sending JSON

All three are required. The anthropic-version value is 2023-06-01 regardless of which model or release date you are using.

Body

Claude uses a top-level system field (outside the messages array) for the persona instruction, which differs from OpenAI's approach of putting it as a system-role message.

JSON body
{
  "model": "claude-sonnet-4-6",
  "max_tokens": 500,
  "system": "You are a helpful support assistant for {{business_name}}. Answer briefly and politely.",
  "messages": [
    {
      "role": "user",
      "content": "{{customer_message}}"
    }
  ]
}

 max_tokens is not optional

Unlike OpenAI, Claude's API will return a validation error if you omit max_tokens. There is no default. 500 is a sensible starting point for WhatsApp-length replies. The field limits the reply length and therefore the cost per request.

Step 3: Map the reply into WhatsApp

Claude's response format differs from OpenAI's. The answer is in a content array, not a choices array.

Where the answer sits in the response
{
  "content": [
    {
      "type": "text",
      "text": "...Claude's reply is here..."
    }
  ],
  "model": "claude-sonnet-4-6-20250514",
  "stop_reason": "end_turn",
  "usage": { "input_tokens": 42, "output_tokens": 67 }
}

Map content[0].text into your next WhatsApp message step. If you request only a text reply (the default), there will always be exactly one content block of type text.

Worked example: a booking assistant

A customer asks about rescheduling their appointment. The system prompt tells Claude about your booking policy; the customer's message is the question.

Body with booking context
{
  "model": "claude-sonnet-4-6",
  "max_tokens": 400,
  "system": "You are the booking assistant for a dental clinic. Appointments can be rescheduled up to 24 hours before with no fee. Cancellations within 24 hours incur a fee of Rs 200. Rescheduling can be done by replying to this chat or calling 022-1234-5678. Keep answers brief.",
  "messages": [
    {
      "role": "user",
      "content": "{{customer_message}}"
    }
  ]
}

Claude reads the policy from the system field and answers clearly. You do not need to script every variation of the question; the model handles the phrasing and fills in the right answer from the context you gave it.

Troubleshooting

SymptomLikely causeFix
400 Bad RequestMissing max_tokens, or missing anthropic-version headerAdd max_tokens to the body; confirm anthropic-version: 2023-06-01 is in headers
401 UnauthorizedWrong or revoked API keyRe-check the key in console.anthropic.com; confirm header is x-api-key, not Authorization
404 Not FoundModel ID has been retiredCheck docs.anthropic.com for the current model IDs; Claude model names include a date stamp that becomes invalid when retired
529 OverloadedAnthropic capacity spikeRetry after a short pause; consider adding a delay step before the Claude call
Reply cut offmax_tokens too lowRaise max_tokens in the body

Anthropic returns detailed error messages in the response body. Always read the error field before troubleshooting.

Common questions

Where do I get an Anthropic API key?
+
Sign in or create an account at console.anthropic.com. The console and claude.ai share the same login but are separate products. Under Settings, open API Keys and create a key. It starts with sk-ant-. You will need to add credits or a payment method before the key works beyond any trial credit.
Is max_tokens really required?
+
Yes. Unlike OpenAI, Claude's API will return a validation error if you omit max_tokens. There is no default. A value of 500 is a sensible starting point for WhatsApp replies; raise it if the bot's answers are being cut off.
What is the anthropic-version header?
+
It is a required header on every request that tells the API which version of the response format you expect. The value is 2023-06-01. That date is the API version, not the model release date, and it has remained unchanged through every model generation. Omitting it causes an error.
Which Claude model should I use for a WhatsApp chatbot?
+
claude-sonnet-4-6 is the recommended default for most production workloads: a good balance of capability and cost. Use claude-haiku-4-5-20251001 for very high-volume, latency-sensitive use where cost matters most. Check console.anthropic.com for the current model IDs, as retired models will return an error.
How is Claude different from OpenAI in the API request?
+
Three key differences: (1) auth uses x-api-key header instead of Authorization: Bearer, (2) max_tokens is required in the body, and (3) a system instruction goes in a separate top-level system field rather than inside the messages array. The response format is also different: the answer is in content[0].text, not choices[0].message.content.
Does using Claude cost anything on WA.Expert?
+
WA.Expert does not mark up Anthropic's charges. You pay Anthropic directly based on the tokens your requests and replies use. The WhatsApp reply itself is free if the customer is inside an active service window.
Related

Keep building

The External API Request step

Every field explained.

Read foundation guide →

Connect OpenAI

Bearer auth, messages array, different response path.

Read guide →

Connect Google Gemini

x-goog-api-key header, generateContent endpoint.

Read guide →

Connect hub

All connection guides.

Browse all →

WhatsApp API glossary

Header, bearer, endpoint, defined.

Open glossary →

WhatsApp chatbot builder

Build the flow that calls Claude.

Read guide →

Add Claude to your WhatsApp chatbot today.

Free trial, no credit card required. And if you ever get stuck, we are the only platform in India that answers you live on WhatsApp.

Start Free →Book Demo
1