> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Start an agent run

Spawns a first-party containerized agent (e.g. the workflow-builder deep-agent) on the runtime worker. The org + user are taken from the authenticated request; the server mints the worker session.

` POST /v1/agent-runs `

Start an agent run

Spawns a first-party containerized agent (e.g. the workflow-builder
deep-agent) on the runtime worker. The org + user are taken from the
authenticated request; the server mints the worker session.

## Authentication

The operation accepts these alternatives. Schemes within one alternative are required together.

### Alternative 1

- ` BearerAuth `: ` apiKey `

  - Credential: ` Authorization ` in ` header `

  - JWT or API key, sent as: Bearer <token>

## Request body (required)

Content type: ` application/json `

Agent run request

- ` value `: type ` unknown `

  - ` oneOf alternative 1 `: type ` object `

  - ` oneOf alternative 2 `: type ` object `

    - Required fields: ` agentType `, ` prompt `

    - ` agentType `: type ` string ` — AgentType selects which registered first-party agent to run. Required — the caller picks one from GET /v1/agent-runs/agents (the worker's enabled-agent discovery list). There is no default: routing an empty type to a fixed agent risks dispatching to a disabled one (an opaque 403).

    - ` conversationId `: type ` string ` — Optional. Threads the run into an existing agent conversation; when empty the server generates a fresh conversation id (an independent thread).

    - ` parentProject `: type ` string ` — ParentProject is the Braintrust project the parent span lives in (span nesting is project-scoped). Only meaningful together with ParentSpan.

    - ` parentSpan `: type ` string ` — ParentSpan is an opaque Braintrust span slug (span.export()) of the calling conversation's current span. Passed through verbatim to the runtime worker so the deep-agent run's trace attaches under the parent Caddie chat's Braintrust trace. Optional; observability only — never affects run behavior.

    - ` payload `: type ` object ` — Payload is agent-type-specific input passed opaquely to the runtime (e.g. app-builder build params: workflowId, manifest, archetypeHint, parentBuildId, recentBuilds). workflow-builder ignores it.

    - ` prompt `: type ` string `

## Responses

### ` 200 ` — OK

Content type: ` application/json `

- ` value `: type ` object `

  - ` code `: type ` integer `

    - example: ` 200 `

  - ` data `: type ` object `

    - ` agentType `: type ` string `

    - ` conversationId `: type ` string `

    - ` runId `: type ` string `

  - ` message `: type ` string `

    - example: ` "success" `

  - ` requestId `: type ` string `

    - example: ` "abc-123" `

## Request examples

### cURL

```curl
curl -X POST 'https://api.example.com/v1/agent-runs' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{}'
```

### JavaScript

```javascript
const response = await fetch('https://api.example.com/v1/agent-runs', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json"
  },
  body: JSON.stringify({})
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.post('https://api.example.com/v1/agent-runs', headers=headers, json={})
print(response.json())
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	body := strings.NewReader(`{}`)
	req, _ := http.NewRequest("POST", "https://api.example.com/v1/agent-runs", body)
	req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
	req.Header.Set("Content-Type", "application/json")

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()
	result, _ := io.ReadAll(resp.Body)
	fmt.Println(string(result))
}
```