Branch an agent chat from a message
Creates a new chat seeded from the source chat's history: branching from a user message copies everything before it and returns that message's text as `seed` to re-run, while branching from an assistant message copies through it. An optional `model` overrides the branch's model. Requires a Clerk session for a workspace member with the `ai:write` permission and the `ai.agent.enabled` control switched on; an unknown chat or message is reported as not found.
Authorization
apiKey Workspace API key created in Workspace settings → API keys. Scopes on the key bound what it can read and write.
In: header
Path Parameters
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
curl -X POST "https://example.com/v1/workspaces/string/agent/chats/string/branch" \ -H "Content-Type: application/json" \ -d '{ "fromMessageId": "string" }'{ "data": { "chat": { "id": "string", "workspaceId": "string", "title": "string", "parentSessionId": "string", "model": "string", "appearance": { "shape": "box", "color": "string", "accentColor": "string", "eyes": "dot", "eyePlacement": "centered", "motion": "still" }, "status": "idle", "runningMessageId": "string", "lastError": "string", "createdAt": "string", "updatedAt": "string" }, "seed": "string" }}{ "_tag": "ApiNotFound", "error": "not_found", "message": "That item does not exist, or this key cannot see it.", "status": 404}{ "_tag": "ApiNotFound", "error": "not_found", "message": "That item does not exist, or this key cannot see it.", "status": 404}Switch which version of a message is active
Points the chat's active thread at the latest leaf beneath the given message, so a regenerated or edited branch becomes the visible conversation, and returns the resulting transcript. Requires a Clerk session for a workspace member with the `ai:write` permission; an unknown chat or a message id that is not part of it is reported as not found.
Begin a direct multipart upload session
Validates the declared name, MIME type, size, and per-part checksums, checks the workspace storage quota, opens a multipart upload against the object store, and returns the session with one presigned URL per part and an expiry. Requires a workspace member with the `files:write` permission. Refused when the storage backend does not support direct uploads, when the declared metadata or part layout is invalid, or when the workspace is over its storage quota. Send an `Idempotency-Key` header to make retries safe; a replay within the window returns the original response.