Skip to main content

Quick Start Guide

This guide will help you make your first API call to DocBit AI.

Prerequisites

  • Your API key (provided by DocBit AI)
  • A client organization ID (your internal identifier)
  • A user ID (your user’s identifier)

Step 1: Set Up Your Headers

Every request requires these headers:
Authorization: ApiKey sk_yourpartner_abc123...
X-External-Org-Id: acme
X-External-User-Id: user-456
X-External-Roles: ["employee"]
HeaderDescription
AuthorizationYour API key with ApiKey prefix
X-External-Org-IdIdentifies which of your clients this request is for
X-External-User-IdIdentifies the specific user making the request
X-External-RolesJSON array of roles for access control

Step 2: Send a Chat Request

curl -X POST https://api.docbit.ai/api/ai/chat \
  -H "Authorization: ApiKey sk_yourpartner_abc123..." \
  -H "X-External-Org-Id: acme" \
  -H "X-External-User-Id: user-456" \
  -H "X-External-Roles: [\"employee\"]" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "What is the vacation policy?"
  }'

Step 3: Handle the Response

{
  "conversationId": "550e8400-e29b-41d4-a716-446655440000",
  "content": "According to the Employee Handbook, the vacation policy provides 15 days of paid vacation per year for full-time employees...",
  "citations": [
    {
      "documentId": "doc-123",
      "documentTitle": "Employee Handbook",
      "page": 12,
      "section": "Time Off Policies",
      "excerpt": "Full-time employees are entitled to 15 days..."
    }
  ],
  "confidence": "High"
}

Step 4: Upload Documents

Before chat can work, you need documents in the system:
curl -X POST https://api.docbit.ai/api/documents/upload \
  -H "Authorization: ApiKey sk_yourpartner_abc123..." \
  -H "X-External-Org-Id: acme" \
  -H "X-External-User-Id: admin-1" \
  -H "X-External-Roles: [\"admin\"]" \
  -F "[email protected]" \
  -F "aclRoles=employee"

Complete Example

Here’s a complete Node.js example:
const axios = require('axios');

const API_KEY = 'sk_yourpartner_abc123...';
const BASE_URL = 'https://api.docbit.ai';

async function askQuestion(orgId, userId, roles, question) {
  const response = await axios.post(
    `${BASE_URL}/api/ai/chat`,
    { message: question },
    {
      headers: {
        'Authorization': `ApiKey ${API_KEY}`,
        'X-External-Org-Id': orgId,
        'X-External-User-Id': userId,
        'X-External-Roles': JSON.stringify(roles),
        'Content-Type': 'application/json'
      }
    }
  );
  
  return response.data;
}

// Usage
const answer = await askQuestion(
  'acme',
  'user-456',
  ['employee'],
  'What is the vacation policy?'
);

console.log(answer.content);

Next Steps