Steadybase
API Reference

Brain API

Conversational AI chat interface powered by Claude CLI.

Brain API

The Brain API provides a conversational AI interface powered by Claude CLI. It maintains conversation history, injects context from memory and active workflows, and isolates chats per user.

Endpoints

Send Message

POST /api/brain/chat

Send a message to the Brain and receive an AI response.

Request:

{
  "message": "What deals are in the pipeline for Q1?"
}

Response:

{
  "response": "Based on the current pipeline, here are the Q1 deals:\n\n1. **Acme Corp** - $2.1M ARR (Negotiation)\n2. **Stripe** - $9.2M ARR (Active)\n...",
  "conversationId": "conv-a1b2c3",
  "tokensUsed": 1247
}

How it works:

  1. Retrieves the user's conversation history
  2. Injects context from hierarchical memory (org, team, worker scopes)
  3. Sends the full context + message to Claude CLI
  4. Stores the response in conversation history
  5. Returns the AI response

:::note Chat history is per-user isolated. Each authenticated user has their own conversation thread. :::

Get History

GET /api/brain/history

Retrieve the authenticated user's conversation history.

Response:

{
  "messages": [
    {
      "role": "user",
      "content": "What deals are in the pipeline?",
      "timestamp": "2026-03-04T10:00:00Z"
    },
    {
      "role": "assistant",
      "content": "Based on the current pipeline...",
      "timestamp": "2026-03-04T10:00:02Z"
    }
  ]
}

Clear History

DELETE /api/brain/history

Clear the authenticated user's conversation history.

Response:

{
  "status": "ok",
  "message": "Conversation history cleared"
}

Context Injection

The Brain doesn't just answer from the model's training data. Before each response, it loads:

Context SourceScopeExample
Organization memoryGlobalICP definition, pipeline totals
Team memoryTeam-scopedTerritory assignments, campaigns
Active workflowsReal-timeRunning workflow statuses
Conversation historyPer-userPrevious messages in this thread

This means the Brain can answer questions like "What's Sarah working on right now?" by checking active workflows and worker status.

On this page