POST
POST /v1/sessions?beta=true — Claude API
Beta
Anthropic API key (required); https://api.anthropic.com
Claude APICreate Session
- Base URL
- https://api.anthropic.com
- Auth
- x-api-key: <ANTHROPIC_API_KEY>
- Last verified
- 2026-10-20 · upstream hash matched
Actions Try in browser→
Agents: curl -H "Accept: text/markdown" this URL
→ 377 tokens · Vary: Accept
→ 377 tokens · Vary: Accept
Critical gotchas
Authentication uses the x-api-key header and requests also require an anthropic-version header.
The official OpenAPI URL is discovered from the SDK repository manifest and must remain under Anthropic's trusted Stainless storage prefix.
cURL
curl -X POST 'https://api.anthropic.com/v1/sessions?beta=true' \ -H "x-api-key: $ANTHROPIC_API_KEY" \ -H 'anthropic-version: 2023-06-01' \ -H 'Content-Type: application/json' \ -d '{ "agent": "example-agent", "environment_id": "environment-id"}'
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| agent | body | string | Yes | Agent identifier. Accepts the `agent` ID string, which pins the latest version for the session, or an `agent` object with both id and version specified. |
| environment_id | body | string | Yes | ID of the `environment` defining the container configuration for this session. |
| title | body | string | No | Human-readable session title. |
| metadata | body | object | No | Arbitrary key-value metadata attached to the session. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars. |
| resources | body | object[] | No | Resources (e.g. repositories, files) to mount into the session's container. |
| vault_ids | body | string[] | No | Vault IDs for stored credentials the agent can use during the session. |
| initial_events | body | object[] | No | Initial events to send to the `session` at creation, processed in order. Supports `user.message` and `user.define_outcome` events. Maximum 50 events. |
| budget | body | object | No | Enforced spend ceiling for the session. Omit to create an uncapped session. Every model the session can run — the agent's model and each callable agent's model — must have a public list price, or the request is rejected with reason `model_not_budgetable`. |
Response 200 OK
{
"type": "session",
"id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
"status": "idle",
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z",
"archived_at": null,
"budget": null,
"environment_id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
"title": "Order #1234 inquiry",
"metadata": {},
"agent": {
"type": "agent",
"id": "agent_011CZkYpogX7uDKUyvBTophP",
"version": 1,
"name": "My First Agent",
"description": "A general-purpose starter agent.",
"model": {
"id": "claude-opus-5",
"speed": "standard"
},
"system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
"tools": [
{
"type": "agent_toolset_20260401",
"default_config": {
"enabled": true,
"permission_policy": {
"type": "always_ask"
}
},
"configs": []
}
],
"mcp_servers": [
{
"type": "url",
"name": "example-mcp",
"url": "https://example-server.modelcontextprotocol.io/sse"
}
],
"skills": [
{
"type": "anthropic",
"skill_id": "xlsx",
"version": "1"
},
{
"type": "custom",
"skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
"version": "2"
}
],
"multiagent": null
},
"resources": [
{
"type": "file",
"id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
"file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
"mount_path": "/uploads/receipt.pdf",
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
},
{
"type": "github_repository",
"id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
"url": "https://github.com/example-org/example-repo",
"mount_path": "/workspace/example-repo",
"checkout": {
"type": "branch",
"name": "main"
},
"created_at": "2026-03-15T10:00:00Z",
"updated_at": "2026-03-15T10:00:00Z"
}
],
"vault_ids": [
"vlt_011CZkZDLs7fYzm1hXNPeRjv"
],
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"cache_read_input_tokens": 0
},
"stats": {
"duration_seconds": 0,
"active_seconds": 0
},
"outcome_evaluations": [
{
"type": "outcome_evaluation",
"outcome_id": "outc_011CZkZRSw2kEfs6ncTVljxP",
"description": "Produce a 2-page summary as summary.md",
"result": "satisfied",
"iteration": 0,
"completed_at": "2026-03-15T10:02:31Z",
"explanation": "All five sections present with inline citations."
}
]
} Get a free Claude API key → sponsored Affiliate link - we may earn a commission, at no extra cost to you.