Skip to main content

Agents

Agents (also called bots) are the core resource in Brainstormer. Each agent has a name, AI model, system prompt, linked knowledge bases, and configuration for streaming, voice, file uploads, and multimodal support.
All API requests require a valid JWT token in the Authorization: Bearer <token> header. The API Gateway decodes the JWT and forwards auth context (user-id, organization-id, user-email, x-platform-role, x-org-role) as headers to downstream services.

Create Agent

Create a new agent in your organization. Requires the member organization role or higher (platform superadmins always pass); a viewer gets 403.

Request Body

string
required
Agent name. 1-255 characters.
string
Agent description. Max 2000 characters.
string
AI model ID (e.g. openai/gpt-4o). If omitted, uses the platform default.
string
System prompt for the agent. Max 50,000 characters.
string[]
required
Array of knowledge base UUIDs to link to this agent, at most 100. At least one knowledge base is required when publishing (isDraft: false).Every id is validated before anything is written: the knowledge base must exist, belong to the agent’s organization, and be one you can edit (organization owners, admins and members can edit every knowledge base in their organization; a viewer needs an edit grant on it). If any id fails, the request is refused with 400 invalid_knowledge_base_ids and no agent is created.
boolean
default:"false"
If true, creates the agent as a draft. Draft agents do not need a linked knowledge base.
boolean
default:"true"
Enable streaming responses for chat.
boolean
default:"false"
Allow file uploads in chat.
boolean
default:"false"
Enable voice capabilities.
object
Voice configuration.
object
Multimodal input configuration.
object[]
Tool configurations for the agent.
object[]
Template variables for the system prompt.

Response (201)

boolean
Always true on success.
object
The created agent object.

Errors

error
One or more knowledgeBaseIds cannot be linked. A knowledge base that does not exist and one in another organization get the identical response, so this cannot be used to confirm that another organization’s knowledge base exists. Nothing was written.
error
The caller’s organization role is below member. Body: { "error": "Forbidden", "message": "Requires member role or higher" }.
error
The knowledge base access check could not be completed. Nothing was written; retry the request. Body carries error, code (both knowledge_base_check_unavailable) and message.
error
Returned when isDraft is false and the agent has no linked knowledge bases, or none of the linked knowledge bases have indexed documents. The response includes:

List Agents

List all agents in your organization.

Query Parameters

number
default:"50"
Maximum number of agents to return. 1-100.
string
Opaque keyset cursor. Pass the nextCursor from the previous page’s response to fetch the following page; omit it for the first page. A malformed cursor returns 400.This endpoint does not take an offset. Agents are ordered by creation time, which is not unique, and an offset addresses a page boundary by row count — so a tie, or an agent created or deleted while a client is paging, can silently skip a row or return one twice.
string
Filter by lifecycle status: draft or published. Omit to return every status, including archived.
Case-insensitive substring match on agent name or description. 1-200 chars.

Response (200)

object[]
Array of agent objects.
object
curl

Get Agent

Get a single agent by ID, including linked knowledge bases.

Path Parameters

string
required
Agent UUID.

Response (200)

Returns the full agent object plus:
object[]
Array of linked knowledge base objects with full details (name, description, document counts).
boolean
Whether the builtin:voice_input tool is on. Gates the microphone button in the chat UI.
boolean
Whether the builtin:file_upload tool is on. Gates the file-attach control.
string[] | null
What the agent’s model accepts as input, resolved from the model catalog: a subset of text, image, file, audio, video, in that order.Chat surfaces use it to withhold attachment types the model cannot read — a model without image is not offered images, and one with neither image nor file is not offered attachments at all.null means unknown, not “accepts nothing”. It is returned when the model has no catalog row or its capabilities could not be read, and a client must then restrict nothing: refusing an upload on the strength of absent data disables a feature that works.
curl

Update Agent

Update an existing agent. All fields are optional — only provided fields are updated.

Path Parameters

string
required
Agent UUID.

Request Body

Same fields as Create Agent, but all are optional.
If you include knowledgeBaseIds, the entire set of linked KBs is replaced. Sending an empty array [] will unlink all knowledge bases.
knowledgeBaseIds is validated against the agent’s organization before anything is written. Every id must exist and belong to that organization. A link you add or remove must be to a knowledge base you can edit; a link that is already there and stays is not re-checked, so re-saving an agent’s existing knowledge needs no edit access to each knowledge base.

Response (200)

Returns the updated agent object.

Errors

error
Same body as on Create Agent. The agent and its links are left unchanged.
error
The knowledge base access check could not be completed. Nothing was written.
error
Returned when isDraft is set to false and the agent has no linked knowledge bases, or none of the linked knowledge bases have indexed documents yet.
curl

Delete Agent

Soft-delete an agent (sets deleted_at; conversations are retained). The agent stops appearing in active listings. Requires delete on the agent. Writes an agent.delete audit entry under the agent’s own organization. Linked knowledge bases are not deleted — see Agent Delete Impact for what a delete stops and how the dashboard deletes chosen knowledge bases with it.

Path Parameters

string
required
Agent UUID.

Response (204)

No content on success.
curl

Get Agent Usage

Get usage statistics for an agent (conversations, messages, token usage, costs).

Path Parameters

string
required
Agent UUID.

Response (200)

Returns usage statistics including conversation counts, message counts, total tokens, and estimated cost.

Version History

Get version history for an agent. Every update creates a new version snapshot.

Path Parameters

string
required
Agent UUID.

Response (200)

object[]
Array of version snapshots, newest first.
number
Total number of versions.

Revert to Version

Revert an agent’s configuration to a specific version. This creates a new version (does not rewrite history).

Path Parameters

string
required
Agent UUID.
number
required
Version number to revert to.

Response (200)

boolean
Always true.
object
Updated agent object.
string
Confirmation message.

Get Draft Status

Get the current publish/draft status of an agent, including any pending review.

Path Parameters

string
required
Agent UUID.

Publishing Lifecycle

Agents follow a publish lifecycle: draft -> submitted for review -> approved/rejected -> published.

Submit for Review

Submit a draft agent for review.

Approve Agent

Approve a submitted agent (requires appropriate role).

Reject Agent

Reject a submitted agent with feedback.

Publish Agent

Publish an approved agent, making it available to end users.

Errors

error
Returned when the agent has no linked knowledge bases, or none of the linked knowledge bases have indexed documents yet.

Get Agent Indexing Status

Returns the indexing status of all knowledge bases linked to this agent. Use this to check whether the agent is ready to be published.

Path Parameters

string
required
Agent UUID.

Response (200)

number
Number of knowledge bases linked to the agent.
number
Total documents across all linked knowledge bases.
number
Documents with processing_status = completed.
number
Documents that failed processing.
number
Documents still pending or processing.
boolean
true when at least one knowledge base is linked and at least one document is indexed.
curl

RBAC Permissions

All agent endpoints enforce role-based access control: