---
title: "Start an agent session"
method: POST
path: "/api/agent/sessions"
tags: ["Agent"]
---

# Start an agent session

`POST /api/agent/sessions`

## Request

- Base URL: `http://localhost:38200`
- URL: `http://localhost:38200/api/agent/sessions`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `token`

## Request body

- object
  - `agent` string, required
  - `agent_name` string
  - `goal` string
  - `workspace` string
  - `project` string
  - `role` string
  - `parent_session_id` integer: Chains a resume session to the run it continues.
  - `metadata` object

## Response `201`

Created session.

- AgentSession: The `agent_sessions` row (src/db/schema.ts), as returned by boot/session endpoints.
  - `id` integer
  - `tenantId` integer
  - `agentId` integer
  - `workspaceId` integer, nullable
  - `projectId` integer, nullable
  - `goal` string, nullable
  - `role` string, nullable: Inferred at boot from the matched goal node's owner_role.
  - `status` 'active' | 'paused' | 'completed' | 'stalled' | 'abandoned'
  - `parentSessionId` integer, nullable
  - `lastCheckpointId` integer, nullable
  - `handoffContextId` integer, nullable
  - `metadata` object
  - `startedAt` string, date-time
  - `endedAt` string, date-time, nullable

## Other responses

- `400`: Request body/query failed Zod validation.
- `401`: Missing or invalid credentials.

---

[API](https://skmtc.dev/contextq/apis/contextq-api.md) · [All operations](https://skmtc.dev/contextq/apis/contextq-api/llms.txt) · [OpenAPI document](https://skmtc.dev/contextq/apis/contextq-api/revisions/7afc44056a22?raw)
