Documentation/API Reference
DOCUMENTATION

API Reference

Integrate BeforeQuery into your product with the Search and Chat APIs. Programmatically manage projects, trigger syncs, and retrieve analytics.

Authentication

The BeforeQuery API uses Bearer token authentication. Include your API key in the Authorization header:

Authorization: Bearer bq_live_your_api_key_here

Getting Your API Key

  1. Log in to your BeforeQuery dashboard
  2. Navigate to Settings → API Keys
  3. Click "Create New Key" and choose a name
  4. Copy the key and store it securely — it is shown once

Base URL

https://api.beforequery.com/v1

All API requests use this base URL. Responses are JSON. The Chat API supports server-sent events (SSE) streaming — add Accept: text/event-stream to enable.

Chat API Example

REQUEST — POST /v1/chat
{
  "project_id": "proj_abc123",
  "question": "How do I rate-limit the API?",
  "session_id": "sess_xyz",
  "stream": false
}
RESPONSE
{
  "answer": "Use the X-RateLimit-Limit and
X-RateLimit-Remaining headers to track
your quota...",
  "citations": [
    {
      "title": "Rate Limiting",
      "url": "https://docs.example.com/rate",
      "excerpt": "All API calls are subject..."
    }
  ],
  "confidence": 0.94,
  "session_id": "sess_xyz"
}

Search API Example

REQUEST — POST /v1/search
{
  "project_id": "proj_abc123",
  "query": "authentication API key",
  "limit": 5,
  "mode": "hybrid"
}
RESPONSE
{
  "results": [
    {
      "title": "Authentication",
      "url": "https://docs.example.com/auth",
      "excerpt": "Pass your API key as...",
      "score": 0.97
    }
  ],
  "total": 5
}

All Endpoints

POST/v1/chat
POST/v1/search
GET/v1/projects
POST/v1/projects
GET/v1/projects/:id
POST/v1/projects/:id/sync
GET/v1/projects/:id/analytics
POST/v1/sources
DELETE/v1/sources/:id
POST/mcp/projects/:projectId

MCP Server

Every BeforeQuery project exposes a Model Context Protocol (MCP) server. Any MCP-aware AI application — IDEs like Cursor and Windsurf, Claude Desktop, or your own LLM — can query your knowledge base as structured tools.

POST https://api.beforequery.com/mcp/projects/:projectId
X-Client-Key: bq_pk_your_client_key_here

The MCP server is available on Pro and Enterprise plans. Activate it in your project settings. Once active, use any MCP client to list available tools and issue queries against your indexed knowledge.

@beforequery/agents SDK

The open-source @beforequery/agents TypeScript package provides typed primitives for building agent workflows that call the BeforeQuery API, MCP servers, and external A2A agents.

npm install @beforequery/agents import { runAgent, defineAgent } from "@beforequery/agents"; const result = await runAgent({ projectId: "proj_abc123", input: "What is our refund policy?", });

See the Agent Platform page for full graph definition examples including multi-agent graphs, human-approval nodes, and MCP tool integration.

Rate Limits

Free Plan

60

API calls per minute

Pro Plan

600

API calls per minute

Enterprise

Custom

contact sales

Need Help?

Can't find what you're looking for? Our team is here to help.

Contact Support