Dokumentation
API ReferenceAPI Overview

API Overview

Programmatically interact with Fabric AI using our REST API.

Fabric AI provides a comprehensive REST API that lets you integrate AI-powered document generation, agent interactions, and workflow automation into your applications.

Base URL

All API requests are made to:

https://api.fabric.pro/v1

For self-hosted installations, replace with your instance URL.

Authentication

All API requests require authentication using a Bearer token:

curl -X GET https://api.fabric.pro/v1/agents \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Getting Your API Token

  1. Go to Settings → API Tokens
  2. Click Generate Token
  3. Give it a descriptive name
  4. Copy and store securely (shown only once)

Token Scopes

When creating a token, select appropriate scopes:

ScopePermissions
agents:readList and view agents
agents:writeCreate and update agents
conversations:readView conversations
conversations:writeCreate messages, start conversations
workspaces:readList and view workspaces
workspaces:writeUpload documents, manage workspaces
workflows:readView workflow status
workflows:writeStart and manage workflows

Quick Start

Start a Conversation

curl -X POST https://api.fabric.pro/v1/conversations \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "agent_abc123",
    "message": "Create a PRD for user authentication"
  }'

Response

{
  "id": "conv_xyz789",
  "agentId": "agent_abc123",
  "status": "active",
  "messages": [
    {
      "role": "user",
      "content": "Create a PRD for user authentication"
    },
    {
      "role": "assistant",
      "content": "# Product Requirements Document...",
      "streaming": true
    }
  ],
  "createdAt": "2024-01-15T10:30:00Z"
}

Core Endpoints

Agents

MethodEndpointDescription
GET/agentsList all agents
GET/agents/:idGet agent details
POST/agentsCreate a new agent
PUT/agents/:idUpdate an agent
DELETE/agents/:idDelete an agent

Conversations

MethodEndpointDescription
GET/conversationsList conversations
GET/conversations/:idGet conversation details
POST/conversationsStart new conversation
POST/conversations/:id/messagesAdd message
DELETE/conversations/:idDelete conversation

Workspaces

MethodEndpointDescription
GET/workspacesList workspaces
GET/workspaces/:idGet workspace details
POST/workspacesCreate workspace
POST/workspaces/:id/documentsUpload document
DELETE/workspaces/:idDelete workspace

Workflows

MethodEndpointDescription
GET/workflowsList workflows
GET/workflows/:idGet workflow status
POST/workflowsStart workflow
POST/workflows/:id/approveApprove pending step
POST/workflows/:id/cancelCancel workflow

Response Format

All responses follow a consistent format:

Success Response

{
  "data": {
    // Resource data
  },
  "meta": {
    "requestId": "req_abc123"
  }
}

Paginated Response

{
  "data": [
    // Array of resources
  ],
  "meta": {
    "total": 100,
    "page": 1,
    "perPage": 20,
    "requestId": "req_abc123"
  }
}

Error Response

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid agent ID format",
    "details": {
      "field": "agentId",
      "reason": "Must be a valid UUID"
    }
  },
  "meta": {
    "requestId": "req_abc123"
  }
}

Error Codes

CodeHTTP StatusDescription
UNAUTHORIZED401Invalid or missing token
FORBIDDEN403Token lacks required scope
NOT_FOUND404Resource not found
VALIDATION_ERROR400Invalid request data
RATE_LIMITED429Too many requests
INTERNAL_ERROR500Server error

Rate Limiting

API requests are rate limited:

  • Standard: 100 requests/minute
  • Enterprise: Custom limits

Rate limit headers are included in responses:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1705320600

Streaming Responses

For real-time agent responses, use Server-Sent Events (SSE):

curl -X POST https://api.fabric.pro/v1/conversations \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "agent_abc123",
    "message": "Create a PRD for notifications",
    "stream": true
  }'

SSE Events

event: message_start
data: {"id": "msg_123", "role": "assistant"}

event: content_delta
data: {"delta": "# Product Requirements"}

event: content_delta
data: {"delta": " Document\n\n## Overview"}

event: message_end
data: {"id": "msg_123", "status": "complete"}

Webhooks

Configure webhooks to receive real-time notifications:

Supported Events

EventDescription
conversation.createdNew conversation started
conversation.completedConversation finished
workflow.startedWorkflow execution began
workflow.completedWorkflow finished
workflow.approval_neededHuman approval required
document.uploadedDocument added to workspace

Webhook Payload

{
  "event": "workflow.completed",
  "timestamp": "2024-01-15T10:35:00Z",
  "data": {
    "workflowId": "wf_abc123",
    "status": "completed",
    "result": {
      // Workflow-specific data
    }
  }
}

Configuring Webhooks

  1. Go to Settings → Webhooks
  2. Click Add Webhook
  3. Enter your endpoint URL
  4. Select events to receive
  5. Save and verify

SDKs

Official SDKs are available for popular languages:

JavaScript/TypeScript

npm install @fabric-ai/sdk
import { FabricClient } from '@fabric-ai/sdk';

const fabric = new FabricClient({
  apiKey: process.env.FABRIC_API_KEY
});

const conversation = await fabric.conversations.create({
  agentId: 'agent_abc123',
  message: 'Create a PRD for user auth'
});

for await (const chunk of conversation.stream()) {
  console.log(chunk.content);
}

Python

pip install fabric-ai
from fabric_ai import FabricClient

fabric = FabricClient(api_key=os.environ["FABRIC_API_KEY"])

conversation = fabric.conversations.create(
    agent_id="agent_abc123",
    message="Create a PRD for user auth"
)

for chunk in conversation.stream():
    print(chunk.content)

Examples

Generate a Document

import { FabricClient } from '@fabric-ai/sdk';

const fabric = new FabricClient({ apiKey: 'YOUR_API_KEY' });

// Start conversation with Document Generator
const conv = await fabric.conversations.create({
  agentId: 'document-generator',
  workspaceIds: ['ws_templates'],
  message: `Create a PRD for a notification preferences feature.

    Requirements:
    - Email, push, and SMS channels
    - Quiet hours configuration
    - Frequency settings

    Target: Web and mobile apps`
});

// Wait for completion
const result = await conv.waitForCompletion();

// Export as markdown
const markdown = await fabric.documents.export(result.documentId, 'markdown');

Trigger a Workflow

// Start an automated workflow
const workflow = await fabric.workflows.create({
  template: 'prd-to-jira',
  inputs: {
    prdDocumentId: 'doc_xyz789',
    jiraProjectKey: 'PROJ',
    assignee: 'john@company.com'
  }
});

// Wait for approval step
await workflow.waitForEvent('approval_needed');

// Approve programmatically
await workflow.approve({
  stepId: 'create-stories',
  approver: 'api-automation'
});

Next Steps