# Droid Sessions API

Create and drive Droid sessions and workstreams, and manage settings and messages.

## List sessions

`GET /api/v0/sessions`

Returns a paginated list of sessions for the authenticated user. With `computerId`, sessions are listed from that computer, whose session list records no run state, so every row reports `status` `idle`; read a session with `GET /api/v0/sessions/{sessionId}?computerId=` for whether it is running. Rows listed from a computer omit `factoryCredits`; without `computerId`, `factoryCredits` appears on sessions that have reported usage, and is omitted from every row when the organization hides billable usage. Without `computerId`, `updatedAfter` and `updatedBefore` select sessions by their current last update time, at or after `updatedAfter` and before `updatedBefore`; they do not return a history of changes, and they are rejected with `computerId`. Send the same window with every cursor. A page can be short or empty while `hasMore` is true, so follow `nextCursor` until `hasMore` is false. A session updated while you page is listed at its new update time, so it can appear again or leave the window, and a cursor that names none of your sessions starts the list again; deduplicate rows by `sessionId`. For periodic polls, set an explicit `updatedBefore` and overlap consecutive windows to reduce missed updates. `excludeSubagents=true` omits sessions with a public `parent_session_id`; see the parameter for which sessions remain listed. This feature is enabled for selected organizations only.

```bash
curl 'https://api.factory.ai/api/v0/sessions' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `limit` (`integer`) - Query parameter. Maximum number of items to return (1-100) Default: 20.
- `cursor` (`string`) - Query parameter. Cursor for pagination
- `computerId` (`string`) - Query parameter. Computer ID to query directly
- `sessionIds` (`string`) - Query parameter. Comma-separated set of 1–100 session UUIDs, counted before deduplication. Unknown or inaccessible IDs are omitted. Returns only normally listable matches in last-update order, not input order. Use limit=100 for up to 100 matches; repeat the same IDs with each cursor and time window. Older storage that cannot apply this filter returns 503, never an unfiltered list. Not supported with a nonempty computerId or on the workstreams list. Minimum length: 1. Maximum length: 3699.
- `excludeSubagents` (`boolean`) - Query parameter. `excludeSubagents=true` omits sessions with a public `parent_session_id`. Mission and legacy child sessions without that public parent remain listed. Filtering can produce short or empty pages with `hasMore=true`; continue using `nextCursor`. A fork of a child session inherits that child's parent lineage, so it is omitted when the child is. When supplied, `excludeSubagents` cannot be combined with `sessionIds` or a non-empty `computerId`, even when it is `false`.
- `updatedAfter` (`string`) - Query parameter. List only sessions whose last update time (Unix ms) is at or after this time Pattern: ^(0|[1-9]\d{0,15})$.
- `updatedBefore` (`string`) - Query parameter. List only sessions whose last update time (Unix ms) is before this time; at least 1 and later than updatedAfter Pattern: ^(0|[1-9]\d{0,15})$.
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "sessions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "description": "Session ID"
          },
          "parent_session_id": {
            "type": "string",
            "description": "Immediate parent session ID for a Task subagent, if one exists"
          },
          "title": {
            "type": "string",
            "description": "Session title"
          },
          "status": {
            "type": "string",
            "enum": [
              "idle",
              "pending",
              "running"
            ],
            "description": "Current session execution status"
          },
          "messageCount": {
            "type": "integer",
            "description": "Number of messages in session"
          },
          "createdAt": {
            "type": "integer",
            "description": "Creation timestamp (Unix ms). Read from a computer with computerId, a single session reports its earliest message's creation time (the request time when it has no messages), and a list reports when the session file was created (its last update time when the computer did not record that)"
          },
          "updatedAt": {
            "type": "integer",
            "description": "Last update timestamp (Unix ms). Read from a computer with computerId, a single session reports its latest message's update time (the request time when it has no messages)"
          },
          "completedAt": {
            "type": "integer",
            "description": "Completion timestamp (Unix ms)"
          },
          "computerId": {
            "type": "string",
            "description": "The computer the session runs on: your computer on the session's host, otherwise the computer the session records. Absent when its host has none of your computers and it records none. Read from a computer with computerId, that computer"
          },
          "sessionSettings": {
            "type": "object",
            "properties": {
              "model": {
                "type": "string"
              },
              "reasoningEffort": {
                "type": "string",
                "enum": [
                  "none",
                  "dynamic",
                  "off",
                  "minimal",
                  "low",
                  "medium",
                  "high",
                  "xhigh",
                  "max"
                ]
              },
              "interactionMode": {
                "type": "string",
                "enum": [
                  "auto",
                  "spec",
                  "agi",
                  "mission"
                ]
              },
              "autonomyLevel": {
                "type": "string",
                "enum": [
                  "off",
                  "low",
                  "medium",
                  "high"
                ]
              },
              "autonomyMode": {
                "type": "string",
                "enum": [
                  "normal",
                  "spec",
                  "auto-low",
                  "auto-medium",
                  "auto-high"
                ],
                "description": "Deprecated: use interactionMode + autonomyLevel instead."
              },
              "specModeModel": {
                "type": "string"
              },
              "specModeReasoningEffort": {
                "type": "string",
                "enum": [
                  "none",
                  "dynamic",
                  "off",
                  "minimal",
                  "low",
                  "medium",
                  "high",
                  "xhigh",
                  "max"
                ]
              },
              "providerLock": {
                "type": "string",
                "enum": [
                  "anthropic",
                  "openai",
                  "generic-chat-completion-api",
                  "factory",
                  "google",
                  "xai",
                  "bedrock-converse"
                ]
              },
              "providerLockTimestamp": {
                "type": "string"
              },
              "apiProviderLock": {
                "type": "string",
                "enum": [
                  "bedrock",
                  "anthropic",
                  "vertex_anthropic",
                  "bedrock_anthropic",
                  "bedrock_converse",
                  "bedrock_openai",
                  "openai",
                  "azure_openai",
                  "azure_anthropic",
                  "google",
                  "xai",
                  "mistral",
                  "fireworks",
                  "baseten",
                  "together",
                  "snowflake",
                  "databricks"
                ]
              },
              "archivedAt": {
                "type": "string"
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "minLength": 1
                    },
                    "metadata": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "name"
                  ]
                }
              },
              "worktree": {
                "type": "object",
                "properties": {
                  "branch": {
                    "type": "string"
                  },
                  "lifecycle": {
                    "type": "string",
                    "enum": [
                      "ephemeral",
                      "persistent"
                    ]
                  },
                  "path": {
                    "type": "string"
                  },
                  "parentWorktreePath": {
                    "type": "string"
                  },
                  "removedAt": {
                    "type": "string"
                  },
                  "repoRoot": {
                    "type": "string"
                  },
                  "setupProfileId": {
                    "type": "string"
                  }
                },
                "required": [
                  "repoRoot"
                ]
              },
              "enabledToolIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "disabledToolIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "restrictToolIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "toolExecutionMode": {
                "type": "string",
                "enum": [
                  "direct_only",
                  "script_only"
                ]
              },
              "allowSubagentsInScripts": {
                "type": "boolean"
              },
              "compactionModel": {
                "type": "string"
              },
              "compactionThresholdCheckEnabled": {
                "type": "boolean"
              }
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "metadata": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "name"
              ]
            },
            "description": "Session tags. A workstream carries a mission-v2 tag whose metadata has kind \"orchestrator\" and a missionId equal to its own sessionId; spaceId appears once its shared folder is attached"
          },
          "artifacts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "externalId": {
                  "type": "string"
                },
                "provider": {
                  "type": "string",
                  "enum": [
                    "github",
                    "gitlab",
                    "linear",
                    "jira",
                    "notion",
                    "web",
                    "local",
                    "connector"
                  ]
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "pull_request",
                    "issue",
                    "document",
                    "record",
                    "file",
                    "link"
                  ]
                },
                "connector": {
                  "type": "string"
                },
                "fileRole": {
                  "type": "string",
                  "enum": [
                    "spec"
                  ]
                },
                "action": {
                  "type": "string",
                  "enum": [
                    "create",
                    "update",
                    "delete",
                    "view",
                    "close",
                    "merge"
                  ],
                  "default": "create"
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "tool",
                    "classifier",
                    "user_message"
                  ]
                },
                "createdAt": {
                  "type": "string"
                },
                "toolCallId": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "url",
                "provider",
                "kind",
                "source",
                "createdAt"
              ]
            },
            "description": "Integration artifacts (pull requests, issues, pages) the session touched, oldest first"
          },
          "factoryCredits": {
            "type": "number",
            "description": "Total Factory credits consumed by the session and its subagents"
          }
        },
        "required": [
          "sessionId",
          "status",
          "messageCount",
          "createdAt",
          "updatedAt"
        ]
      }
    },
    "pagination": {
      "type": "object",
      "properties": {
        "hasMore": {
          "type": "boolean",
          "description": "Whether there are more items after this page"
        },
        "nextCursor": {
          "type": "string",
          "nullable": true,
          "description": "Cursor to use for the next page, null if no more pages"
        }
      },
      "required": [
        "hasMore",
        "nextCursor"
      ]
    }
  },
  "required": [
    "sessions",
    "pagination"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `424` - Response for status 424

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Create a session

`POST /api/v0/sessions`

Creates a new session with the specified configuration. This feature is enabled for selected organizations only.

```bash
curl -X POST 'https://api.factory.ai/api/v0/sessions' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
```

**Parameters**

- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Request body** (required)

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "computerId": {
      "type": "string",
      "description": "Computer ID to connect"
    },
    "cwd": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4096,
      "description": "Working directory for the session on the computer."
    },
    "sessionSettings": {
      "type": "object",
      "properties": {
        "model": {
          "type": "string"
        },
        "reasoningEffort": {
          "type": "string",
          "enum": [
            "none",
            "dynamic",
            "off",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh",
            "max"
          ]
        },
        "interactionMode": {
          "type": "string",
          "enum": [
            "auto",
            "spec",
            "agi",
            "mission"
          ]
        },
        "autonomyLevel": {
          "type": "string",
          "enum": [
            "off",
            "low",
            "medium",
            "high"
          ]
        },
        "autonomyMode": {
          "type": "string",
          "enum": [
            "normal",
            "spec",
            "auto-low",
            "auto-medium",
            "auto-high"
          ],
          "description": "Deprecated: use interactionMode + autonomyLevel instead."
        },
        "specModeModel": {
          "type": "string"
        },
        "specModeReasoningEffort": {
          "type": "string",
          "enum": [
            "none",
            "dynamic",
            "off",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh",
            "max"
          ]
        },
        "providerLock": {
          "type": "string",
          "enum": [
            "anthropic",
            "openai",
            "generic-chat-completion-api",
            "factory",
            "google",
            "xai",
            "bedrock-converse"
          ]
        },
        "providerLockTimestamp": {
          "type": "string"
        },
        "apiProviderLock": {
          "type": "string",
          "enum": [
            "bedrock",
            "anthropic",
            "vertex_anthropic",
            "bedrock_anthropic",
            "bedrock_converse",
            "bedrock_openai",
            "openai",
            "azure_openai",
            "azure_anthropic",
            "google",
            "xai",
            "mistral",
            "fireworks",
            "baseten",
            "together",
            "snowflake",
            "databricks"
          ]
        },
        "archivedAt": {
          "type": "string"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1
              },
              "metadata": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              }
            },
            "required": [
              "name"
            ],
            "additionalProperties": false
          }
        },
        "worktree": {
          "type": "object",
          "properties": {
            "branch": {
              "type": "string"
            },
            "lifecycle": {
              "type": "string",
              "enum": [
                "ephemeral",
                "persistent"
              ]
            },
            "path": {
              "type": "string"
            },
            "parentWorktreePath": {
              "type": "string"
            },
            "removedAt": {
              "type": "string"
            },
            "repoRoot": {
              "type": "string"
            },
            "setupProfileId": {
              "type": "string"
            }
          },
          "required": [
            "repoRoot"
          ],
          "additionalProperties": false
        },
        "enabledToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "disabledToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "restrictToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "toolExecutionMode": {
          "type": "string",
          "enum": [
            "direct_only",
            "script_only"
          ]
        },
        "allowSubagentsInScripts": {
          "type": "boolean"
        },
        "systemPrompt": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "\\S"
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "preset"
                  ]
                },
                "preset": {
                  "type": "string",
                  "enum": [
                    "droid"
                  ]
                },
                "append": {
                  "type": "string",
                  "pattern": "\\S"
                }
              },
              "required": [
                "type",
                "preset",
                "append"
              ],
              "additionalProperties": false
            }
          ]
        },
        "compactionModel": {
          "type": "string"
        },
        "compactionThresholdCheckEnabled": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "blockOnStartupLoad": {
      "type": "boolean",
      "description": "Wait up to 5 more seconds before responding so the session can be read back from the API, and make each turn wait for MCP servers and connectors to load before it starts. The session is created either way: if its record is not stored within that time, or cannot be stored, reading it returns 404 until it is."
    }
  },
  "required": [
    "computerId"
  ],
  "additionalProperties": false
}
```

**Response:** `201` - Response for status 201

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "sessionId": {
      "type": "string",
      "description": "Session ID"
    },
    "parent_session_id": {
      "type": "string",
      "description": "Immediate parent session ID for a Task subagent, if one exists"
    },
    "title": {
      "type": "string",
      "description": "Session title"
    },
    "status": {
      "type": "string",
      "enum": [
        "idle",
        "pending",
        "running"
      ],
      "description": "Current session execution status"
    },
    "messageCount": {
      "type": "integer",
      "description": "Number of messages in session"
    },
    "createdAt": {
      "type": "integer",
      "description": "Creation timestamp (Unix ms). Read from a computer with computerId, a single session reports its earliest message's creation time (the request time when it has no messages), and a list reports when the session file was created (its last update time when the computer did not record that)"
    },
    "updatedAt": {
      "type": "integer",
      "description": "Last update timestamp (Unix ms). Read from a computer with computerId, a single session reports its latest message's update time (the request time when it has no messages)"
    },
    "completedAt": {
      "type": "integer",
      "description": "Completion timestamp (Unix ms)"
    },
    "computerId": {
      "type": "string",
      "description": "The computer the session runs on: your computer on the session's host, otherwise the computer the session records. Absent when its host has none of your computers and it records none. Read from a computer with computerId, that computer"
    },
    "sessionSettings": {
      "type": "object",
      "properties": {
        "model": {
          "type": "string"
        },
        "reasoningEffort": {
          "type": "string",
          "enum": [
            "none",
            "dynamic",
            "off",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh",
            "max"
          ]
        },
        "interactionMode": {
          "type": "string",
          "enum": [
            "auto",
            "spec",
            "agi",
            "mission"
          ]
        },
        "autonomyLevel": {
          "type": "string",
          "enum": [
            "off",
            "low",
            "medium",
            "high"
          ]
        },
        "autonomyMode": {
          "type": "string",
          "enum": [
            "normal",
            "spec",
            "auto-low",
            "auto-medium",
            "auto-high"
          ],
          "description": "Deprecated: use interactionMode + autonomyLevel instead."
        },
        "specModeModel": {
          "type": "string"
        },
        "specModeReasoningEffort": {
          "type": "string",
          "enum": [
            "none",
            "dynamic",
            "off",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh",
            "max"
          ]
        },
        "providerLock": {
          "type": "string",
          "enum": [
            "anthropic",
            "openai",
            "generic-chat-completion-api",
            "factory",
            "google",
            "xai",
            "bedrock-converse"
          ]
        },
        "providerLockTimestamp": {
          "type": "string"
        },
        "apiProviderLock": {
          "type": "string",
          "enum": [
            "bedrock",
            "anthropic",
            "vertex_anthropic",
            "bedrock_anthropic",
            "bedrock_converse",
            "bedrock_openai",
            "openai",
            "azure_openai",
            "azure_anthropic",
            "google",
            "xai",
            "mistral",
            "fireworks",
            "baseten",
            "together",
            "snowflake",
            "databricks"
          ]
        },
        "archivedAt": {
          "type": "string"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1
              },
              "metadata": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              }
            },
            "required": [
              "name"
            ]
          }
        },
        "worktree": {
          "type": "object",
          "properties": {
            "branch": {
              "type": "string"
            },
            "lifecycle": {
              "type": "string",
              "enum": [
                "ephemeral",
                "persistent"
              ]
            },
            "path": {
              "type": "string"
            },
            "parentWorktreePath": {
              "type": "string"
            },
            "removedAt": {
              "type": "string"
            },
            "repoRoot": {
              "type": "string"
            },
            "setupProfileId": {
              "type": "string"
            }
          },
          "required": [
            "repoRoot"
          ]
        },
        "enabledToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "disabledToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "restrictToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "toolExecutionMode": {
          "type": "string",
          "enum": [
            "direct_only",
            "script_only"
          ]
        },
        "allowSubagentsInScripts": {
          "type": "boolean"
        },
        "compactionModel": {
          "type": "string"
        },
        "compactionThresholdCheckEnabled": {
          "type": "boolean"
        }
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "required": [
          "name"
        ]
      },
      "description": "Session tags. A workstream carries a mission-v2 tag whose metadata has kind \"orchestrator\" and a missionId equal to its own sessionId; spaceId appears once its shared folder is attached"
    },
    "artifacts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "externalId": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "github",
              "gitlab",
              "linear",
              "jira",
              "notion",
              "web",
              "local",
              "connector"
            ]
          },
          "kind": {
            "type": "string",
            "enum": [
              "pull_request",
              "issue",
              "document",
              "record",
              "file",
              "link"
            ]
          },
          "connector": {
            "type": "string"
          },
          "fileRole": {
            "type": "string",
            "enum": [
              "spec"
            ]
          },
          "action": {
            "type": "string",
            "enum": [
              "create",
              "update",
              "delete",
              "view",
              "close",
              "merge"
            ],
            "default": "create"
          },
          "source": {
            "type": "string",
            "enum": [
              "tool",
              "classifier",
              "user_message"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "toolCallId": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "url",
          "provider",
          "kind",
          "source",
          "createdAt"
        ]
      },
      "description": "Integration artifacts (pull requests, issues, pages) the session touched, oldest first"
    },
    "factoryCredits": {
      "type": "number",
      "description": "Total Factory credits consumed by the session and its subagents"
    }
  },
  "required": [
    "sessionId",
    "status",
    "messageCount",
    "createdAt",
    "updatedAt"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `413` - Response for status 413

Content type: `application/json`

```json
{
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "description": "The platform edge refused a body over its own size limit before the route ran, and answered in JSON because the request accepts JSON, for example `{\"error\":{\"code\":\"413\",\"message\":\"Request Entity Too Large\"}}`.",
      "required": [
        "error"
      ],
      "properties": {
        "error": {
          "type": "object",
          "required": [
            "code",
            "message"
          ],
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            }
          }
        }
      },
      "not": {
        "required": [
          "detail"
        ]
      }
    }
  ]
}
```

Content type: `text/plain`

```json
{
  "type": "string",
  "description": "The platform edge refused a body over its own size limit before the route ran, for example `Request Entity Too Large` followed by an error code such as `FUNCTION_PAYLOAD_TOO_LARGE`."
}
```

**Response:** `415` - Response for status 415

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Request validation error"
    },
    "errors": {
      "type": "array",
      "items": {},
      "description": "Framework validation issues, when available"
    }
  },
  "required": [
    "message"
  ]
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `504` - Response for status 504

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## List workstreams

`GET /api/v0/sessions/workstreams`

Returns a paginated list of the workstreams you started, most recently updated first, with the same session fields as `GET /api/v0/sessions`. The `sessionIds` filter is not supported on this endpoint. Agents a workstream starts are not listed; each workstream carries its mission-v2 tag. Workstreams must be available to your organization; otherwise the request fails with 403.

```bash
curl 'https://api.factory.ai/api/v0/sessions/workstreams' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `limit` (`integer`) - Query parameter. Maximum number of items to return (1-100) Default: 20.
- `cursor` (`string`) - Query parameter. The nextCursor of the previous page. Workstreams are ordered by last update, so one updated while you page can move to an earlier page. A cursor that names none of your sessions starts the list again from the most recently updated workstream.
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "sessions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "description": "Session ID"
          },
          "parent_session_id": {
            "type": "string",
            "description": "Immediate parent session ID for a Task subagent, if one exists"
          },
          "title": {
            "type": "string",
            "description": "Session title"
          },
          "status": {
            "type": "string",
            "enum": [
              "idle",
              "pending",
              "running"
            ],
            "description": "Current session execution status"
          },
          "messageCount": {
            "type": "integer",
            "description": "Number of messages in session"
          },
          "createdAt": {
            "type": "integer",
            "description": "Creation timestamp (Unix ms). Read from a computer with computerId, a single session reports its earliest message's creation time (the request time when it has no messages), and a list reports when the session file was created (its last update time when the computer did not record that)"
          },
          "updatedAt": {
            "type": "integer",
            "description": "Last update timestamp (Unix ms). Read from a computer with computerId, a single session reports its latest message's update time (the request time when it has no messages)"
          },
          "completedAt": {
            "type": "integer",
            "description": "Completion timestamp (Unix ms)"
          },
          "computerId": {
            "type": "string",
            "description": "The computer the session runs on: your computer on the session's host, otherwise the computer the session records. Absent when its host has none of your computers and it records none. Read from a computer with computerId, that computer"
          },
          "sessionSettings": {
            "type": "object",
            "properties": {
              "model": {
                "type": "string"
              },
              "reasoningEffort": {
                "type": "string",
                "enum": [
                  "none",
                  "dynamic",
                  "off",
                  "minimal",
                  "low",
                  "medium",
                  "high",
                  "xhigh",
                  "max"
                ]
              },
              "interactionMode": {
                "type": "string",
                "enum": [
                  "auto",
                  "spec",
                  "agi",
                  "mission"
                ]
              },
              "autonomyLevel": {
                "type": "string",
                "enum": [
                  "off",
                  "low",
                  "medium",
                  "high"
                ]
              },
              "autonomyMode": {
                "type": "string",
                "enum": [
                  "normal",
                  "spec",
                  "auto-low",
                  "auto-medium",
                  "auto-high"
                ],
                "description": "Deprecated: use interactionMode + autonomyLevel instead."
              },
              "specModeModel": {
                "type": "string"
              },
              "specModeReasoningEffort": {
                "type": "string",
                "enum": [
                  "none",
                  "dynamic",
                  "off",
                  "minimal",
                  "low",
                  "medium",
                  "high",
                  "xhigh",
                  "max"
                ]
              },
              "providerLock": {
                "type": "string",
                "enum": [
                  "anthropic",
                  "openai",
                  "generic-chat-completion-api",
                  "factory",
                  "google",
                  "xai",
                  "bedrock-converse"
                ]
              },
              "providerLockTimestamp": {
                "type": "string"
              },
              "apiProviderLock": {
                "type": "string",
                "enum": [
                  "bedrock",
                  "anthropic",
                  "vertex_anthropic",
                  "bedrock_anthropic",
                  "bedrock_converse",
                  "bedrock_openai",
                  "openai",
                  "azure_openai",
                  "azure_anthropic",
                  "google",
                  "xai",
                  "mistral",
                  "fireworks",
                  "baseten",
                  "together",
                  "snowflake",
                  "databricks"
                ]
              },
              "archivedAt": {
                "type": "string"
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "minLength": 1
                    },
                    "metadata": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "name"
                  ]
                }
              },
              "worktree": {
                "type": "object",
                "properties": {
                  "branch": {
                    "type": "string"
                  },
                  "lifecycle": {
                    "type": "string",
                    "enum": [
                      "ephemeral",
                      "persistent"
                    ]
                  },
                  "path": {
                    "type": "string"
                  },
                  "parentWorktreePath": {
                    "type": "string"
                  },
                  "removedAt": {
                    "type": "string"
                  },
                  "repoRoot": {
                    "type": "string"
                  },
                  "setupProfileId": {
                    "type": "string"
                  }
                },
                "required": [
                  "repoRoot"
                ]
              },
              "enabledToolIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "disabledToolIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "restrictToolIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "toolExecutionMode": {
                "type": "string",
                "enum": [
                  "direct_only",
                  "script_only"
                ]
              },
              "allowSubagentsInScripts": {
                "type": "boolean"
              },
              "compactionModel": {
                "type": "string"
              },
              "compactionThresholdCheckEnabled": {
                "type": "boolean"
              }
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "metadata": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "name"
              ]
            },
            "description": "Session tags. A workstream carries a mission-v2 tag whose metadata has kind \"orchestrator\" and a missionId equal to its own sessionId; spaceId appears once its shared folder is attached"
          },
          "artifacts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "externalId": {
                  "type": "string"
                },
                "provider": {
                  "type": "string",
                  "enum": [
                    "github",
                    "gitlab",
                    "linear",
                    "jira",
                    "notion",
                    "web",
                    "local",
                    "connector"
                  ]
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "pull_request",
                    "issue",
                    "document",
                    "record",
                    "file",
                    "link"
                  ]
                },
                "connector": {
                  "type": "string"
                },
                "fileRole": {
                  "type": "string",
                  "enum": [
                    "spec"
                  ]
                },
                "action": {
                  "type": "string",
                  "enum": [
                    "create",
                    "update",
                    "delete",
                    "view",
                    "close",
                    "merge"
                  ],
                  "default": "create"
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "tool",
                    "classifier",
                    "user_message"
                  ]
                },
                "createdAt": {
                  "type": "string"
                },
                "toolCallId": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "url",
                "provider",
                "kind",
                "source",
                "createdAt"
              ]
            },
            "description": "Integration artifacts (pull requests, issues, pages) the session touched, oldest first"
          },
          "factoryCredits": {
            "type": "number",
            "description": "Total Factory credits consumed by the session and its subagents"
          }
        },
        "required": [
          "sessionId",
          "status",
          "messageCount",
          "createdAt",
          "updatedAt"
        ]
      }
    },
    "pagination": {
      "type": "object",
      "properties": {
        "hasMore": {
          "type": "boolean",
          "description": "Whether there are more items after this page"
        },
        "nextCursor": {
          "type": "string",
          "nullable": true,
          "description": "Cursor to use for the next page, null if no more pages"
        }
      },
      "required": [
        "hasMore",
        "nextCursor"
      ]
    }
  },
  "required": [
    "sessions",
    "pagination"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Start a workstream

`POST /api/v0/sessions/workstreams`

Starts a workstream: an orchestrator session that works through the brief, can start agents, and shares a folder with them. The orchestrator runs at High autonomy, so it runs commands without asking for approval, and the agents it starts run at its level. If an admin has set a lower maximum autonomy level for your organization, the orchestrator and its agents run at that maximum, and a command that needs more autonomy does not run until someone approves it. Target an `environment` to provision a fresh computer from its active build, or a `computer` you own. Returns once the brief is delivered, after waiting up to 5 more seconds so the session can be read back from the API; if its record is not stored within that time, or cannot be stored, reading it returns 404 until it is. The orchestrator keeps working afterwards, so read `GET /api/v0/sessions/{sessionId}` and `GET /api/v0/sessions/{sessionId}/messages` to follow it. A request whose connection drops before the response arrives can still have started the workstream, so list workstreams with `GET /api/v0/sessions/workstreams` before you retry. Workstreams must be available to your organization, and when an administrator limits them to selected members you must be one of them; otherwise the request fails with 403. A computer whose Droid is too old to run workstreams fails with 424 before anything starts. A computer provisioned from an environment is deleted when the workstream cannot start; otherwise it stays with the workstream until you delete it or it is removed after a long period of inactivity.

```bash
curl -X POST 'https://api.factory.ai/api/v0/sessions/workstreams' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
```

**Parameters**

- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Request body** (required)

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "target": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "environment"
              ]
            },
            "environmentId": {
              "type": "string",
              "minLength": 1
            },
            "templateId": {
              "not": {}
            },
            "executionTemplateId": {
              "not": {}
            },
            "computerId": {
              "not": {}
            },
            "sourceComputerId": {
              "not": {}
            },
            "sessionId": {
              "not": {}
            }
          },
          "required": [
            "kind",
            "environmentId"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "computer"
              ]
            },
            "computerId": {
              "type": "string",
              "minLength": 1
            },
            "environmentId": {
              "not": {}
            },
            "templateId": {
              "not": {}
            },
            "executionTemplateId": {
              "not": {}
            },
            "sourceComputerId": {
              "not": {}
            },
            "sessionId": {
              "not": {}
            }
          },
          "required": [
            "kind",
            "computerId"
          ],
          "additionalProperties": false
        }
      ],
      "description": "Where the workstream runs: a fresh computer from an environment, or an existing computer you own"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "description": "Workstream title. It cannot contain a NUL character or an unpaired surrogate"
    },
    "brief": {
      "type": "string",
      "minLength": 1,
      "description": "First message to the workstream orchestrator"
    }
  },
  "required": [
    "target",
    "title",
    "brief"
  ],
  "additionalProperties": false
}
```

**Response:** `201` - Response for status 201

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "sessionId": {
      "type": "string",
      "minLength": 1
    },
    "computerId": {
      "type": "string",
      "minLength": 1
    },
    "messageId": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "sessionId",
    "computerId",
    "messageId"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `409` - Response for status 409

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `413` - The platform edge refused a body over its own size limit before the route ran, for example `Request Entity Too Large` followed by an error code such as `FUNCTION_PAYLOAD_TOO_LARGE`.

Content type: `text/plain`

```json
{
  "type": "string",
  "description": "The platform edge refused a body over its own size limit before the route ran, for example `Request Entity Too Large` followed by an error code such as `FUNCTION_PAYLOAD_TOO_LARGE`."
}
```

Content type: `application/json`

```json
{
  "type": "object",
  "description": "The platform edge refused a body over its own size limit before the route ran, and answered in JSON because the request accepts JSON, for example `{\"error\":{\"code\":\"413\",\"message\":\"Request Entity Too Large\"}}`.",
  "required": [
    "error"
  ],
  "properties": {
    "error": {
      "type": "object",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    }
  },
  "not": {
    "required": [
      "detail"
    ]
  }
}
```

**Response:** `415` - Response for status 415

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Request validation error"
    },
    "errors": {
      "type": "array",
      "items": {},
      "description": "Framework validation issues, when available"
    }
  },
  "required": [
    "message"
  ]
}
```

**Response:** `424` - Response for status 424

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `504` - Response for status 504

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Get a session

`GET /api/v0/sessions/{sessionId}`

Returns the session with its status, tags, and credit usage. With `computerId`, the session is read from that computer, and `status` is `running` while its agent loop runs. This feature is enabled for selected organizations only.

```bash
curl 'https://api.factory.ai/api/v0/sessions/{sessionId}' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `sessionId` (`string`, required) - Path parameter. Session ID
- `computerId` (`string`) - Query parameter. Computer ID to query directly
- `includePinned` (`boolean`) - Query parameter. Set to true to add pinned to the answer: true when your pinned list holds this session, false when it does not.
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "sessionId": {
      "type": "string",
      "description": "Session ID"
    },
    "parent_session_id": {
      "type": "string",
      "description": "Immediate parent session ID for a Task subagent, if one exists"
    },
    "title": {
      "type": "string",
      "description": "Session title"
    },
    "status": {
      "type": "string",
      "enum": [
        "idle",
        "pending",
        "running"
      ],
      "description": "Current session execution status"
    },
    "messageCount": {
      "type": "integer",
      "description": "Number of messages in session"
    },
    "createdAt": {
      "type": "integer",
      "description": "Creation timestamp (Unix ms). Read from a computer with computerId, a single session reports its earliest message's creation time (the request time when it has no messages), and a list reports when the session file was created (its last update time when the computer did not record that)"
    },
    "updatedAt": {
      "type": "integer",
      "description": "Last update timestamp (Unix ms). Read from a computer with computerId, a single session reports its latest message's update time (the request time when it has no messages)"
    },
    "completedAt": {
      "type": "integer",
      "description": "Completion timestamp (Unix ms)"
    },
    "computerId": {
      "type": "string",
      "description": "The computer the session runs on: your computer on the session's host, otherwise the computer the session records. Absent when its host has none of your computers and it records none. Read from a computer with computerId, that computer"
    },
    "sessionSettings": {
      "type": "object",
      "properties": {
        "model": {
          "type": "string"
        },
        "reasoningEffort": {
          "type": "string",
          "enum": [
            "none",
            "dynamic",
            "off",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh",
            "max"
          ]
        },
        "interactionMode": {
          "type": "string",
          "enum": [
            "auto",
            "spec",
            "agi",
            "mission"
          ]
        },
        "autonomyLevel": {
          "type": "string",
          "enum": [
            "off",
            "low",
            "medium",
            "high"
          ]
        },
        "autonomyMode": {
          "type": "string",
          "enum": [
            "normal",
            "spec",
            "auto-low",
            "auto-medium",
            "auto-high"
          ],
          "description": "Deprecated: use interactionMode + autonomyLevel instead."
        },
        "specModeModel": {
          "type": "string"
        },
        "specModeReasoningEffort": {
          "type": "string",
          "enum": [
            "none",
            "dynamic",
            "off",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh",
            "max"
          ]
        },
        "providerLock": {
          "type": "string",
          "enum": [
            "anthropic",
            "openai",
            "generic-chat-completion-api",
            "factory",
            "google",
            "xai",
            "bedrock-converse"
          ]
        },
        "providerLockTimestamp": {
          "type": "string"
        },
        "apiProviderLock": {
          "type": "string",
          "enum": [
            "bedrock",
            "anthropic",
            "vertex_anthropic",
            "bedrock_anthropic",
            "bedrock_converse",
            "bedrock_openai",
            "openai",
            "azure_openai",
            "azure_anthropic",
            "google",
            "xai",
            "mistral",
            "fireworks",
            "baseten",
            "together",
            "snowflake",
            "databricks"
          ]
        },
        "archivedAt": {
          "type": "string"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1
              },
              "metadata": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              }
            },
            "required": [
              "name"
            ]
          }
        },
        "worktree": {
          "type": "object",
          "properties": {
            "branch": {
              "type": "string"
            },
            "lifecycle": {
              "type": "string",
              "enum": [
                "ephemeral",
                "persistent"
              ]
            },
            "path": {
              "type": "string"
            },
            "parentWorktreePath": {
              "type": "string"
            },
            "removedAt": {
              "type": "string"
            },
            "repoRoot": {
              "type": "string"
            },
            "setupProfileId": {
              "type": "string"
            }
          },
          "required": [
            "repoRoot"
          ]
        },
        "enabledToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "disabledToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "restrictToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "toolExecutionMode": {
          "type": "string",
          "enum": [
            "direct_only",
            "script_only"
          ]
        },
        "allowSubagentsInScripts": {
          "type": "boolean"
        },
        "compactionModel": {
          "type": "string"
        },
        "compactionThresholdCheckEnabled": {
          "type": "boolean"
        }
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "required": [
          "name"
        ]
      },
      "description": "Session tags. A workstream carries a mission-v2 tag whose metadata has kind \"orchestrator\" and a missionId equal to its own sessionId; spaceId appears once its shared folder is attached"
    },
    "artifacts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "externalId": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "github",
              "gitlab",
              "linear",
              "jira",
              "notion",
              "web",
              "local",
              "connector"
            ]
          },
          "kind": {
            "type": "string",
            "enum": [
              "pull_request",
              "issue",
              "document",
              "record",
              "file",
              "link"
            ]
          },
          "connector": {
            "type": "string"
          },
          "fileRole": {
            "type": "string",
            "enum": [
              "spec"
            ]
          },
          "action": {
            "type": "string",
            "enum": [
              "create",
              "update",
              "delete",
              "view",
              "close",
              "merge"
            ],
            "default": "create"
          },
          "source": {
            "type": "string",
            "enum": [
              "tool",
              "classifier",
              "user_message"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "toolCallId": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "url",
          "provider",
          "kind",
          "source",
          "createdAt"
        ]
      },
      "description": "Integration artifacts (pull requests, issues, pages) the session touched, oldest first"
    },
    "factoryCredits": {
      "type": "number",
      "description": "Total Factory credits consumed by the session and its subagents"
    },
    "pinned": {
      "type": "boolean",
      "description": "Pin preference reported by this operation. Present on a successful getSession response when includePinned=true, or on a successful updateSession response when its body supplied pinned. Absence means not reported, not unpinned."
    }
  },
  "required": [
    "sessionId",
    "status",
    "messageCount",
    "createdAt",
    "updatedAt"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `424` - Response for status 424

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Delete a session

`DELETE /api/v0/sessions/{sessionId}`

Deletes a session. With `computerId`, archives the session on that computer instead of deleting it. This feature is enabled for selected organizations only.

```bash
curl -X DELETE 'https://api.factory.ai/api/v0/sessions/{sessionId}' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `sessionId` (`string`, required) - Path parameter. Session ID
- `computerId` (`string`) - Query parameter. Computer ID to query directly
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `204` - Response for status 204

No response body.

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Update a session

`PATCH /api/v0/sessions/{sessionId}`

Pins or unpins the session for you, and updates session configuration such as model and reasoning effort. With `pinned` in the body, a 200 answers that value once the pin store acknowledges the write; without it, the request reads and writes nothing about pins and the 200 has no `pinned`. The pin write goes to the pin store before `sessionSettings` goes to the computer, and the two writes are not atomic: when the pin write is not acknowledged (a refusal, or an answer the server cannot read), `sessionSettings` is not sent, and when applying `sessionSettings` then fails with a 503, nothing undoes the pin write. This feature is enabled for selected organizations only.

```bash
curl -X PATCH 'https://api.factory.ai/api/v0/sessions/{sessionId}' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
```

**Parameters**

- `sessionId` (`string`, required) - Path parameter. Session ID
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Request body** (required)

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "sessionSettings": {
      "type": "object",
      "properties": {
        "model": {
          "type": "string"
        },
        "reasoningEffort": {
          "type": "string",
          "enum": [
            "none",
            "dynamic",
            "off",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh",
            "max"
          ]
        },
        "interactionMode": {
          "type": "string",
          "enum": [
            "auto",
            "spec",
            "agi",
            "mission"
          ]
        },
        "autonomyLevel": {
          "type": "string",
          "enum": [
            "off",
            "low",
            "medium",
            "high"
          ]
        },
        "autonomyMode": {
          "type": "string",
          "enum": [
            "normal",
            "spec",
            "auto-low",
            "auto-medium",
            "auto-high"
          ],
          "description": "Deprecated: use interactionMode + autonomyLevel instead."
        },
        "specModeModel": {
          "type": "string"
        },
        "specModeReasoningEffort": {
          "type": "string",
          "enum": [
            "none",
            "dynamic",
            "off",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh",
            "max"
          ]
        },
        "providerLock": {
          "type": "string",
          "enum": [
            "anthropic",
            "openai",
            "generic-chat-completion-api",
            "factory",
            "google",
            "xai",
            "bedrock-converse"
          ]
        },
        "providerLockTimestamp": {
          "type": "string"
        },
        "apiProviderLock": {
          "type": "string",
          "enum": [
            "bedrock",
            "anthropic",
            "vertex_anthropic",
            "bedrock_anthropic",
            "bedrock_converse",
            "bedrock_openai",
            "openai",
            "azure_openai",
            "azure_anthropic",
            "google",
            "xai",
            "mistral",
            "fireworks",
            "baseten",
            "together",
            "snowflake",
            "databricks"
          ]
        },
        "archivedAt": {
          "type": "string"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1
              },
              "metadata": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              }
            },
            "required": [
              "name"
            ],
            "additionalProperties": false
          }
        },
        "worktree": {
          "type": "object",
          "properties": {
            "branch": {
              "type": "string"
            },
            "lifecycle": {
              "type": "string",
              "enum": [
                "ephemeral",
                "persistent"
              ]
            },
            "path": {
              "type": "string"
            },
            "parentWorktreePath": {
              "type": "string"
            },
            "removedAt": {
              "type": "string"
            },
            "repoRoot": {
              "type": "string"
            },
            "setupProfileId": {
              "type": "string"
            }
          },
          "required": [
            "repoRoot"
          ],
          "additionalProperties": false
        },
        "enabledToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "disabledToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "restrictToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "compactionModel": {
          "type": "string"
        },
        "compactionThresholdCheckEnabled": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "pinned": {
      "type": "boolean",
      "description": "true pins the session for you and false unpins it; omit it to leave the pin unchanged. Only a person can change their own session's pin preference."
    }
  },
  "additionalProperties": false
}
```

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "sessionId": {
      "type": "string",
      "description": "Session ID"
    },
    "parent_session_id": {
      "type": "string",
      "description": "Immediate parent session ID for a Task subagent, if one exists"
    },
    "title": {
      "type": "string",
      "description": "Session title"
    },
    "status": {
      "type": "string",
      "enum": [
        "idle",
        "pending",
        "running"
      ],
      "description": "Current session execution status"
    },
    "messageCount": {
      "type": "integer",
      "description": "Number of messages in session"
    },
    "createdAt": {
      "type": "integer",
      "description": "Creation timestamp (Unix ms). Read from a computer with computerId, a single session reports its earliest message's creation time (the request time when it has no messages), and a list reports when the session file was created (its last update time when the computer did not record that)"
    },
    "updatedAt": {
      "type": "integer",
      "description": "Last update timestamp (Unix ms). Read from a computer with computerId, a single session reports its latest message's update time (the request time when it has no messages)"
    },
    "completedAt": {
      "type": "integer",
      "description": "Completion timestamp (Unix ms)"
    },
    "computerId": {
      "type": "string",
      "description": "The computer the session runs on: your computer on the session's host, otherwise the computer the session records. Absent when its host has none of your computers and it records none. Read from a computer with computerId, that computer"
    },
    "sessionSettings": {
      "type": "object",
      "properties": {
        "model": {
          "type": "string"
        },
        "reasoningEffort": {
          "type": "string",
          "enum": [
            "none",
            "dynamic",
            "off",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh",
            "max"
          ]
        },
        "interactionMode": {
          "type": "string",
          "enum": [
            "auto",
            "spec",
            "agi",
            "mission"
          ]
        },
        "autonomyLevel": {
          "type": "string",
          "enum": [
            "off",
            "low",
            "medium",
            "high"
          ]
        },
        "autonomyMode": {
          "type": "string",
          "enum": [
            "normal",
            "spec",
            "auto-low",
            "auto-medium",
            "auto-high"
          ],
          "description": "Deprecated: use interactionMode + autonomyLevel instead."
        },
        "specModeModel": {
          "type": "string"
        },
        "specModeReasoningEffort": {
          "type": "string",
          "enum": [
            "none",
            "dynamic",
            "off",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh",
            "max"
          ]
        },
        "providerLock": {
          "type": "string",
          "enum": [
            "anthropic",
            "openai",
            "generic-chat-completion-api",
            "factory",
            "google",
            "xai",
            "bedrock-converse"
          ]
        },
        "providerLockTimestamp": {
          "type": "string"
        },
        "apiProviderLock": {
          "type": "string",
          "enum": [
            "bedrock",
            "anthropic",
            "vertex_anthropic",
            "bedrock_anthropic",
            "bedrock_converse",
            "bedrock_openai",
            "openai",
            "azure_openai",
            "azure_anthropic",
            "google",
            "xai",
            "mistral",
            "fireworks",
            "baseten",
            "together",
            "snowflake",
            "databricks"
          ]
        },
        "archivedAt": {
          "type": "string"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1
              },
              "metadata": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              }
            },
            "required": [
              "name"
            ]
          }
        },
        "worktree": {
          "type": "object",
          "properties": {
            "branch": {
              "type": "string"
            },
            "lifecycle": {
              "type": "string",
              "enum": [
                "ephemeral",
                "persistent"
              ]
            },
            "path": {
              "type": "string"
            },
            "parentWorktreePath": {
              "type": "string"
            },
            "removedAt": {
              "type": "string"
            },
            "repoRoot": {
              "type": "string"
            },
            "setupProfileId": {
              "type": "string"
            }
          },
          "required": [
            "repoRoot"
          ]
        },
        "enabledToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "disabledToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "restrictToolIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "toolExecutionMode": {
          "type": "string",
          "enum": [
            "direct_only",
            "script_only"
          ]
        },
        "allowSubagentsInScripts": {
          "type": "boolean"
        },
        "compactionModel": {
          "type": "string"
        },
        "compactionThresholdCheckEnabled": {
          "type": "boolean"
        }
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        },
        "required": [
          "name"
        ]
      },
      "description": "Session tags. A workstream carries a mission-v2 tag whose metadata has kind \"orchestrator\" and a missionId equal to its own sessionId; spaceId appears once its shared folder is attached"
    },
    "artifacts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "externalId": {
            "type": "string"
          },
          "provider": {
            "type": "string",
            "enum": [
              "github",
              "gitlab",
              "linear",
              "jira",
              "notion",
              "web",
              "local",
              "connector"
            ]
          },
          "kind": {
            "type": "string",
            "enum": [
              "pull_request",
              "issue",
              "document",
              "record",
              "file",
              "link"
            ]
          },
          "connector": {
            "type": "string"
          },
          "fileRole": {
            "type": "string",
            "enum": [
              "spec"
            ]
          },
          "action": {
            "type": "string",
            "enum": [
              "create",
              "update",
              "delete",
              "view",
              "close",
              "merge"
            ],
            "default": "create"
          },
          "source": {
            "type": "string",
            "enum": [
              "tool",
              "classifier",
              "user_message"
            ]
          },
          "createdAt": {
            "type": "string"
          },
          "toolCallId": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "url",
          "provider",
          "kind",
          "source",
          "createdAt"
        ]
      },
      "description": "Integration artifacts (pull requests, issues, pages) the session touched, oldest first"
    },
    "factoryCredits": {
      "type": "number",
      "description": "Total Factory credits consumed by the session and its subagents"
    },
    "pinned": {
      "type": "boolean",
      "description": "Pin preference reported by this operation. Present on a successful getSession response when includePinned=true, or on a successful updateSession response when its body supplied pinned. Absence means not reported, not unpinned."
    }
  },
  "required": [
    "sessionId",
    "status",
    "messageCount",
    "createdAt",
    "updatedAt"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `413` - Response for status 413

Content type: `application/json`

```json
{
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "description": "The platform edge refused a body over its own size limit before the route ran, and answered in JSON because the request accepts JSON, for example `{\"error\":{\"code\":\"413\",\"message\":\"Request Entity Too Large\"}}`.",
      "required": [
        "error"
      ],
      "properties": {
        "error": {
          "type": "object",
          "required": [
            "code",
            "message"
          ],
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            }
          }
        }
      },
      "not": {
        "required": [
          "detail"
        ]
      }
    }
  ]
}
```

Content type: `text/plain`

```json
{
  "type": "string",
  "description": "The platform edge refused a body over its own size limit before the route ran, for example `Request Entity Too Large` followed by an error code such as `FUNCTION_PAYLOAD_TOO_LARGE`."
}
```

**Response:** `415` - Response for status 415

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Request validation error"
    },
    "errors": {
      "type": "array",
      "items": {},
      "description": "Framework validation issues, when available"
    }
  },
  "required": [
    "message"
  ]
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## List a session's child sessions

`GET /api/v0/sessions/{sessionId}/children`

Returns the caller's sessions spawned under one parent session (Task subagents, mission agents) with their last reported status and the state of the computer each runs on, oldest first. A member of a shared workstream lists the agents under it they are a member of instead. Computer details are only included for computers the caller owns. Artifacts are included only when `includeArtifacts=true`; what each session is waiting on only when `includeAttention=true`; token usage and Factory Standard Credits, rolled up with each session's Task subagents, only when `includeUsage=true`. Archived sessions are left out unless `includeArchived=true`, which lists them with `archivedAt` and sets `archivedIncluded` on the response. For enterprise organizations, `usage.tokenCountsScope` is `byok_only` and token counts cover only calls the client reported as made with the organization's own provider keys (BYOK); managed-inference calls, and usage reported before clients tagged BYOK calls, count as zero. Credits always cover every call.

```bash
curl 'https://api.factory.ai/api/v0/sessions/{sessionId}/children' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `sessionId` (`string`, required) - Path parameter. The parent session id Minimum length: 1.
- `includeArtifacts` (`boolean`) - Query parameter. Whether to include each child session’s integration artifacts (pull requests, issues, pages).
- `includeAttention` (`boolean`) - Query parameter. Whether to include what each child session is waiting on (a permission prompt or a question).
- `includeUsage` (`boolean`) - Query parameter. Whether to include each child session’s token usage and Factory Standard Credits, rolled up with its Task subagents.
- `includeArchived` (`boolean`) - Query parameter. Whether to include archived child sessions, such as a mission agent whose computer was reclaimed, each with its archivedAt. The response sets archivedIncluded when it does.
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "sessions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "minLength": 1,
            "description": "Session ID"
          },
          "title": {
            "type": "string",
            "description": "Session title; empty until the session has one"
          },
          "status": {
            "type": "string",
            "enum": [
              "idle",
              "pending",
              "running"
            ],
            "description": "Current session execution status"
          },
          "createdAt": {
            "type": "integer",
            "description": "Creation timestamp (Unix ms)"
          },
          "updatedAt": {
            "type": "integer",
            "description": "Last update timestamp (Unix ms); the status has held at least since then"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "metadata": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "name"
              ]
            },
            "description": "Session tags, including any mission identity"
          },
          "artifacts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "title": {
                  "type": "string"
                },
                "externalId": {
                  "type": "string"
                },
                "provider": {
                  "type": "string",
                  "enum": [
                    "github",
                    "gitlab",
                    "linear",
                    "jira",
                    "notion",
                    "web",
                    "local",
                    "connector"
                  ]
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "pull_request",
                    "issue",
                    "document",
                    "record",
                    "file",
                    "link"
                  ]
                },
                "connector": {
                  "type": "string"
                },
                "fileRole": {
                  "type": "string",
                  "enum": [
                    "spec"
                  ]
                },
                "action": {
                  "type": "string",
                  "enum": [
                    "create",
                    "update",
                    "delete",
                    "view",
                    "close",
                    "merge"
                  ],
                  "default": "create"
                },
                "source": {
                  "type": "string",
                  "enum": [
                    "tool",
                    "classifier",
                    "user_message"
                  ]
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "toolCallId": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "url",
                "provider",
                "kind",
                "source",
                "createdAt"
              ]
            },
            "description": "Integration artifacts the session created; only returned when includeArtifacts=true"
          },
          "attention": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "permission",
                  "ask-user"
                ]
              },
              "since": {
                "type": "integer"
              }
            },
            "required": [
              "kind",
              "since"
            ],
            "nullable": true,
            "description": "What the session is waiting on, or null when it is not blocked; only returned when includeAttention=true"
          },
          "usage": {
            "type": "object",
            "properties": {
              "inputTokens": {
                "type": "number"
              },
              "outputTokens": {
                "type": "number"
              },
              "cacheCreationTokens": {
                "type": "number"
              },
              "cacheReadTokens": {
                "type": "number"
              },
              "factoryCredits": {
                "type": "number"
              },
              "tokenCountsScope": {
                "type": "string",
                "enum": [
                  "byok_only"
                ]
              }
            },
            "required": [
              "inputTokens",
              "outputTokens",
              "cacheCreationTokens",
              "cacheReadTokens"
            ],
            "nullable": true,
            "description": "Token usage and Factory Standard Credits for the session and its Task subagents, or null when it has not reported any; factoryCredits is omitted when the organization hides billable usage. For enterprise organizations tokenCountsScope is byok_only and the token counts cover only calls the client reported as BYOK; managed-inference calls, and usage reported before clients tagged BYOK calls, count as zero. Only returned when includeUsage=true"
          },
          "archivedAt": {
            "type": "integer",
            "nullable": true,
            "description": "When the session was archived (Unix ms), or null when it is archived but its stored marker has no readable time; absent for a live session. Only returned when includeArchived=true"
          },
          "computerId": {
            "type": "string",
            "minLength": 1,
            "nullable": true,
            "description": "The computer id the session records, or null when it records none, as for an agent an orchestrator starts on its own machine. Act on an agent by its session id: session operations find the machine it runs on, and GET /api/v0/sessions/{sessionId} reports it"
          },
          "computer": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "provisioning",
                  "active",
                  "error"
                ]
              },
              "providerStatus": {
                "type": "string",
                "enum": [
                  "requested",
                  "provisioning",
                  "booting",
                  "running",
                  "paused",
                  "snapshotting",
                  "terminating",
                  "terminated",
                  "failed",
                  null
                ],
                "nullable": true,
                "description": "Last known sandbox lifecycle state; null for BYOM computers. More states may be added, so treat a value you do not know as unknown."
              },
              "templateId": {
                "type": "string",
                "minLength": 1,
                "nullable": true
              }
            },
            "required": [
              "id",
              "name",
              "templateId"
            ],
            "nullable": true,
            "description": "The computer that computerId names, when the caller owns it; null when computerId is null, that computer is gone, or it is someone else's. Compare with computerId to tell these apart"
          }
        },
        "required": [
          "sessionId",
          "title",
          "status",
          "createdAt",
          "updatedAt",
          "computerId",
          "computer"
        ]
      }
    },
    "archivedIncluded": {
      "type": "boolean",
      "enum": [
        true
      ],
      "description": "Present when the list includes archived child sessions, as includeArchived=true asks for"
    }
  },
  "required": [
    "sessions"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## List pending session elicitations

`GET /api/v0/sessions/{sessionId}/elicitations`

Returns the permission prompts (including spec approvals) and AskUser questions the session is waiting on. Each item carries the same fields the SDK permissionHandler and askUserHandler receive, plus the requestId to answer it with, and a permission prompt lists only the options the answer endpoint accepts. Items use these SDK shapes, not the MCP elicitation JSON Schema form. Option pickers (pick_options requests) are not covered, and neither are queued AskUser questions (`blocking: false`, which the agent does not wait on); answer those in the Factory desktop app, web app or CLI. This feature is enabled for selected organizations only.

```bash
curl 'https://api.factory.ai/api/v0/sessions/{sessionId}/elicitations' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `sessionId` (`string`, required) - Path parameter. Session ID
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "elicitations": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "toolUses": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "toolUse": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "tool_use"
                          ]
                        },
                        "id": {
                          "type": "string"
                        },
                        "input": {
                          "type": "object",
                          "additionalProperties": {}
                        },
                        "name": {
                          "type": "string"
                        },
                        "thoughtSignature": {
                          "type": "string"
                        },
                        "namespace": {
                          "type": "string"
                        },
                        "scriptExecution": {
                          "type": "object",
                          "properties": {
                            "runId": {
                              "type": "string"
                            },
                            "outerToolUseId": {
                              "type": "string"
                            },
                            "seen": {
                              "type": "number"
                            }
                          },
                          "required": [
                            "runId",
                            "outerToolUseId"
                          ]
                        },
                        "scriptOracle": {
                          "type": "object",
                          "properties": {
                            "callCount": {
                              "type": "number"
                            },
                            "rows": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "site": {
                                    "type": "number"
                                  },
                                  "toolName": {
                                    "type": "string"
                                  },
                                  "path": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "input": {
                                    "type": "object",
                                    "additionalProperties": {}
                                  },
                                  "count": {
                                    "type": "number"
                                  }
                                },
                                "required": [
                                  "id",
                                  "toolName",
                                  "path",
                                  "input",
                                  "count"
                                ]
                              }
                            }
                          },
                          "required": [
                            "callCount",
                            "rows"
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "id",
                        "input",
                        "name"
                      ]
                    },
                    "confirmationType": {
                      "type": "string",
                      "enum": [
                        "edit",
                        "exec",
                        "create",
                        "ask_user",
                        "exit_spec_mode",
                        "recommend_mission",
                        "propose_mission",
                        "start_mission_run",
                        "apply_patch",
                        "mcp_tool",
                        "sandbox_violation",
                        "droid_shield_violation",
                        "script"
                      ]
                    },
                    "details": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "edit"
                              ]
                            },
                            "filePath": {
                              "type": "string"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "oldContent": {
                              "type": "string"
                            },
                            "newContent": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "filePath",
                            "fileName"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "exec"
                              ]
                            },
                            "fullCommand": {
                              "type": "string"
                            },
                            "command": {
                              "type": "string"
                            },
                            "extractedCommands": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "impactLevel": {
                              "type": "string"
                            },
                            "riskLevelReason": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "fullCommand",
                            "command"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "create"
                              ]
                            },
                            "filePath": {
                              "type": "string"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "content": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "filePath",
                            "fileName",
                            "content"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "ask_user"
                              ]
                            },
                            "questionnaire": {
                              "type": "string"
                            },
                            "parsed": {
                              "type": "object",
                              "properties": {
                                "questions": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "index": {
                                        "type": "number"
                                      },
                                      "topic": {
                                        "type": "string"
                                      },
                                      "question": {
                                        "type": "string"
                                      },
                                      "options": {
                                        "type": "array",
                                        "items": {
                                          "type": "string"
                                        }
                                      },
                                      "multiSelect": {
                                        "type": "boolean"
                                      }
                                    },
                                    "required": [
                                      "index",
                                      "topic",
                                      "question",
                                      "options"
                                    ]
                                  }
                                }
                              },
                              "required": [
                                "questions"
                              ]
                            },
                            "parseError": {
                              "type": "object",
                              "properties": {
                                "message": {
                                  "type": "string"
                                },
                                "line": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "message"
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "questionnaire"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "exit_spec_mode"
                              ]
                            },
                            "plan": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "contextSavingsPercent": {
                              "type": "number"
                            },
                            "supportsClientStartedHandoff": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "type",
                            "plan"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "propose_mission"
                              ]
                            },
                            "proposal": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "proposal"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "start_mission_run"
                              ]
                            },
                            "runningMissionCount": {
                              "type": "number"
                            },
                            "runningMissionSessionIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": [
                            "type",
                            "runningMissionCount",
                            "runningMissionSessionIds"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "apply_patch"
                              ]
                            },
                            "filePath": {
                              "type": "string"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "patchContent": {
                              "type": "string"
                            },
                            "oldContent": {
                              "type": "string"
                            },
                            "newContent": {
                              "type": "string"
                            },
                            "files": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "filePath": {
                                    "type": "string"
                                  },
                                  "fileName": {
                                    "type": "string"
                                  },
                                  "operation": {
                                    "type": "string",
                                    "enum": [
                                      "create",
                                      "update",
                                      "delete"
                                    ]
                                  },
                                  "moveTo": {
                                    "type": "string"
                                  },
                                  "oldContent": {
                                    "type": "string"
                                  },
                                  "newContent": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "filePath",
                                  "fileName",
                                  "operation"
                                ]
                              }
                            }
                          },
                          "required": [
                            "type",
                            "filePath",
                            "fileName",
                            "patchContent"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "mcp_tool"
                              ]
                            },
                            "toolName": {
                              "type": "string"
                            },
                            "impactLevel": {
                              "type": "string"
                            },
                            "serverName": {
                              "type": "string"
                            },
                            "actualToolName": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "toolName",
                            "impactLevel"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "sandbox_violation"
                              ]
                            },
                            "violatingToolName": {
                              "type": "string"
                            },
                            "target": {
                              "type": "string"
                            },
                            "operationType": {
                              "type": "string",
                              "enum": [
                                "read",
                                "write",
                                "network",
                                "tool"
                              ]
                            },
                            "violationType": {
                              "type": "string",
                              "enum": [
                                "filesystem-read",
                                "filesystem-write",
                                "network",
                                "tool"
                              ]
                            },
                            "reason": {
                              "type": "string"
                            },
                            "violationReason": {
                              "type": "string",
                              "enum": [
                                "deny-list",
                                "not-allowed"
                              ]
                            },
                            "isOrgDeny": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "type",
                            "violatingToolName",
                            "target",
                            "operationType",
                            "violationType",
                            "reason",
                            "isOrgDeny"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "droid_shield_violation"
                              ]
                            },
                            "command": {
                              "type": "string"
                            },
                            "reason": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "command",
                            "reason"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "recommend_mission"
                              ]
                            },
                            "reason": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "reason"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "script"
                              ]
                            },
                            "impactLevel": {
                              "type": "string"
                            },
                            "calls": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "toolName": {
                                    "type": "string"
                                  },
                                  "line": {
                                    "type": "number"
                                  },
                                  "column": {
                                    "type": "number"
                                  },
                                  "toolInput": {
                                    "type": "object",
                                    "additionalProperties": {}
                                  },
                                  "confirmation": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "edit"
                                            ]
                                          },
                                          "filePath": {
                                            "type": "string"
                                          },
                                          "fileName": {
                                            "type": "string"
                                          },
                                          "oldContent": {
                                            "type": "string"
                                          },
                                          "newContent": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "filePath",
                                          "fileName"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "exec"
                                            ]
                                          },
                                          "fullCommand": {
                                            "type": "string"
                                          },
                                          "command": {
                                            "type": "string"
                                          },
                                          "extractedCommands": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          "impactLevel": {
                                            "type": "string"
                                          },
                                          "riskLevelReason": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "fullCommand",
                                          "command"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "create"
                                            ]
                                          },
                                          "filePath": {
                                            "type": "string"
                                          },
                                          "fileName": {
                                            "type": "string"
                                          },
                                          "content": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "filePath",
                                          "fileName",
                                          "content"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "ask_user"
                                            ]
                                          },
                                          "questionnaire": {
                                            "type": "string"
                                          },
                                          "parsed": {
                                            "type": "object",
                                            "properties": {
                                              "questions": {
                                                "type": "array",
                                                "items": {
                                                  "type": "object",
                                                  "properties": {
                                                    "index": {
                                                      "type": "number"
                                                    },
                                                    "topic": {
                                                      "type": "string"
                                                    },
                                                    "question": {
                                                      "type": "string"
                                                    },
                                                    "options": {
                                                      "type": "array",
                                                      "items": {
                                                        "type": "string"
                                                      }
                                                    },
                                                    "multiSelect": {
                                                      "type": "boolean"
                                                    }
                                                  },
                                                  "required": [
                                                    "index",
                                                    "topic",
                                                    "question",
                                                    "options"
                                                  ]
                                                }
                                              }
                                            },
                                            "required": [
                                              "questions"
                                            ]
                                          },
                                          "parseError": {
                                            "type": "object",
                                            "properties": {
                                              "message": {
                                                "type": "string"
                                              },
                                              "line": {
                                                "type": "number"
                                              }
                                            },
                                            "required": [
                                              "message"
                                            ]
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "questionnaire"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "exit_spec_mode"
                                            ]
                                          },
                                          "plan": {
                                            "type": "string"
                                          },
                                          "title": {
                                            "type": "string"
                                          },
                                          "contextSavingsPercent": {
                                            "type": "number"
                                          },
                                          "supportsClientStartedHandoff": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "plan"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "propose_mission"
                                            ]
                                          },
                                          "proposal": {
                                            "type": "string"
                                          },
                                          "title": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "proposal"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "start_mission_run"
                                            ]
                                          },
                                          "runningMissionCount": {
                                            "type": "number"
                                          },
                                          "runningMissionSessionIds": {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "runningMissionCount",
                                          "runningMissionSessionIds"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "apply_patch"
                                            ]
                                          },
                                          "filePath": {
                                            "type": "string"
                                          },
                                          "fileName": {
                                            "type": "string"
                                          },
                                          "patchContent": {
                                            "type": "string"
                                          },
                                          "oldContent": {
                                            "type": "string"
                                          },
                                          "newContent": {
                                            "type": "string"
                                          },
                                          "files": {
                                            "type": "array",
                                            "items": {
                                              "type": "object",
                                              "properties": {
                                                "filePath": {
                                                  "type": "string"
                                                },
                                                "fileName": {
                                                  "type": "string"
                                                },
                                                "operation": {
                                                  "type": "string",
                                                  "enum": [
                                                    "create",
                                                    "update",
                                                    "delete"
                                                  ]
                                                },
                                                "moveTo": {
                                                  "type": "string"
                                                },
                                                "oldContent": {
                                                  "type": "string"
                                                },
                                                "newContent": {
                                                  "type": "string"
                                                }
                                              },
                                              "required": [
                                                "filePath",
                                                "fileName",
                                                "operation"
                                              ]
                                            }
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "filePath",
                                          "fileName",
                                          "patchContent"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "mcp_tool"
                                            ]
                                          },
                                          "toolName": {
                                            "type": "string"
                                          },
                                          "impactLevel": {
                                            "type": "string"
                                          },
                                          "serverName": {
                                            "type": "string"
                                          },
                                          "actualToolName": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "toolName",
                                          "impactLevel"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "sandbox_violation"
                                            ]
                                          },
                                          "violatingToolName": {
                                            "type": "string"
                                          },
                                          "target": {
                                            "type": "string"
                                          },
                                          "operationType": {
                                            "type": "string",
                                            "enum": [
                                              "read",
                                              "write",
                                              "network",
                                              "tool"
                                            ]
                                          },
                                          "violationType": {
                                            "type": "string",
                                            "enum": [
                                              "filesystem-read",
                                              "filesystem-write",
                                              "network",
                                              "tool"
                                            ]
                                          },
                                          "reason": {
                                            "type": "string"
                                          },
                                          "violationReason": {
                                            "type": "string",
                                            "enum": [
                                              "deny-list",
                                              "not-allowed"
                                            ]
                                          },
                                          "isOrgDeny": {
                                            "type": "boolean"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "violatingToolName",
                                          "target",
                                          "operationType",
                                          "violationType",
                                          "reason",
                                          "isOrgDeny"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "droid_shield_violation"
                                            ]
                                          },
                                          "command": {
                                            "type": "string"
                                          },
                                          "reason": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "command",
                                          "reason"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "recommend_mission"
                                            ]
                                          },
                                          "reason": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "reason"
                                        ]
                                      }
                                    ]
                                  },
                                  "alwaysAsk": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "toolName",
                                  "line",
                                  "column",
                                  "toolInput",
                                  "confirmation"
                                ]
                              }
                            }
                          },
                          "required": [
                            "type",
                            "impactLevel",
                            "calls"
                          ]
                        }
                      ]
                    }
                  },
                  "required": [
                    "toolUse",
                    "confirmationType",
                    "details"
                  ]
                }
              },
              "options": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "label": {
                      "type": "string"
                    },
                    "value": {
                      "type": "string",
                      "enum": [
                        "proceed_once",
                        "proceed_always",
                        "proceed_always_file",
                        "proceed_auto_run",
                        "proceed_auto_run_low",
                        "proceed_auto_run_medium",
                        "proceed_auto_run_high",
                        "proceed_new_session",
                        "proceed_new_session_low",
                        "proceed_new_session_medium",
                        "proceed_new_session_high",
                        "proceed_edit",
                        "proceed_always_tools",
                        "proceed_always_server",
                        "proceed_report_false_positive",
                        "cancel"
                      ]
                    }
                  },
                  "required": [
                    "label",
                    "value"
                  ]
                }
              },
              "associatedSessionIds": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "type": {
                "type": "string",
                "enum": [
                  "permission"
                ]
              },
              "requestId": {
                "type": "string",
                "minLength": 1,
                "description": "ID to answer the prompt with"
              }
            },
            "required": [
              "toolUses",
              "options",
              "type",
              "requestId"
            ]
          },
          {
            "type": "object",
            "properties": {
              "toolCallId": {
                "type": "string"
              },
              "questions": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "index": {
                      "type": "number"
                    },
                    "topic": {
                      "type": "string"
                    },
                    "question": {
                      "type": "string"
                    },
                    "options": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "optionDescriptions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "multiSelect": {
                      "type": "boolean"
                    },
                    "context": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "index",
                    "topic",
                    "question",
                    "options"
                  ]
                }
              },
              "blocking": {
                "type": "boolean"
              },
              "type": {
                "type": "string",
                "enum": [
                  "ask-user"
                ]
              },
              "requestId": {
                "type": "string",
                "minLength": 1,
                "description": "ID to answer the questions with"
              }
            },
            "required": [
              "toolCallId",
              "questions",
              "type",
              "requestId"
            ]
          }
        ]
      },
      "description": "Permission prompts and AskUser questions the session is waiting on. Queued AskUser questions, which the agent does not wait on, are not listed."
    }
  },
  "required": [
    "elicitations"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `504` - Response for status 504

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Answer a pending session elicitation

`POST /api/v0/sessions/{sessionId}/elicitations/{requestId}`

Answers one pending elicitation with the same result the SDK handlers return: `selectedOption` (one of the prompt's listed `options[].value`) for a permission prompt, or `answers` (exactly one per question, matched by index) or `cancelled: true` for AskUser questions. Persistent "always" options, `proceed_edit`, and `proceed_new_session*` are not listed or accepted. `comment` reaches the agent only when approving a spec; a `cancel` drops it, so send feedback with `POST /api/v0/sessions/{sessionId}/messages` after rejecting. 200 means the session applied this answer; for a permission prompt the response names the option it applied. Returns 409 when the elicitation is not pending: it was never a pending prompt of this session (a queued AskUser question counts as not pending), another client answered it first, or its turn ended. Returns 503 when the session's computer runs a Droid version that cannot answer elicitations through this API. This feature is enabled for selected organizations only.

```bash
curl -X POST 'https://api.factory.ai/api/v0/sessions/{sessionId}/elicitations/{requestId}' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
```

**Parameters**

- `sessionId` (`string`, required) - Path parameter. Session ID
- `requestId` (`string`, required) - Path parameter. Pending elicitation ID Minimum length: 1.
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Request body** (required)

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "cancelled": {
          "type": "boolean",
          "enum": [
            true
          ],
          "description": "Dismiss an AskUser elicitation without answering"
        },
        "answers": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "index": {
                "type": "number"
              },
              "question": {
                "type": "string"
              },
              "answer": {
                "type": "string"
              }
            },
            "required": [
              "index",
              "question",
              "answer"
            ],
            "additionalProperties": false
          },
          "maxItems": 0
        },
        "selectedOption": {
          "not": {}
        }
      },
      "required": [
        "cancelled"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "answers": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "index": {
                "type": "number"
              },
              "question": {
                "type": "string"
              },
              "answer": {
                "type": "string"
              }
            },
            "required": [
              "index",
              "question",
              "answer"
            ],
            "additionalProperties": false
          },
          "minItems": 1,
          "description": "Answers to an AskUser elicitation: exactly one per question, matched by index"
        },
        "cancelled": {
          "type": "boolean",
          "enum": [
            false
          ]
        },
        "selectedOption": {
          "not": {}
        }
      },
      "required": [
        "answers"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "selectedOption": {
          "type": "string",
          "enum": [
            "proceed_once",
            "proceed_always",
            "proceed_always_file",
            "proceed_auto_run",
            "proceed_auto_run_low",
            "proceed_auto_run_medium",
            "proceed_auto_run_high",
            "proceed_new_session",
            "proceed_new_session_low",
            "proceed_new_session_medium",
            "proceed_new_session_high",
            "proceed_edit",
            "proceed_always_tools",
            "proceed_always_server",
            "proceed_report_false_positive",
            "cancel"
          ],
          "description": "One of the permission elicitation's options[].value"
        },
        "comment": {
          "type": "string",
          "description": "Note passed to the agent when approving a spec. Rejections and other prompts drop it; after cancel, send feedback as a message"
        },
        "answers": {
          "not": {}
        },
        "cancelled": {
          "not": {}
        }
      },
      "required": [
        "selectedOption"
      ],
      "additionalProperties": false
    }
  ]
}
```

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "requestId": {
      "type": "string",
      "minLength": 1,
      "description": "The answered elicitation ID"
    },
    "selectedOption": {
      "type": "string",
      "enum": [
        "proceed_once",
        "proceed_always",
        "proceed_always_file",
        "proceed_auto_run",
        "proceed_auto_run_low",
        "proceed_auto_run_medium",
        "proceed_auto_run_high",
        "proceed_new_session",
        "proceed_new_session_low",
        "proceed_new_session_medium",
        "proceed_new_session_high",
        "proceed_edit",
        "proceed_always_tools",
        "proceed_always_server",
        "proceed_report_false_positive",
        "cancel"
      ],
      "description": "For a permission prompt, the option the session settled it with: the one this answer sent"
    }
  },
  "required": [
    "requestId"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `409` - Response for status 409

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `413` - Response for status 413

Content type: `application/json`

```json
{
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "description": "The platform edge refused a body over its own size limit before the route ran, and answered in JSON because the request accepts JSON, for example `{\"error\":{\"code\":\"413\",\"message\":\"Request Entity Too Large\"}}`.",
      "required": [
        "error"
      ],
      "properties": {
        "error": {
          "type": "object",
          "required": [
            "code",
            "message"
          ],
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            }
          }
        }
      },
      "not": {
        "required": [
          "detail"
        ]
      }
    }
  ]
}
```

Content type: `text/plain`

```json
{
  "type": "string",
  "description": "The platform edge refused a body over its own size limit before the route ran, for example `Request Entity Too Large` followed by an error code such as `FUNCTION_PAYLOAD_TOO_LARGE`."
}
```

**Response:** `415` - Response for status 415

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Request validation error"
    },
    "errors": {
      "type": "array",
      "items": {},
      "description": "Framework validation issues, when available"
    }
  },
  "required": [
    "message"
  ]
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `504` - Response for status 504

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Interrupt a session

`POST /api/v0/sessions/{sessionId}/interrupt`

Interrupts a running agent loop. Idempotent if already idle. This feature is enabled for selected organizations only.

```bash
curl -X POST 'https://api.factory.ai/api/v0/sessions/{sessionId}/interrupt' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `sessionId` (`string`, required) - Path parameter
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "idle",
        "pending",
        "running"
      ],
      "description": "Current session execution status"
    }
  },
  "required": [
    "status"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Get session messages

`GET /api/v0/sessions/{sessionId}/messages`

Returns paginated message history with optional role filtering. This feature is enabled for selected organizations only.

```bash
curl 'https://api.factory.ai/api/v0/sessions/{sessionId}/messages' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `sessionId` (`string`, required) - Path parameter
- `limit` (`integer`) - Query parameter. Maximum number of items to return (1-100) Default: 20.
- `cursor` (`string`) - Query parameter. Cursor for pagination
- `computerId` (`string`) - Query parameter. Computer ID to query directly
- `role` (`string`) - Query parameter. Filter messages by role Allowed values: user, assistant, tool.
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "messages": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant",
              "tool",
              "system"
            ]
          },
          "content": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "text"
                      ]
                    },
                    "text": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "text"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "image"
                      ]
                    },
                    "source": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "base64"
                          ]
                        },
                        "data": {
                          "type": "string"
                        },
                        "mediaType": {
                          "type": "string",
                          "enum": [
                            "image/jpeg",
                            "image/png",
                            "image/gif",
                            "image/webp"
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "data",
                        "mediaType"
                      ]
                    },
                    "elided": {
                      "type": "object",
                      "properties": {
                        "bytes": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "lines": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "width": {
                          "type": "integer",
                          "exclusiveMinimum": true,
                          "minimum": 0
                        },
                        "height": {
                          "type": "integer",
                          "exclusiveMinimum": true,
                          "minimum": 0
                        },
                        "preview": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "bytes"
                      ]
                    },
                    "generated": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "type",
                    "source"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "thinking"
                      ]
                    },
                    "signature": {
                      "type": "string"
                    },
                    "signatureProvider": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "anthropic",
                            "openai",
                            "generic-chat-completion-api",
                            "factory",
                            "google",
                            "xai",
                            "bedrock-converse"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "unknown"
                          ]
                        }
                      ]
                    },
                    "thinking": {
                      "type": "string"
                    },
                    "durationMs": {
                      "type": "number",
                      "minimum": 0
                    },
                    "progressUpdate": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "type",
                    "signature",
                    "thinking"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "redacted_thinking"
                      ]
                    },
                    "data": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "data"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "tool_use"
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "input": {
                      "type": "object",
                      "additionalProperties": {}
                    },
                    "name": {
                      "type": "string"
                    },
                    "thoughtSignature": {
                      "type": "string"
                    },
                    "namespace": {
                      "type": "string"
                    },
                    "scriptExecution": {
                      "type": "object",
                      "properties": {
                        "runId": {
                          "type": "string"
                        },
                        "outerToolUseId": {
                          "type": "string"
                        },
                        "seen": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "runId",
                        "outerToolUseId"
                      ]
                    },
                    "scriptOracle": {
                      "type": "object",
                      "properties": {
                        "callCount": {
                          "type": "number"
                        },
                        "rows": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "site": {
                                "type": "number"
                              },
                              "toolName": {
                                "type": "string"
                              },
                              "path": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "input": {
                                "type": "object",
                                "additionalProperties": {}
                              },
                              "count": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "id",
                              "toolName",
                              "path",
                              "input",
                              "count"
                            ]
                          }
                        }
                      },
                      "required": [
                        "callCount",
                        "rows"
                      ]
                    }
                  },
                  "required": [
                    "type",
                    "id",
                    "input",
                    "name"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "tool_result"
                      ]
                    },
                    "toolUseId": {
                      "type": "string"
                    },
                    "content": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "array",
                          "items": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "text"
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "text"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "image"
                                    ]
                                  },
                                  "source": {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "base64"
                                        ]
                                      },
                                      "data": {
                                        "type": "string"
                                      },
                                      "mediaType": {
                                        "type": "string",
                                        "enum": [
                                          "image/jpeg",
                                          "image/png",
                                          "image/gif",
                                          "image/webp"
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "data",
                                      "mediaType"
                                    ]
                                  },
                                  "elided": {
                                    "type": "object",
                                    "properties": {
                                      "bytes": {
                                        "type": "integer",
                                        "minimum": 0
                                      },
                                      "lines": {
                                        "type": "integer",
                                        "minimum": 0
                                      },
                                      "width": {
                                        "type": "integer",
                                        "exclusiveMinimum": true,
                                        "minimum": 0
                                      },
                                      "height": {
                                        "type": "integer",
                                        "exclusiveMinimum": true,
                                        "minimum": 0
                                      },
                                      "preview": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "bytes"
                                    ]
                                  },
                                  "generated": {
                                    "type": "boolean"
                                  }
                                },
                                "required": [
                                  "type",
                                  "source"
                                ]
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "document"
                                    ]
                                  },
                                  "source": {
                                    "anyOf": [
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "base64"
                                            ]
                                          },
                                          "mediaType": {
                                            "type": "string",
                                            "enum": [
                                              "application/pdf"
                                            ]
                                          },
                                          "data": {
                                            "type": "string"
                                          },
                                          "parsedData": {
                                            "type": "string"
                                          },
                                          "name": {
                                            "type": "string"
                                          },
                                          "path": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "mediaType",
                                          "data"
                                        ]
                                      },
                                      {
                                        "type": "object",
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "text"
                                            ]
                                          },
                                          "mediaType": {
                                            "type": "string",
                                            "enum": [
                                              "text/plain"
                                            ]
                                          },
                                          "data": {
                                            "type": "string"
                                          },
                                          "name": {
                                            "type": "string"
                                          },
                                          "mime": {
                                            "type": "string"
                                          }
                                        },
                                        "required": [
                                          "type",
                                          "mediaType",
                                          "data"
                                        ]
                                      }
                                    ]
                                  },
                                  "elided": {
                                    "type": "object",
                                    "properties": {
                                      "bytes": {
                                        "type": "integer",
                                        "minimum": 0
                                      },
                                      "lines": {
                                        "type": "integer",
                                        "minimum": 0
                                      },
                                      "width": {
                                        "type": "integer",
                                        "exclusiveMinimum": true,
                                        "minimum": 0
                                      },
                                      "height": {
                                        "type": "integer",
                                        "exclusiveMinimum": true,
                                        "minimum": 0
                                      },
                                      "preview": {
                                        "type": "string"
                                      }
                                    },
                                    "required": [
                                      "bytes"
                                    ]
                                  }
                                },
                                "required": [
                                  "type",
                                  "source"
                                ]
                              }
                            ]
                          }
                        }
                      ]
                    },
                    "elided": {
                      "type": "object",
                      "properties": {
                        "bytes": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "lines": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "width": {
                          "type": "integer",
                          "exclusiveMinimum": true,
                          "minimum": 0
                        },
                        "height": {
                          "type": "integer",
                          "exclusiveMinimum": true,
                          "minimum": 0
                        },
                        "preview": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "bytes"
                      ]
                    },
                    "isError": {
                      "type": "boolean"
                    },
                    "modelContent": {
                      "type": "string"
                    },
                    "respondedBy": {
                      "type": "object",
                      "properties": {
                        "userId": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "source": {
                          "type": "string",
                          "enum": [
                            "web",
                            "desktop",
                            "cli_tui",
                            "cli_exec",
                            "cli_acp",
                            "slack",
                            "jira",
                            "linear",
                            "microsoft-teams",
                            "google-chat",
                            "sessions_api",
                            "api",
                            "sdk",
                            "automation",
                            "readiness-remediation",
                            "readiness-evaluation",
                            "wiki-generation",
                            "wiki-ci-setup"
                          ]
                        },
                        "receipt": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "userId"
                      ]
                    },
                    "modelOnly": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "type",
                    "toolUseId"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "document"
                      ]
                    },
                    "source": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "base64"
                              ]
                            },
                            "mediaType": {
                              "type": "string",
                              "enum": [
                                "application/pdf"
                              ]
                            },
                            "data": {
                              "type": "string"
                            },
                            "parsedData": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "path": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "mediaType",
                            "data"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "text"
                              ]
                            },
                            "mediaType": {
                              "type": "string",
                              "enum": [
                                "text/plain"
                              ]
                            },
                            "data": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "mime": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "mediaType",
                            "data"
                          ]
                        }
                      ]
                    },
                    "elided": {
                      "type": "object",
                      "properties": {
                        "bytes": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "lines": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "width": {
                          "type": "integer",
                          "exclusiveMinimum": true,
                          "minimum": 0
                        },
                        "height": {
                          "type": "integer",
                          "exclusiveMinimum": true,
                          "minimum": 0
                        },
                        "preview": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "bytes"
                      ]
                    }
                  },
                  "required": [
                    "type",
                    "source"
                  ]
                }
              ]
            }
          },
          "createdAt": {
            "type": "number",
            "description": "Unix timestamp, in milliseconds, when the message was created."
          },
          "updatedAt": {
            "type": "number",
            "description": "Unix timestamp, in milliseconds, when the message last changed."
          },
          "parentId": {
            "type": "string"
          },
          "seq": {
            "type": "integer",
            "minimum": 0
          },
          "userMessageSource": {
            "type": "string",
            "enum": [
              "web",
              "desktop",
              "cli_tui",
              "cli_exec",
              "cli_acp",
              "slack",
              "jira",
              "linear",
              "microsoft-teams",
              "google-chat",
              "sessions_api",
              "api",
              "sdk",
              "automation",
              "readiness-remediation",
              "readiness-evaluation",
              "wiki-generation",
              "wiki-ci-setup"
            ]
          },
          "sender": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "orchestrator"
                    ]
                  },
                  "sessionId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "kind",
                  "sessionId"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "agent"
                    ]
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1
                  },
                  "sessionId": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "kind",
                  "title",
                  "sessionId"
                ]
              }
            ]
          },
          "author": {
            "type": "object",
            "properties": {
              "userId": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "source": {
                "type": "string",
                "enum": [
                  "web",
                  "desktop",
                  "cli_tui",
                  "cli_exec",
                  "cli_acp",
                  "slack",
                  "jira",
                  "linear",
                  "microsoft-teams",
                  "google-chat",
                  "sessions_api",
                  "api",
                  "sdk",
                  "automation",
                  "readiness-remediation",
                  "readiness-evaluation",
                  "wiki-generation",
                  "wiki-ci-setup"
                ]
              },
              "receipt": {
                "type": "string"
              }
            },
            "required": [
              "userId"
            ]
          },
          "docCommentThread": {
            "type": "object",
            "properties": {
              "threadId": {
                "type": "string",
                "format": "uuid"
              },
              "doc": {
                "anyOf": [
                  {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "space"
                            ]
                          },
                          "spaceId": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "documentId": {
                            "type": "string",
                            "format": "uuid"
                          }
                        },
                        "required": [
                          "kind",
                          "spaceId",
                          "documentId"
                        ]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "local"
                            ]
                          },
                          "machineId": {
                            "type": "string",
                            "minLength": 1
                          },
                          "path": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "required": [
                          "kind",
                          "machineId",
                          "path"
                        ]
                      }
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "enum": [
                          "unknown"
                        ]
                      },
                      "reportedKind": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "kind"
                    ]
                  }
                ]
              },
              "documentPath": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "threadId",
              "documentPath"
            ]
          },
          "mentions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "userId": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "userId",
                "name"
              ]
            }
          },
          "interactionMode": {
            "type": "string",
            "enum": [
              "auto",
              "spec",
              "agi",
              "mission"
            ]
          },
          "visibility": {
            "type": "string",
            "enum": [
              "both",
              "llm_only",
              "user_only"
            ]
          },
          "systemNotice": {
            "type": "boolean",
            "enum": [
              true
            ],
            "description": "Marks a notice the harness wrote into the conversation, such as a provider error or a skill activation. The role is unchanged by it, so readers that predate the marker still show its text."
          },
          "hookRowId": {
            "type": "string",
            "description": "On a notice that repeats a hook's error: the id of the hook row that already shows the error. A client that draws that hook row can leave the notice out."
          },
          "endedEarly": {
            "type": "boolean",
            "enum": [
              true
            ],
            "description": "Marks an assistant message that ended early. When the session is loaded, a model-owned call of it that has no result is not run or resumed, unless a pending marker reserves that call or a message without the mark also makes it."
          },
          "openaiMessageId": {
            "type": "string"
          },
          "openaiPhase": {
            "type": "string",
            "enum": [
              "commentary",
              "final_answer",
              null
            ],
            "nullable": true
          },
          "openaiEncryptedContent": {
            "type": "string"
          },
          "openaiReasoningId": {
            "type": "string"
          },
          "openaiReasoningSummary": {
            "type": "string"
          },
          "geminiThoughtSignature": {
            "type": "string",
            "description": "@deprecated Use thinking block `signature` fields with `signatureProvider: \"google\"` instead. Do not use in new code."
          },
          "chatCompletionReasoningField": {
            "type": "string",
            "enum": [
              "reasoning",
              "reasoning_content"
            ]
          },
          "chatCompletionReasoningContent": {
            "type": "string"
          },
          "geminiNativeContent": {
            "type": "string"
          },
          "isUserVisible": {
            "type": "boolean"
          },
          "isError": {
            "type": "boolean"
          },
          "modelId": {
            "type": "string"
          },
          "apiProvider": {
            "type": "string",
            "enum": [
              "bedrock",
              "anthropic",
              "vertex_anthropic",
              "bedrock_anthropic",
              "bedrock_converse",
              "bedrock_openai",
              "openai",
              "azure_openai",
              "azure_anthropic",
              "google",
              "xai",
              "mistral",
              "fireworks",
              "baseten",
              "together",
              "snowflake",
              "databricks"
            ]
          },
          "routerId": {
            "type": "string"
          },
          "reasoningEffort": {
            "type": "string",
            "enum": [
              "none",
              "dynamic",
              "off",
              "minimal",
              "low",
              "medium",
              "high",
              "xhigh",
              "max"
            ]
          },
          "hookEventName": {
            "type": "string"
          },
          "hookMatcher": {
            "type": "string"
          },
          "hookCommands": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "command": {
                  "type": "string"
                },
                "timeout": {
                  "type": "number"
                }
              },
              "required": [
                "command"
              ]
            }
          },
          "hookStatus": {
            "type": "string",
            "enum": [
              "executing",
              "completed",
              "error"
            ]
          },
          "hookResults": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "exitCode": {
                  "type": "number"
                },
                "stdout": {
                  "type": "string"
                },
                "stderr": {
                  "type": "string"
                },
                "suppressOutput": {
                  "type": "boolean"
                },
                "cancelled": {
                  "type": "boolean",
                  "enum": [
                    true
                  ],
                  "description": "The run's abort ended this hook before it exited; exitCode, stdout and stderr are the cancellation's, not the hook's."
                },
                "error": {
                  "type": "string",
                  "description": "Diagnostic for this hook alone, never its decision: why it failed (it could not run, timed out, printed JSON that does not parse or fails validation, or exited non-zero with plain-text stdout, or with any stdout where onFailure: \"block\" applies), or, for an exit 2, its stderr, else its plain-text stdout, else its exit code. A JSON block or deny alone does not create a diagnostic. Absent when the hook succeeded or was cancelled, and on rows recorded before this field existed even if the hook failed. A non-zero exitCode alone is not a failure: exit 1 with valid JSON output succeeds, except on a PreToolUse, PostToolUse, UserPromptSubmit or PreCompact hook with onFailure: \"block\", which fails on any exit other than 0 or 2."
                }
              },
              "required": [
                "exitCode",
                "stdout",
                "stderr"
              ]
            }
          },
          "hookToolCallId": {
            "type": "string"
          },
          "hookParentId": {
            "type": "string"
          },
          "hookOrder": {
            "type": "number"
          },
          "hookPreventedAction": {
            "type": "boolean"
          },
          "hiddenFromUserViews": {
            "type": "boolean"
          },
          "hookStartTime": {
            "type": "number",
            "description": "Unix timestamp, in milliseconds, when the hook started."
          },
          "hookEndTime": {
            "type": "number",
            "description": "Unix timestamp, in milliseconds, when the hook finished."
          },
          "isParallelExecution": {
            "type": "boolean"
          },
          "parallelGroupId": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "role",
          "content",
          "createdAt",
          "updatedAt"
        ]
      }
    },
    "pagination": {
      "type": "object",
      "properties": {
        "hasMore": {
          "type": "boolean",
          "description": "Whether there are more items after this page"
        },
        "nextCursor": {
          "type": "string",
          "nullable": true,
          "description": "Cursor to use for the next page, null if no more pages"
        }
      },
      "required": [
        "hasMore",
        "nextCursor"
      ]
    }
  },
  "required": [
    "messages",
    "pagination"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `504` - Response for status 504

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Add a message to a session

`POST /api/v0/sessions/{sessionId}/messages`

Adds a user message and returns once the computer accepts it. The agent turn runs asynchronously, so read `GET /api/v0/sessions/{sessionId}` and its messages to follow it. Supports text, images, and file attachments. This feature is enabled for selected organizations only.

```bash
curl -X POST 'https://api.factory.ai/api/v0/sessions/{sessionId}/messages' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{ ... }'
```

**Parameters**

- `sessionId` (`string`, required) - Path parameter
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Request body** (required)

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "text": {
      "type": "string",
      "description": "Message text content"
    },
    "images": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "base64"
            ]
          },
          "data": {
            "type": "string"
          },
          "mediaType": {
            "type": "string",
            "enum": [
              "image/jpeg",
              "image/png",
              "image/gif",
              "image/webp"
            ]
          }
        },
        "required": [
          "type",
          "data",
          "mediaType"
        ],
        "additionalProperties": false
      },
      "description": "Optional base64-encoded images"
    },
    "files": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "base64"
                ]
              },
              "mediaType": {
                "type": "string",
                "enum": [
                  "application/pdf"
                ]
              },
              "data": {
                "type": "string"
              },
              "parsedData": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "mediaType",
              "data"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "text"
                ]
              },
              "mediaType": {
                "type": "string",
                "enum": [
                  "text/plain"
                ]
              },
              "data": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "mime": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "mediaType",
              "data"
            ],
            "additionalProperties": false
          }
        ]
      },
      "description": "Optional file attachments (PDFs, text files)"
    },
    "computerId": {
      "type": "string",
      "description": "Computer ID to route the message to; falls back to the session.computerId if omitted"
    },
    "sender": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "orchestrator"
              ]
            },
            "sessionId": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "kind",
            "sessionId"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "agent"
              ]
            },
            "title": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120,
              "pattern": "^\\P{Cc}+$"
            },
            "sessionId": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "kind",
            "title",
            "sessionId"
          ],
          "additionalProperties": false
        }
      ],
      "description": "The mission session sending this message (the orchestrator, or an agent by name), stored on the message so clients can attribute it and the model sees a [From …] header. Omit for human messages."
    }
  },
  "required": [
    "text"
  ],
  "additionalProperties": false
}
```

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "messageId": {
      "type": "string",
      "description": "ID of the created user message"
    },
    "status": {
      "type": "string",
      "enum": [
        "idle",
        "pending",
        "running"
      ],
      "description": "Agent status after message submission"
    },
    "recipientDroidStatus": {
      "type": "string",
      "enum": [
        "idle",
        "pending",
        "running"
      ],
      "description": "The recipient's agent status before this message was submitted: idle means the message starts a turn now, running means it is queued behind the current turn. Omitted when the session was addressed by computerId."
    }
  },
  "required": [
    "messageId",
    "status"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `413` - Response for status 413

Content type: `application/json`

```json
{
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "description": "The platform edge refused a body over its own size limit before the route ran, and answered in JSON because the request accepts JSON, for example `{\"error\":{\"code\":\"413\",\"message\":\"Request Entity Too Large\"}}`.",
      "required": [
        "error"
      ],
      "properties": {
        "error": {
          "type": "object",
          "required": [
            "code",
            "message"
          ],
          "properties": {
            "code": {
              "type": "string"
            },
            "message": {
              "type": "string"
            }
          }
        }
      },
      "not": {
        "required": [
          "detail"
        ]
      }
    }
  ]
}
```

Content type: `text/plain`

```json
{
  "type": "string",
  "description": "The platform edge refused a body over its own size limit before the route ran, for example `Request Entity Too Large` followed by an error code such as `FUNCTION_PAYLOAD_TOO_LARGE`."
}
```

**Response:** `415` - Response for status 415

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "message": {
      "type": "string",
      "description": "Request validation error"
    },
    "errors": {
      "type": "array",
      "items": {},
      "description": "Framework validation issues, when available"
    }
  },
  "required": [
    "message"
  ]
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `504` - Response for status 504

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

## Get a message by ID

`GET /api/v0/sessions/{sessionId}/messages/{messageId}`

Returns a single message from the session by its ID. This feature is enabled for selected organizations only.

```bash
curl 'https://api.factory.ai/api/v0/sessions/{sessionId}/messages/{messageId}' \
  -H "Authorization: Bearer $FACTORY_BEARER_TOKEN"
```

**Parameters**

- `sessionId` (`string`, required) - Path parameter. Session ID
- `messageId` (`string`, required) - Path parameter. Message ID
- `computerId` (`string`) - Query parameter. Computer ID to query directly
- `X-Factory-Org-Id` (`string`) - Header parameter. Organization a JWT request acts in; required to act in a sub-organization. Without it, the request acts in the user's root organization, or is rejected with 403 when the user cannot access the root organization. API keys always act in their own organization and ignore this header.

**Response:** `200` - Response for status 200

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "role": {
      "type": "string",
      "enum": [
        "user",
        "assistant",
        "tool",
        "system"
      ]
    },
    "content": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "text"
                ]
              },
              "text": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "text"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "image"
                ]
              },
              "source": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "base64"
                    ]
                  },
                  "data": {
                    "type": "string"
                  },
                  "mediaType": {
                    "type": "string",
                    "enum": [
                      "image/jpeg",
                      "image/png",
                      "image/gif",
                      "image/webp"
                    ]
                  }
                },
                "required": [
                  "type",
                  "data",
                  "mediaType"
                ]
              },
              "elided": {
                "type": "object",
                "properties": {
                  "bytes": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "lines": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "width": {
                    "type": "integer",
                    "exclusiveMinimum": true,
                    "minimum": 0
                  },
                  "height": {
                    "type": "integer",
                    "exclusiveMinimum": true,
                    "minimum": 0
                  },
                  "preview": {
                    "type": "string"
                  }
                },
                "required": [
                  "bytes"
                ]
              },
              "generated": {
                "type": "boolean"
              }
            },
            "required": [
              "type",
              "source"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "thinking"
                ]
              },
              "signature": {
                "type": "string"
              },
              "signatureProvider": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "anthropic",
                      "openai",
                      "generic-chat-completion-api",
                      "factory",
                      "google",
                      "xai",
                      "bedrock-converse"
                    ]
                  },
                  {
                    "type": "string",
                    "enum": [
                      "unknown"
                    ]
                  }
                ]
              },
              "thinking": {
                "type": "string"
              },
              "durationMs": {
                "type": "number",
                "minimum": 0
              },
              "progressUpdate": {
                "type": "boolean"
              }
            },
            "required": [
              "type",
              "signature",
              "thinking"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "redacted_thinking"
                ]
              },
              "data": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "data"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "tool_use"
                ]
              },
              "id": {
                "type": "string"
              },
              "input": {
                "type": "object",
                "additionalProperties": {}
              },
              "name": {
                "type": "string"
              },
              "thoughtSignature": {
                "type": "string"
              },
              "namespace": {
                "type": "string"
              },
              "scriptExecution": {
                "type": "object",
                "properties": {
                  "runId": {
                    "type": "string"
                  },
                  "outerToolUseId": {
                    "type": "string"
                  },
                  "seen": {
                    "type": "number"
                  }
                },
                "required": [
                  "runId",
                  "outerToolUseId"
                ]
              },
              "scriptOracle": {
                "type": "object",
                "properties": {
                  "callCount": {
                    "type": "number"
                  },
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "site": {
                          "type": "number"
                        },
                        "toolName": {
                          "type": "string"
                        },
                        "path": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "input": {
                          "type": "object",
                          "additionalProperties": {}
                        },
                        "count": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "id",
                        "toolName",
                        "path",
                        "input",
                        "count"
                      ]
                    }
                  }
                },
                "required": [
                  "callCount",
                  "rows"
                ]
              }
            },
            "required": [
              "type",
              "id",
              "input",
              "name"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "tool_result"
                ]
              },
              "toolUseId": {
                "type": "string"
              },
              "content": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "text"
                              ]
                            },
                            "text": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "text"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "image"
                              ]
                            },
                            "source": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "base64"
                                  ]
                                },
                                "data": {
                                  "type": "string"
                                },
                                "mediaType": {
                                  "type": "string",
                                  "enum": [
                                    "image/jpeg",
                                    "image/png",
                                    "image/gif",
                                    "image/webp"
                                  ]
                                }
                              },
                              "required": [
                                "type",
                                "data",
                                "mediaType"
                              ]
                            },
                            "elided": {
                              "type": "object",
                              "properties": {
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "lines": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "width": {
                                  "type": "integer",
                                  "exclusiveMinimum": true,
                                  "minimum": 0
                                },
                                "height": {
                                  "type": "integer",
                                  "exclusiveMinimum": true,
                                  "minimum": 0
                                },
                                "preview": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "bytes"
                              ]
                            },
                            "generated": {
                              "type": "boolean"
                            }
                          },
                          "required": [
                            "type",
                            "source"
                          ]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "document"
                              ]
                            },
                            "source": {
                              "anyOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "base64"
                                      ]
                                    },
                                    "mediaType": {
                                      "type": "string",
                                      "enum": [
                                        "application/pdf"
                                      ]
                                    },
                                    "data": {
                                      "type": "string"
                                    },
                                    "parsedData": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "path": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "mediaType",
                                    "data"
                                  ]
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    "mediaType": {
                                      "type": "string",
                                      "enum": [
                                        "text/plain"
                                      ]
                                    },
                                    "data": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "mime": {
                                      "type": "string"
                                    }
                                  },
                                  "required": [
                                    "type",
                                    "mediaType",
                                    "data"
                                  ]
                                }
                              ]
                            },
                            "elided": {
                              "type": "object",
                              "properties": {
                                "bytes": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "lines": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "width": {
                                  "type": "integer",
                                  "exclusiveMinimum": true,
                                  "minimum": 0
                                },
                                "height": {
                                  "type": "integer",
                                  "exclusiveMinimum": true,
                                  "minimum": 0
                                },
                                "preview": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "bytes"
                              ]
                            }
                          },
                          "required": [
                            "type",
                            "source"
                          ]
                        }
                      ]
                    }
                  }
                ]
              },
              "elided": {
                "type": "object",
                "properties": {
                  "bytes": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "lines": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "width": {
                    "type": "integer",
                    "exclusiveMinimum": true,
                    "minimum": 0
                  },
                  "height": {
                    "type": "integer",
                    "exclusiveMinimum": true,
                    "minimum": 0
                  },
                  "preview": {
                    "type": "string"
                  }
                },
                "required": [
                  "bytes"
                ]
              },
              "isError": {
                "type": "boolean"
              },
              "modelContent": {
                "type": "string"
              },
              "respondedBy": {
                "type": "object",
                "properties": {
                  "userId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "web",
                      "desktop",
                      "cli_tui",
                      "cli_exec",
                      "cli_acp",
                      "slack",
                      "jira",
                      "linear",
                      "microsoft-teams",
                      "google-chat",
                      "sessions_api",
                      "api",
                      "sdk",
                      "automation",
                      "readiness-remediation",
                      "readiness-evaluation",
                      "wiki-generation",
                      "wiki-ci-setup"
                    ]
                  },
                  "receipt": {
                    "type": "string"
                  }
                },
                "required": [
                  "userId"
                ]
              },
              "modelOnly": {
                "type": "boolean"
              }
            },
            "required": [
              "type",
              "toolUseId"
            ]
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "document"
                ]
              },
              "source": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "base64"
                        ]
                      },
                      "mediaType": {
                        "type": "string",
                        "enum": [
                          "application/pdf"
                        ]
                      },
                      "data": {
                        "type": "string"
                      },
                      "parsedData": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "mediaType",
                      "data"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "text"
                        ]
                      },
                      "mediaType": {
                        "type": "string",
                        "enum": [
                          "text/plain"
                        ]
                      },
                      "data": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type",
                      "mediaType",
                      "data"
                    ]
                  }
                ]
              },
              "elided": {
                "type": "object",
                "properties": {
                  "bytes": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "lines": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "width": {
                    "type": "integer",
                    "exclusiveMinimum": true,
                    "minimum": 0
                  },
                  "height": {
                    "type": "integer",
                    "exclusiveMinimum": true,
                    "minimum": 0
                  },
                  "preview": {
                    "type": "string"
                  }
                },
                "required": [
                  "bytes"
                ]
              }
            },
            "required": [
              "type",
              "source"
            ]
          }
        ]
      }
    },
    "createdAt": {
      "type": "number",
      "description": "Unix timestamp, in milliseconds, when the message was created."
    },
    "updatedAt": {
      "type": "number",
      "description": "Unix timestamp, in milliseconds, when the message last changed."
    },
    "parentId": {
      "type": "string"
    },
    "seq": {
      "type": "integer",
      "minimum": 0
    },
    "userMessageSource": {
      "type": "string",
      "enum": [
        "web",
        "desktop",
        "cli_tui",
        "cli_exec",
        "cli_acp",
        "slack",
        "jira",
        "linear",
        "microsoft-teams",
        "google-chat",
        "sessions_api",
        "api",
        "sdk",
        "automation",
        "readiness-remediation",
        "readiness-evaluation",
        "wiki-generation",
        "wiki-ci-setup"
      ]
    },
    "sender": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "orchestrator"
              ]
            },
            "sessionId": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "kind",
            "sessionId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "agent"
              ]
            },
            "title": {
              "type": "string",
              "minLength": 1
            },
            "sessionId": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "kind",
            "title",
            "sessionId"
          ]
        }
      ]
    },
    "author": {
      "type": "object",
      "properties": {
        "userId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "source": {
          "type": "string",
          "enum": [
            "web",
            "desktop",
            "cli_tui",
            "cli_exec",
            "cli_acp",
            "slack",
            "jira",
            "linear",
            "microsoft-teams",
            "google-chat",
            "sessions_api",
            "api",
            "sdk",
            "automation",
            "readiness-remediation",
            "readiness-evaluation",
            "wiki-generation",
            "wiki-ci-setup"
          ]
        },
        "receipt": {
          "type": "string"
        }
      },
      "required": [
        "userId"
      ]
    },
    "docCommentThread": {
      "type": "object",
      "properties": {
        "threadId": {
          "type": "string",
          "format": "uuid"
        },
        "doc": {
          "anyOf": [
            {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "space"
                      ]
                    },
                    "spaceId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "documentId": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "kind",
                    "spaceId",
                    "documentId"
                  ]
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "enum": [
                        "local"
                      ]
                    },
                    "machineId": {
                      "type": "string",
                      "minLength": 1
                    },
                    "path": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "kind",
                    "machineId",
                    "path"
                  ]
                }
              ]
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "unknown"
                  ]
                },
                "reportedKind": {
                  "type": "string"
                }
              },
              "required": [
                "kind"
              ]
            }
          ]
        },
        "documentPath": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "threadId",
        "documentPath"
      ]
    },
    "mentions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "userId",
          "name"
        ]
      }
    },
    "interactionMode": {
      "type": "string",
      "enum": [
        "auto",
        "spec",
        "agi",
        "mission"
      ]
    },
    "visibility": {
      "type": "string",
      "enum": [
        "both",
        "llm_only",
        "user_only"
      ]
    },
    "systemNotice": {
      "type": "boolean",
      "enum": [
        true
      ],
      "description": "Marks a notice the harness wrote into the conversation, such as a provider error or a skill activation. The role is unchanged by it, so readers that predate the marker still show its text."
    },
    "hookRowId": {
      "type": "string",
      "description": "On a notice that repeats a hook's error: the id of the hook row that already shows the error. A client that draws that hook row can leave the notice out."
    },
    "endedEarly": {
      "type": "boolean",
      "enum": [
        true
      ],
      "description": "Marks an assistant message that ended early. When the session is loaded, a model-owned call of it that has no result is not run or resumed, unless a pending marker reserves that call or a message without the mark also makes it."
    },
    "openaiMessageId": {
      "type": "string"
    },
    "openaiPhase": {
      "type": "string",
      "enum": [
        "commentary",
        "final_answer",
        null
      ],
      "nullable": true
    },
    "openaiEncryptedContent": {
      "type": "string"
    },
    "openaiReasoningId": {
      "type": "string"
    },
    "openaiReasoningSummary": {
      "type": "string"
    },
    "geminiThoughtSignature": {
      "type": "string",
      "description": "@deprecated Use thinking block `signature` fields with `signatureProvider: \"google\"` instead. Do not use in new code."
    },
    "chatCompletionReasoningField": {
      "type": "string",
      "enum": [
        "reasoning",
        "reasoning_content"
      ]
    },
    "chatCompletionReasoningContent": {
      "type": "string"
    },
    "geminiNativeContent": {
      "type": "string"
    },
    "isUserVisible": {
      "type": "boolean"
    },
    "isError": {
      "type": "boolean"
    },
    "modelId": {
      "type": "string"
    },
    "apiProvider": {
      "type": "string",
      "enum": [
        "bedrock",
        "anthropic",
        "vertex_anthropic",
        "bedrock_anthropic",
        "bedrock_converse",
        "bedrock_openai",
        "openai",
        "azure_openai",
        "azure_anthropic",
        "google",
        "xai",
        "mistral",
        "fireworks",
        "baseten",
        "together",
        "snowflake",
        "databricks"
      ]
    },
    "routerId": {
      "type": "string"
    },
    "reasoningEffort": {
      "type": "string",
      "enum": [
        "none",
        "dynamic",
        "off",
        "minimal",
        "low",
        "medium",
        "high",
        "xhigh",
        "max"
      ]
    },
    "hookEventName": {
      "type": "string"
    },
    "hookMatcher": {
      "type": "string"
    },
    "hookCommands": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "command": {
            "type": "string"
          },
          "timeout": {
            "type": "number"
          }
        },
        "required": [
          "command"
        ]
      }
    },
    "hookStatus": {
      "type": "string",
      "enum": [
        "executing",
        "completed",
        "error"
      ]
    },
    "hookResults": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "exitCode": {
            "type": "number"
          },
          "stdout": {
            "type": "string"
          },
          "stderr": {
            "type": "string"
          },
          "suppressOutput": {
            "type": "boolean"
          },
          "cancelled": {
            "type": "boolean",
            "enum": [
              true
            ],
            "description": "The run's abort ended this hook before it exited; exitCode, stdout and stderr are the cancellation's, not the hook's."
          },
          "error": {
            "type": "string",
            "description": "Diagnostic for this hook alone, never its decision: why it failed (it could not run, timed out, printed JSON that does not parse or fails validation, or exited non-zero with plain-text stdout, or with any stdout where onFailure: \"block\" applies), or, for an exit 2, its stderr, else its plain-text stdout, else its exit code. A JSON block or deny alone does not create a diagnostic. Absent when the hook succeeded or was cancelled, and on rows recorded before this field existed even if the hook failed. A non-zero exitCode alone is not a failure: exit 1 with valid JSON output succeeds, except on a PreToolUse, PostToolUse, UserPromptSubmit or PreCompact hook with onFailure: \"block\", which fails on any exit other than 0 or 2."
          }
        },
        "required": [
          "exitCode",
          "stdout",
          "stderr"
        ]
      }
    },
    "hookToolCallId": {
      "type": "string"
    },
    "hookParentId": {
      "type": "string"
    },
    "hookOrder": {
      "type": "number"
    },
    "hookPreventedAction": {
      "type": "boolean"
    },
    "hiddenFromUserViews": {
      "type": "boolean"
    },
    "hookStartTime": {
      "type": "number",
      "description": "Unix timestamp, in milliseconds, when the hook started."
    },
    "hookEndTime": {
      "type": "number",
      "description": "Unix timestamp, in milliseconds, when the hook finished."
    },
    "isParallelExecution": {
      "type": "boolean"
    },
    "parallelGroupId": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "role",
    "content",
    "createdAt",
    "updatedAt"
  ]
}
```

**Response:** `400` - Response for status 400

Content type: `application/json`

```json
{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        },
        "error": {
          "type": "object",
          "properties": {
            "detail": {
              "type": "string",
              "description": "Human-readable error message"
            },
            "status": {
              "type": "number",
              "description": "HTTP status code"
            },
            "title": {
              "type": "string",
              "description": "HTTP status title"
            },
            "metadata": {
              "type": "object",
              "additionalProperties": {},
              "description": "Additional error metadata"
            },
            "requestId": {
              "type": "string",
              "description": "Request identifier to include when contacting support"
            },
            "code": {
              "type": "string",
              "description": "Stable machine-readable error code, when one applies"
            },
            "displayToUser": {
              "type": "boolean",
              "description": "True when detail is curated copy that is safe to show users"
            }
          },
          "required": [
            "detail",
            "status",
            "title"
          ],
          "description": "The same error fields, for clients that only read body.error"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "additionalProperties": true
    },
    {
      "type": "object",
      "properties": {
        "message": {
          "type": "string",
          "description": "Request validation error"
        },
        "errors": {
          "type": "array",
          "items": {},
          "description": "Framework validation issues, when available"
        }
      },
      "required": [
        "message"
      ]
    }
  ]
}
```

**Response:** `401` - Response for status 401

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `402` - Response for status 402

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `403` - Response for status 403

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `404` - Response for status 404

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `429` - Response for status 429

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `451` - Response for status 451

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `500` - Response for status 500

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```

**Response:** `503` - Response for status 503

Content type: `application/json`

```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "description": "Human-readable error message"
    },
    "status": {
      "type": "number",
      "description": "HTTP status code"
    },
    "title": {
      "type": "string",
      "description": "HTTP status title"
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {},
      "description": "Additional error metadata"
    },
    "requestId": {
      "type": "string",
      "description": "Request identifier to include when contacting support"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable error code, when one applies"
    },
    "displayToUser": {
      "type": "boolean",
      "description": "True when detail is curated copy that is safe to show users"
    },
    "error": {
      "type": "object",
      "properties": {
        "detail": {
          "type": "string",
          "description": "Human-readable error message"
        },
        "status": {
          "type": "number",
          "description": "HTTP status code"
        },
        "title": {
          "type": "string",
          "description": "HTTP status title"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {},
          "description": "Additional error metadata"
        },
        "requestId": {
          "type": "string",
          "description": "Request identifier to include when contacting support"
        },
        "code": {
          "type": "string",
          "description": "Stable machine-readable error code, when one applies"
        },
        "displayToUser": {
          "type": "boolean",
          "description": "True when detail is curated copy that is safe to show users"
        }
      },
      "required": [
        "detail",
        "status",
        "title"
      ],
      "description": "The same error fields, for clients that only read body.error"
    }
  },
  "required": [
    "detail",
    "status",
    "title"
  ],
  "additionalProperties": true
}
```
