openapi: 3.0.3 info: title: Brainfish Public Agents Catalogs API description: "The Brainfish API is organized around REST. Our API has predictable resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.\n\nUse the Brainfish API to programmatically manage your knowledge base, generate AI-powered answers, and integrate Brainfish capabilities into your applications.\n\n---\n\n## Just Getting Started?\n\nCheck out our [Help documentation](https://help.brainfi.sh) for guides and tutorials.\n\n---\n\n## Base URL\n\n```\nhttps://api.brainfi.sh\n```\n\nAll API requests must be made over HTTPS. Calls made over plain HTTP will fail.\n\n---\n\n## Authentication\n\nThe Brainfish API uses API tokens to authenticate requests. You can view and manage your API tokens in your [Brainfish Dashboard](https://app.brainfi.sh) under **Settings → API Tokens**.\n\nAPI tokens have the prefix `bf_api_`. Your API tokens carry many privileges, so be sure to keep them secure! Do not share your API tokens in publicly accessible areas such as GitHub, client-side code, and so forth.\n\nAll API requests must include authentication. Requests without authentication will fail.\n\n| Header | Description |\n|--------|-------------|\n| `Authorization` | Bearer token authentication: `Bearer bf_api_xxxxx` |\n| `agent-key` | Required for AI Agent endpoints only. Find this in your Agents page. |\n\n**Example: Authenticated Request**\n\n```bash\ncurl https://api.brainfi.sh/v1/auth/validate \\\n -X POST \\\n -H \"Authorization: Bearer bf_api_xxxxx\" \\\n -H \"Content-Type: application/json\"\n```\n\n---\n\n## Errors\n\nBrainfish uses conventional HTTP response codes to indicate the success or failure of an API request.\n\n| Code | Description |\n|------|-------------|\n| `2xx` | Success — The request was successful. |\n| `4xx` | Client Error — The request failed due to client-side issues (e.g., missing required parameter, invalid authentication, resource not found). |\n| `5xx` | Server Error — Something went wrong on Brainfish's servers (these are rare). |\n\n**Error Response Format**\n\n```json\n{\n \"error\": \"validation_failed\",\n \"message\": \"Request validation failed\",\n \"validationErrors\": [\n {\n \"field\": \"query\",\n \"message\": \"Query cannot be empty\",\n \"code\": \"invalid_string\"\n }\n ],\n \"timestamp\": \"2024-01-15T10:30:00Z\",\n \"requestId\": \"req-abc123\"\n}\n```\n\nThe `requestId` can be provided to Brainfish support when troubleshooting issues.\n\n---\n\n## Rate Limiting\n\nThe API implements rate limiting to ensure fair usage and system stability.\n\n| Endpoint Type | Limit |\n|---------------|-------|\n| Most endpoints | 25 requests per minute |\n| Token revocation | 10 requests per hour |\n\nWhen you exceed the rate limit, the API returns a `429 Too Many Requests` response with headers indicating when you can retry:\n\n- `X-RateLimit-Limit`: Maximum requests allowed in the window\n- `X-RateLimit-Remaining`: Remaining requests in current window\n- `X-RateLimit-Reset`: Unix timestamp when the rate limit resets\n\n---\n\n## Available Resources\n\n| Resource | Description |\n|----------|-------------|\n| **Authentication** | Validate and revoke API tokens |\n| **AI Agents** | Generate streaming AI-powered answers from your knowledge base |\n| **Analytics** | Query conversation thread analytics with filtering and pagination |\n| **Conversations** | Generate follow-up questions for conversations |\n| **Collections** | Organize documents into collections |\n| **Catalogs** | Create catalogs and sync content via API |\n| **Documents** | Create, read, update, and delete documents |\n\n---\n\n## Quick Start\n\n**1. Create an API token** in your Brainfish dashboard under Settings → API Tokens.\n\n**2. Validate your token** to ensure it's working:\n\n```bash\ncurl https://api.brainfi.sh/v1/auth/validate \\\n -X POST \\\n -H \"Authorization: Bearer bf_api_xxxxx\" \\\n -H \"Content-Type: application/json\"\n```\n\n**3. For AI endpoints**, get your agent key from the Agents page.\n\n**4. Generate an AI answer**:\n\n```bash\ncurl https://api.brainfi.sh/v1/agents/answer \\\n -X POST \\\n -H \"Authorization: Bearer bf_api_xxxxx\" \\\n -H \"agent-key: your-agent-key\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\"query\": \"How do I reset my password?\"}'\n```\n\n---\n\n## Pagination\n\nList endpoints support pagination using `limit` and `offset` parameters:\n\n| Parameter | Description | Default |\n|-----------|-------------|---------|\n| `limit` | Maximum number of results to return (1-100) | 25 |\n| `offset` | Number of results to skip | 0 |\n\nPaginated responses include a `pagination` object:\n\n```json\n{\n \"data\": [...],\n \"pagination\": {\n \"offset\": 0,\n \"limit\": 25,\n \"total\": 42\n }\n}\n```\n" version: 1.0.0 contact: name: Brainfish API Support email: support@brainfish.ai url: https://help.brainfi.sh/articles/api-reference-7mjzVCAmeM license: name: Proprietary servers: - url: https://api.brainfi.sh description: Production server tags: - name: Catalogs description: Catalog management operations. Create catalogs and sync content programmatically via the API. paths: /v1/catalogs: get: summary: List catalogs description: 'List all catalogs for the authenticated user''s team. Supports filtering by source type and status, with pagination. ' operationId: listCatalogs tags: - Catalogs security: - BearerAuth: [] parameters: - name: source in: query description: Filter by catalog source type schema: type: string enum: - cms - website - zendesk - github - discovery - helpscout - readme - readmev2 - oas - notion - intercom - freshdesk - helpjuice - googledrive - confluence - guru - external - name: status in: query description: Filter by catalog status schema: type: string enum: - inprogress - completed - failed - name: limit in: query description: Maximum number of results to return (1-100) schema: type: integer minimum: 1 maximum: 100 default: 25 - name: offset in: query description: Offset for pagination schema: type: integer minimum: 0 default: 0 responses: '200': description: List of catalogs content: application/json: schema: $ref: '#/components/schemas/CatalogListResponse' example: data: - id: cat-123 name: Developer Docs source: external status: completed enabled: true contentCount: 42 createdAt: '2024-01-10T08:00:00Z' updatedAt: '2024-01-15T10:30:00Z' pagination: offset: 0 limit: 25 total: 3 timestamp: '2024-01-15T10:30:00Z' '401': $ref: '#/components/responses/Unauthorized' '429': $ref: '#/components/responses/TooManyRequests' '500': $ref: '#/components/responses/InternalServerError' post: summary: Create catalog description: 'Create a new catalog. A catalog is a container for content that can be synced via the API. After creating a catalog, use the sync endpoint (`POST /v1/catalogs/{id}/content`) to push content into it. ' operationId: createCatalog tags: - Catalogs security: - BearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateCatalogRequest' examples: externalCatalog: summary: Create an external catalog value: name: Developer Documentation source: external slug: dev-docs customConfig: summary: Create catalog with custom configuration value: name: Internal Wiki source: external slug: internal-wiki configurations: repo: acme/docs branch: main responses: '200': description: Catalog created successfully content: application/json: schema: $ref: '#/components/schemas/CatalogResponse' example: data: id: cat-123 name: Developer Documentation source: external status: inprogress enabled: true createdAt: '2024-01-15T10:30:00Z' updatedAt: '2024-01-15T10:30:00Z' timestamp: '2024-01-15T10:30:00Z' '401': $ref: '#/components/responses/Unauthorized' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/TooManyRequests' '500': $ref: '#/components/responses/InternalServerError' /v1/catalogs/{id}: get: summary: Get catalog description: 'Retrieve a catalog by its ID, including a count of content entries. ' operationId: getCatalog tags: - Catalogs security: - BearerAuth: [] parameters: - name: id in: path required: true description: Catalog ID (UUID) schema: type: string format: uuid responses: '200': description: Catalog details with content count content: application/json: schema: $ref: '#/components/schemas/CatalogDetailResponse' example: data: id: cat-123 name: Developer Documentation source: external status: completed enabled: true contentCount: 42 createdAt: '2024-01-10T08:00:00Z' updatedAt: '2024-01-15T10:30:00Z' timestamp: '2024-01-15T10:30:00Z' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' '429': $ref: '#/components/responses/TooManyRequests' '500': $ref: '#/components/responses/InternalServerError' /v1/catalogs/{id}/content: post: summary: Sync content to catalog description: 'Sync content files to a catalog. This performs a **full sync**: - **New files** are created as catalog content entries - **Changed files** (different content or title) are updated - **Missing files** (present in catalog but not in request) are removed Each file is identified by its `url`, which acts as a unique key within the catalog. This endpoint is designed for large documentation sets (1000+ files) and uses batched database operations for performance. ' operationId: syncCatalogContent tags: - Catalogs security: - BearerAuth: [] parameters: - name: id in: path required: true description: Catalog ID (UUID) schema: type: string format: uuid requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SyncCatalogContentRequest' examples: simpleSync: summary: Sync markdown documentation value: files: - url: https://docs.acme.com/getting-started content: '# Getting Started Welcome to our docs...' title: Getting Started - url: https://docs.acme.com/guides/authentication content: '# Authentication Learn how to authenticate...' title: Authentication - url: https://docs.acme.com/api/endpoints content: '# API Endpoints Available endpoints...' title: API Endpoints responses: '200': description: Content synced successfully content: application/json: schema: $ref: '#/components/schemas/SyncCatalogContentResponse' example: data: id: cat-123 name: Developer Documentation source: external status: completed contentCount: 3 created: 2 updated: 1 removed: 0 timestamp: '2024-01-15T10:30:00Z' '401': $ref: '#/components/responses/Unauthorized' '404': $ref: '#/components/responses/NotFound' '422': $ref: '#/components/responses/UnprocessableEntity' '429': $ref: '#/components/responses/TooManyRequests' '500': $ref: '#/components/responses/InternalServerError' components: schemas: CatalogResponse: type: object required: - data - timestamp properties: data: $ref: '#/components/schemas/Catalog' timestamp: type: string format: date-time description: Response timestamp CreateCatalogRequest: type: object required: - name - source properties: name: type: string description: Catalog name minLength: 1 maxLength: 255 example: Developer Documentation source: type: string description: Catalog source type enum: - cms - website - zendesk - github - discovery - helpscout - readme - readmev2 - oas - notion - intercom - freshdesk - helpjuice - googledrive - confluence - guru - external example: external slug: type: string description: Unique slug for this catalog (used as an external identifier) minLength: 1 maxLength: 100 example: dev-docs configurations: type: object additionalProperties: true description: Optional source-specific configuration CatalogDetailResponse: type: object required: - data - timestamp properties: data: $ref: '#/components/schemas/CatalogWithCount' timestamp: type: string format: date-time description: Response timestamp SyncCatalogContentRequest: type: object required: - files properties: files: type: array minItems: 1 description: Content files to sync items: type: object required: - url - content - title properties: url: type: string minLength: 1 description: URL or path used as unique identifier within the catalog example: https://docs.acme.com/getting-started content: type: string description: File content (Markdown, MDX, plain text, etc.) example: '# Getting Started Welcome to our docs...' title: type: string minLength: 1 description: Content title example: Getting Started Catalog: type: object required: - id - name - source - status properties: id: type: string format: uuid description: Unique catalog identifier example: cat-123 teamId: type: string format: uuid description: Team ID the catalog belongs to name: type: string description: Catalog name example: Developer Documentation source: type: string description: Catalog source type example: external status: type: string enum: - inprogress - completed - failed description: Current sync status example: completed enabled: type: boolean description: Whether the catalog is enabled example: true dailySync: type: boolean description: Whether daily sync is enabled example: false configurations: type: object additionalProperties: true description: Source-specific configuration (API keys are masked) createdBy: type: string format: uuid description: ID of the user who created the catalog createdAt: type: string format: date-time description: Creation timestamp updatedAt: type: string format: date-time description: Last update timestamp lastSyncError: type: string nullable: true description: Last sync error message, if any Error: type: object required: - error - message properties: error: type: string description: Error type or code message: type: string description: Human-readable error message details: type: object additionalProperties: true description: Additional error details timestamp: type: string format: date-time description: Error timestamp requestId: type: string description: Unique request identifier for debugging ValidationError: allOf: - $ref: '#/components/schemas/Error' - type: object properties: validationErrors: type: array items: type: object properties: field: type: string description: Field that failed validation message: type: string description: Validation error message code: type: string description: Validation error code SyncCatalogContentResponse: type: object required: - data - timestamp properties: data: allOf: - $ref: '#/components/schemas/CatalogWithCount' - type: object properties: created: type: integer description: Number of new content entries created example: 2 updated: type: integer description: Number of existing content entries updated example: 1 removed: type: integer description: Number of stale content entries removed example: 0 timestamp: type: string format: date-time description: Response timestamp CatalogWithCount: allOf: - $ref: '#/components/schemas/Catalog' - type: object properties: contentCount: type: integer description: Number of content entries in the catalog example: 42 CatalogListResponse: type: object required: - data - pagination - timestamp properties: data: type: array items: $ref: '#/components/schemas/CatalogWithCount' pagination: type: object required: - offset - limit - total properties: offset: type: integer example: 0 limit: type: integer example: 25 total: type: integer example: 3 timestamp: type: string format: date-time description: Response timestamp responses: Unauthorized: description: Authentication required or invalid credentials content: application/json: schema: $ref: '#/components/schemas/Error' examples: missingToken: summary: Missing authentication token value: error: authentication_required message: 'Authentication required. Use Authorization: Bearer header' timestamp: '2024-01-15T10:30:00Z' requestId: req-abc123 missingAgentKey: summary: Missing agent key value: error: authentication_required message: Agent key is required timestamp: '2024-01-15T10:30:00Z' requestId: req-def456 invalidCredentials: summary: Invalid credentials value: error: authentication_required message: Invalid or missing authentication credentials timestamp: '2024-01-15T10:30:00Z' requestId: req-ghi789 TooManyRequests: description: Rate limit exceeded headers: X-RateLimit-Limit: schema: type: integer description: Request limit per time window X-RateLimit-Remaining: schema: type: integer description: Remaining requests in current window X-RateLimit-Reset: schema: type: integer description: Time when rate limit resets (Unix timestamp) content: application/json: schema: $ref: '#/components/schemas/Error' example: error: rate_limit_exceeded message: 'Too many requests. Rate limit: 25 requests per minute' timestamp: '2024-01-15T10:30:00Z' NotFound: description: Resource not found content: application/json: schema: $ref: '#/components/schemas/Error' example: error: not_found message: Document not found timestamp: '2024-01-15T10:30:00Z' requestId: req-notfound123 UnprocessableEntity: description: Invalid request format or unknown message type content: application/json: schema: $ref: '#/components/schemas/ValidationError' examples: emptyQuery: summary: Empty query validation error value: error: validation_failed message: Request validation failed validationErrors: - field: query message: Query cannot be empty code: invalid_string timestamp: '2024-01-15T10:30:00Z' requestId: req-val123 invalidConversationId: summary: Invalid conversation ID format value: error: validation_failed message: Request validation failed validationErrors: - field: conversationId message: Invalid conversation ID format code: invalid_string timestamp: '2024-01-15T10:30:00Z' requestId: req-val456 queryTooLong: summary: Query exceeds maximum length value: error: validation_failed message: Request validation failed validationErrors: - field: query message: Query must be 2000 characters or less code: too_big timestamp: '2024-01-15T10:30:00Z' requestId: req-val789 InternalServerError: description: Internal server error content: application/json: schema: $ref: '#/components/schemas/Error' example: error: internal_error message: An unexpected error occurred requestId: req-abc123 timestamp: '2024-01-15T10:30:00Z' securitySchemes: BearerAuth: type: http scheme: bearer bearerFormat: API Token description: 'Bearer token authentication. Include your API token in the Authorization header. Example: `Authorization: Bearer bf_api_xxxxx` Create tokens in your Brainfish dashboard under Settings → API Tokens. ' AccessToken: type: apiKey in: header name: access-token description: '**Deprecated**: Use Bearer authentication instead. Legacy access token header for backward compatibility. Must start with `bf_api_`. Create tokens in your Brainfish dashboard under Settings → API Tokens. ' AgentKey: type: apiKey in: header name: agent-key description: 'Agent key identifier that specifies which AI agent/widget to use for the request. Find agent keys in your Brainfish dashboard under Agents. Click on any agent key to copy it. '