← Blog

Claude API Postman Collection Setup Guide

2026-10-07 · 5 min read · SubToAPI Team

Setting up Postman for the Claude API means configuring three things correctly: the base URL and headers, an environment for your API key, and request bodies that match Anthropic's message format. Postman doesn't ship an official Claude collection, so you build your own — but it only takes a few minutes once you know the exact headers and JSON shape Claude expects.

This guide walks through creating that setup from scratch: a Postman environment, a collection with the right headers pre-configured, a working request body, and how to handle streaming responses. It also covers an alternative worth knowing about if you want a simpler, OpenAI-style setup without the custom headers.

Step 1: Create a Postman Environment

Before building requests, set up an environment so your API key isn't hardcoded into every request. In Postman:

  1. Click Environments in the sidebar, then Create Environment.
  2. Name it something like Claude API — Dev.
  3. Add these variables:

| Variable | Initial Value | Type | |---|---|---| | base_url | https://api.anthropic.com | default | | api_key | your key (sk-ant-...) | secret | | api_version | 2023-06-01 | default |

Marking api_key as secret prevents it from being exposed if you ever export or share the collection.

Step 2: Create the Collection and Base Headers

Create a new collection called "Claude API" and set collection-level headers so every request inherits them automatically:

x-api-key: {{api_key}}
anthropic-version: {{api_version}}
content-type: application/json

Setting these at the collection level (Collection → Authorization/Headers tab) means you don't repeat them on every single request. This is the detail most people miss: Claude doesn't use a standard Authorization: Bearer header by convention in their docs — it uses x-api-key plus a required anthropic-version header. Forgetting either one is the most common cause of 401 and 400 errors in Postman.

Step 3: Build the Messages Request

Add a new POST request inside the collection:

{
  "model": "claude-sonnet-4-5",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Explain what a Postman collection is in two sentences."
    }
  ]
}

Send it. A successful response returns a content array with the assistant's reply, plus usage metadata showing input and output tokens. If you get a 400 error, check that max_tokens is present — it's required, not optional. If you get a 401, double-check the x-api-key header is actually being inherited from the collection and not overridden on the request itself.

Step 4: Add a System Prompt and Multi-Turn Example

To test conversation handling, duplicate the request and add a system field plus multiple messages:

{
  "model": "claude-sonnet-4-5",
  "max_tokens": 1024,
  "system": "You are a concise technical writer.",
  "messages": [
    { "role": "user", "content": "What's a REST API?" },
    { "role": "assistant", "content": "A REST API lets clients interact with a server using standard HTTP methods." },
    { "role": "user", "content": "Give one practical example." }
  ]
}

Save this as a separate request in your collection named "Multi-turn conversation" so you have a reference example for how message history is structured.

Step 5: Set Up Streaming (Optional)

Postman supports Server-Sent Events, but it requires enabling "stream": true in the body and reading the response as an event stream rather than a single JSON blob. Add a request with:

{
  "model": "claude-sonnet-4-5",
  "max_tokens": 1024,
  "stream": true,
  "messages": [
    { "role": "user", "content": "Write a haiku about APIs." }
  ]
}

In Postman's response view, switch to the EventStream tab to see tokens arrive incrementally rather than waiting for the full response. This is useful for testing latency and verifying your streaming parser works before wiring it into actual frontend code.

Step 6: Export and Share the Collection

Once your requests are working, export the collection (Collection → Export → Collection v2.1) so teammates can import it directly instead of rebuilding headers and bodies from scratch. Keep the environment file separate and never commit it to version control, since it contains your API key.

A Simpler Alternative: Standard Bearer Auth

If the custom x-api-key / anthropic-version header pair is more setup than you want — especially across a team sharing Postman collections — SubToAPI puts a standard HTTPS layer in front of your existing Claude access. You get application keys (sub_live_...) that work with a normal Authorization: Bearer $SUBTOAPI_KEY header, no version header required, which simplifies both the Postman setup and anything you build downstream.

A minimal request looks like this:

curl https://api.subtoapi.app/v1/messages \
  -H "Authorization: Bearer $SUBTOAPI_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Because the header pattern matches what most API clients (and most developers) already expect, importing this into Postman is a one-variable setup: just Authorization with your bearer token. It also adds usage metadata per key and team seat management if multiple people need access to the same underlying Claude account — see /pricing for plan details, or start with the /docs/quickstart guide. Streaming and tool use work the same way as the raw API; see /docs/streaming and /docs/tools for the request shapes.

Questions

Does Postman have an official Claude API collection? No. Anthropic doesn't publish one, so you build your own using the steps above, or import a community-shared collection if you trust its source and verify the headers match current API requirements.

Why do I get a 401 error even though my API key is correct in Postman? Usually because the x-api-key header isn't inherited correctly, it's overridden at the request level, or the anthropic-version header is missing — Claude's API rejects requests without a valid version header even if the key itself is valid.

Can I test streaming responses in Postman? Yes. Set "stream": true in the request body and view the response in Postman's EventStream tab instead of the default Body tab, which shows tokens arriving as Server-Sent Events rather than one JSON payload.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →