---
search:
  tags:
    - AI
    - POST
seo:
  description: >-
    Resolve an agent into a thread and start it via the same code path as…
    Reference for the POST /v1/ai/agents/{agent_id}/launch endpoint in the
    Roboto REST API.
sidebar:
  label: Launch agent
  badge: POST
title: Launch agent
type: openapi-operation
---
Resolve an agent into a thread and start it via the same code path as ``POST /threads``.

The thread's ``visibility`` comes from ``request.visibility`` (``ORG`` by
default, since agents exist to share work), and ``created_from_agent_id``
is stamped so the agent's detail page can list "threads launched from here".
The resulting thread is created in the agent's owning org — the caller's
own org context (if different) is not used.

Starting a thread takes ``chat:create`` on the org it starts in, as ``POST /threads`` declares on the request's
org. Here that org is the agent's, known only once the agent is loaded, so the handler asks. It asks before it
checks the datasets and devices that the request's values name, so a caller who may not start threads there
cannot use a launch to learn which of the org's datasets and devices exist.

Raises:
    RobotoNotFoundException: No agent has that id, or it is in an org the caller cannot work in.
    RobotoUnauthorizedException: The caller may not start AI threads in the agent's org.
    RobotoInvalidRequestException: A value names a dataset or device that is missing or in another org, or the
        values do not resolve the agent's template.

#### Access control
 - Restricted tokens cannot call this endpoint

`POST /v1/ai/agents/{agent_id}/launch`

**Request body** (`application/json`, required)

- `values` (object)
- `visibility` (ThreadVisibility) — Visibility of a thread: who can read it. Set when the thread is created. Only the thread's creator can change it, with :py:meth:\`\~roboto.ai.agent\_thread.AgentThread.set\_visibility\`. Roboto administrators can read every thread but cannot change the visibility of one they did not create. Import it from \`\`roboto.ai.agent\_thread\`\`.
- `analysis_scope` (AnalysisScope | null)

Request body example:

```json
{
  "values": {
    "property1": "string",
    "property2": "string"
  },
  "visibility": "org",
  "analysis_scope": null
}
```

**Responses**

- `200` — OK
- `400` — A conversation with Roboto's AI is longer than the AI model can read at once. The conversation's messages and tool results, together with the AI's instructions, exceed the model's context window. The exception does not carry the token count or the model's limit.
- `401` — The caller's token is expired or malformed.
- `403` — The request would take the user or organization past a limit on a resource, such as AI credits.
- `404` — The request names an API route Roboto does not serve.
- `409` — The request conflicts with an existing resource, such as by giving a name another resource already has.
- `410` — The resource the request names is missing or has expired.
- `500` — Roboto reported an error that this release of the SDK cannot match to a specific exception class. Reported for an element of a :py:class:\`\~roboto.http.BatchResponse\` whose error names a code this release defines no class for, or that arrived without a code, without a message, or as text that is not an error envelope at all. It carries whatever code and message Roboto sent, so a caller handling the failure still learns what went wrong; when no message could be read, the message is the error's raw text. :py:meth:\`\~roboto.domain.devices.Device.create\_session\` raises it, and :py:meth:\`\~roboto.domain.devices.Device.create\_sessions\` lists it in the batch's :py:attr:\`\~roboto.http.BatchResponse.failed\`. The error envelope carries no status code, so \`\`http\_status\_code\`\` reports the 500 inherited from \`\`RobotoDomainException\`\` rather than the status the failure had.
- `501` — The request asks for an operation this deployment of Roboto does not provide.
- `503` — Roboto could not accept the request, such as under heavy load. Retrying later may succeed.
- `504` — Roboto ran out of time while processing the request. Retrying may succeed.
- `507` — The response to the request is larger than Roboto can send. Retrying the same request fails the same way; request less data at a time.

Response example, 200:

```json
{
  "data": {
    "thread_id": "string",
    "created": "2019-08-24T14:15:22Z",
    "created_by": "string",
    "created_by_principal": null,
    "org_id": "string",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "text": "string"
          }
        ],
        "status": "not_started",
        "created": "2019-08-24T14:15:22Z",
        "created_by": null
      }
    ],
    "continuation_token": "string",
    "has_more": false,
    "status": "not_started",
    "activity": null,
    "title": null,
    "model_profile": null,
    "forked_from_thread_id": null,
    "forked_from_message_sequence_num": null,
    "visibility": "private",
    "created_from_agent_id": null,
    "created_from_trigger_id": null,
    "origin": null,
    "pinned_at": null,
    "goals": null,
    "tasks": null,
    "client_tool_executor_tab_id": null,
    "turn_notice": null
  }
}
```
