AutomationAdvanced

How to Call the Claude API From Zapier Using Webhooks

Use a Webhooks by Zapier POST step to send a prompt to Anthropic's Messages API when there is no native action you need.

10 minAdvanced

When you need precise control over an AI request, or an option the prebuilt app does not expose, call the API directly with Webhooks by Zapier. This guide sends a prompt to Anthropic's Messages API and uses the reply in the rest of your Zap.

What you need

  • A Zapier plan that includes Webhooks by Zapier (Professional)
  • An Anthropic API key from console.anthropic.com
  • Any trigger that produces text to send
  • Comfort reading JSON

Step 1: Get your Anthropic API key

In the Anthropic Console, open API Keys and create a key. Copy it. The Messages API authenticates with this key in an x-api-key header and requires an anthropic-version header.

Step 2: Add a Webhooks POST action

Add an action, choose Webhooks by Zapier, and select Custom Request (it gives you full control of method, headers, and body). Set the method to POST and the URL to the Messages endpoint.

Webhooks - Custom Request
Method: POST
URL:    https://api.anthropic.com/v1/messages

Headers:
  x-api-key:         YOUR_ANTHROPIC_API_KEY
  anthropic-version: 2023-06-01
  content-type:      application/json

Step 3: Build the JSON body

In the Data or Body field, paste the JSON payload. Map your trigger text into the content string. Use a current model id and set max_tokens to cap the response length and cost.

Request body
{
  "model": "claude-sonnet-4-5",
  "max_tokens": 400,
  "messages": [
    {
      "role": "user",
      "content": "Summarize this in 3 bullet points:\n{{trigger text}}"
    }
  ]
}
Escape line breaks in JSON
JSON strings cannot contain raw newlines. Use the literal sequence backslash-n inside the content value, or build the prompt in a Formatter step first so Zapier inserts it cleanly.

Step 4: Read the response field

Test the step. Anthropic returns the model output inside content as an array of blocks. The text you want is at content 0 text. Map that field into the next action.

Webhooks - Response
Response (parsed):
id: msg_01ABC...
type: message
role: assistant
content:
0: { type: text,
text: '- Point one...\n- Point two...' }
stop_reason: end_turn
The text lives at content 0 text in the parsed response.
Handle errors gracefully
If the key is wrong or you hit a rate limit, the API returns a non-200 status with an error object. Add a Filter to stop the Zap when content 0 text is empty so downstream steps do not run on a failed call.

Result: A direct line from any Zapier trigger to Claude, returning text you can route anywhere, with full control over the model, token limit, and prompt structure.

Watch related tutorials

Tags
#zapier#claude#anthropic#webhooks#api