---
title: Start a conversation (thread) in a run
description: "Creates a thread — one provider conversation (claude-code / codex) and mode (ask / edit) — inside a run."
api_method: POST
api_path: "/v1/agent-runs/{runId}/threads"
canonical_url: https://wiblo.app/docs/developers/api/agent-threads/create-agent-thread
last_updated: 2026-07-28T17:31:44+02:00
md_url: https://wiblo.app/docs/developers/api/agent-threads/create-agent-thread.md
---

# Start a conversation (thread) in a run

`POST /v1/agent-runs/{runId}/threads`

Creates a thread — one provider conversation (`claude-code` / `codex`) and `mode` (`ask` / `edit`) — inside a run. Many threads share one sandbox. Cross-tenant probes and unknown ids collapse onto the same 404 `AGENT_RUN_NOT_FOUND` envelope. Per-user rate-limited at 30/60s.

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `runId` | `string` | Yes |  |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `provider` | `"claude-code" \| "codex"` | Yes |  |
| `model` | `string \| null` | No | Defaults to `null`. |
| `mode` | `"ask" \| "edit"` | No |  |
| `title` | `string \| null` | No | Defaults to `null`. |

## Request

**curl**

```bash
curl https://api.wiblo.app/v1/agent-runs/{runId}/threads \
  -X POST \
  -H "Authorization: Bearer $WIBLO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "provider": "claude-code"
}'
```

**TypeScript**

```ts
import { createSdk, createAgentThread } from "@workspace/sdk"

const sdk = createSdk({ baseUrl: "https://api.wiblo.app" })

const { data, error } = await createAgentThread({
  client: sdk,
  path: { runId: "..." },
  body: {
    "provider": "claude-code"
  },
})
```

## Responses

**`201`** — The thread was created. Returns `ThreadResponse`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `thread` | `AgentThread` | Yes |  |

**`400`** — Request body failed Zod validation (`VALIDATION_FAILED`). Returns `ApiErrorEnvelope`.

**`401`** — No valid session cookie or `wbl_*` bearer was present. Returns `ApiErrorEnvelope`.

**`404`** — No run visible to the caller with this id (`AGENT_RUN_NOT_FOUND`). Returns `ApiErrorEnvelope`.

**`422`** — Path param failed UUID validation (`INVALID_PARAMS`). Returns `ApiErrorEnvelope`.

**`429`** — Rate limit exceeded. The body's `error.code` is `RATE_LIMITED` and `error.details.retry_after` is the same number of seconds as the `Retry-After` header. Returns `ApiErrorEnvelope`.

### The AgentThread object

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes |  |
| `runId` | `string` | Yes |  |
| `workspaceId` | `string` | Yes |  |
| `provider` | `"claude-code" \| "codex"` | Yes |  |
| `model` | `string \| null` | Yes |  |
| `mode` | `"ask" \| "edit"` | Yes |  |
| `title` | `string \| null` | Yes |  |
| `status` | `"active" \| "idle" \| "aborted" \| "error"` | Yes |  |
| `providerSessionId` | `string \| null` | Yes |  |
| `createdAt` | `string` | Yes |  |
| `updatedAt` | `string` | Yes |  |
