---
ref: tool:anthropic/create-message
name: Create a message
company: company:anthropic
workflows: [workflow:funding-signal-outbound, workflow:executive-job-change, workflow:champion-job-change-loop, workflow:resend-to-unopened]
access: [cli, api]
tags: [capability:write-copy, category:ai-model, has:api, has:cli]
docs: https://platform.claude.com/docs/en/api/messages/create
updated: 2026-09-27
---

# Create a message

Returns Claude's next message for a prompt or conversation, such as a drafted email or a label for a record.

Send `anthropic-version: 2023-06-01` and `content-type: application/json`
with the key. The body needs `model`, `max_tokens` and `messages`; a `system`
prompt is optional. On the CLI, `claude -p "<prompt>"` prints the response
without starting an interactive session.

## Set up

Use the first option your agent supports.

### CLI (official)

Install the command, then confirm it runs.

```sh
curl -fsSL https://claude.ai/install.sh | bash
claude --version
```

Run `claude -p`.

### API (official)

- Base URL: https://api.anthropic.com
- Endpoint: `POST /v1/messages`
- Auth: send the header `x-api-key: $ANTHROPIC_API_KEY`
- Get a key: https://platform.claude.com/settings/keys
- Docs: https://platform.claude.com/docs/en/api/overview

Before doing anything else, make one read-only call to confirm access.

## Rules

- Ask the user before anything that sends messages, costs money, or changes data.
- Never print API keys.
