Prerequisites

Before you begin, make sure you have:
Never hardcode your API key in any file you commit to version control. Store it as an environment variable and reference it from there.

Your First API Call

You will send a message to Claude and receive a response. This is the foundation of every interaction with the Claude API.

Using Postman

Set up your request with the following: Method: POST URL: https://api.anthropic.com/v1/messages Headers: Body:
Click Send.

Using curl

Understanding the Response

A successful request returns a 200 OK with a response body like this:
Here is what each field means:

Stop Reasons

The stop_reason field tells you why Claude stopped generating. Always check this field — a 200 OK does not guarantee a complete response.
A 200 OK response with stop_reason: "max_tokens" and an empty content array means your max_tokens value is too low. Claude accepted the request but had no room to generate a response. Always set max_tokens to a reasonable value for your use case.

Required Request Fields

Every request to /v1/messages requires these three fields:

Available Models

Next Steps

Core Concepts

Understand how the messages array works and how context is managed

System Prompts

Learn how to shape Claude’s behavior for your use case

Streaming

Stream responses in real time for a better user experience

Tool Use

Connect Claude to real-time data and external services