Documentation
Everything you need to get started with FAQai.app.
API Reference
Programmatic access to FAQai.app. Available on Basic, Starter and Pro plans.
Authentication
All API requests require an API key passed in the Authorization header as a Bearer token.
Create and manage your API keys from Settings → API Keys.
Authorization: Bearer faq_YOUR_API_KEY
Keep your API keys safe
API keys are shown only once at creation time. Store them in an environment variable or secrets manager. Never expose keys in client-side code or public repositories.
Base URL
https://<your-domain>/api/v1
Replace <your-domain> with your deployment domain (e.g. faqai.app). All endpoints below are relative to this base URL. Responses are JSON with Content-Type: application/json.
Rate Limits
| Plan | Requests / min | API calls / month | Pages / month | Playground msgs / month |
|---|---|---|---|---|
| Free | - | - | 10 | 5 |
| Basic | 10 | 500 | 1,000 | 200 |
| Starter | 10 | 1,000 | 2,000 | 500 |
| Pro | 30 | 3,000 | 6,000 | 1,500 |
Rate limit headers X-RateLimit-Remaining and Retry-After are included in every response.
Paid plans can purchase overage page packs that also add bonus RAG Playground messages: Small (+500), Medium (+1,500), Large (+3,000). Bonus messages are valid for the current billing cycle.
POSTUpload a Document
POST /v1/documents
Upload a file for dataset generation. Send the file as multipart/form-data.
Important: Direct uploads are limited to 4.5 MB due to serverless infrastructure constraints. For larger files, use the large file upload options (SDK or upload endpoint) — they handle any size automatically.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| file | File | Yes | PDF, DOCX, TXT, or MD. Size limit varies by plan. |
| name | string | No | Custom document name. Defaults to the filename. |
| auto_process | boolean | No | Automatically generate dataset after upload. Defaults to true. |
| generation_context | string | No | Audience/use-case steering for dataset generation (paid plans, max 500 chars). A preset id (customer_support_bot, internal_knowledge_base, developer_docs_assistant, sales_enablement, compliance_legal) or free text. |
| chunking | string | object | No | Chunking profile: a preset name (balanced ~400 tokens, fine_grained ~200, large_context ~800) or a JSON object with custom values (paid plans): {"target_tokens": 128-2048, "overlap_pct": 0-25, "strategy": "heading_aware" | "fixed_size" | "paragraph"}. |
| contextual_enrichment | boolean | No | Beta Enrich each RAG chunk with an AI context header and hypothetical questions for better retrieval (paid plans). Applies to the RAG dataset path and consumes enrichment units from your monthly quota. When enabled, chunk exports carry context_header and hypothetical_questions, and embedding_text is prefixed with the header. |
Example Request (cURL)
curl -X POST https://faqai.app/api/v1/documents \ -H "Authorization: Bearer faq_YOUR_API_KEY" \ -F "file=@./product-manual.pdf" \ -F "name=Product Manual" \ -F "auto_process=true"
Response
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "Product Manual",
"original_filename": "product-manual.pdf",
"file_type": "application/pdf",
"file_size": 245760,
"status": "processing",
"extraction_method": "hybrid",
"ocr_page_count": 3,
"created_at": "2026-02-26T10:30:00.000Z"
}OCR Response Fields
extraction_method— native (all pages had extractable text), hybrid (mix of native + OCR pages), or full_ocr (all pages processed via OCR). Only present for PDF documents.ocr_page_count— Integer. Number of pages processed via OCR.0for native extractions.
POSTAsync Job (Upload + Process)
POST /v1/jobs
Upload a document and process it asynchronously in a single request. Returns 202 Accepted immediately. Use webhook_url for push notification or poll GET /v1/documents/{id} to check status. Also accepts the optional generation_context, chunking, and contextual_enrichment form fields (same semantics as on Upload Document).
Important: Like direct uploads, this endpoint is limited to 4.5 MB. For larger files, use the large file upload options (SDK or upload endpoint), then poll for status.
curl -X POST https://faqai.app/api/v1/jobs \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "file=@document.pdf" \ -F "webhook_url=https://your-server.com/webhook"
{
"job_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"document_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"status": "processing",
"webhook_url": "https://your-server.com/webhook",
"poll_url": "/api/v1/documents/d290f1ee-6c54-4b01-90e6-d701748f0851"
}POSTLarge File Upload (SDK / Endpoint)
The recommended way to upload files of any size up to your plan limit in a single request. These options transparently handle the underlying presigned flow for you, so there are no 413 errors regardless of file size.
Option 1 — Official SDKs (recommended for code)
A single upload() call auto-routes by file size.
# Python # Node / TypeScript pip install faqai npm install @faqai/sdk
from faqai import FaqaiClient
client = FaqaiClient("faq_YOUR_API_KEY")
doc = client.upload("large-report.pdf", wait=True) # any size up to your plan limit
print(doc["status"]) # "completed"import { FaqaiClient } from "@faqai/sdk";
const client = new FaqaiClient("faq_YOUR_API_KEY");
const doc = await client.upload("large-report.pdf", { wait: true });
console.log(doc.status); // "completed"Option 2 — Upload endpoint (recommended for n8n / Make / Zapier)
A no-size-limit upload endpoint. For large files, send the file as the raw request body with the filename in an X-File-Name header (in n8n, set the HTTP node body to Binary File). Same Authorization header and the same JSON response as POST /v1/documents.
curl -X POST https://pzszslhgotjbrflurhfm.supabase.co/functions/v1/upload \ -H "Authorization: Bearer faq_YOUR_API_KEY" \ -H "Content-Type: application/pdf" \ -H "X-File-Name: large-report.pdf" \ -H "X-Doc-Name: Large Report" \ -H "X-Auto-Process: true" \ --data-binary @./large-report.pdf
Use raw binary for large files. The endpoint also accepts multipart/form-data (a file field), but multipart parsing is slow for big files and can time out — prefer the raw-binary form above for anything over a few MB.
The response is identical to POST /v1/documents. To get completion notifications, register a webhook (Pro plan); the upload endpoint does not accept an ad-hoc webhook_url.
POSTLarge File Upload (Presigned URL)
POST /v1/uploads
For files larger than 4.5 MB, use this two-step upload flow. Step 1: POST JSON to get a presigned URL. Step 2: PUT the file. Step 3: POST to confirm. The Step 1 body also accepts the optional generation_context, chunking, and contextual_enrichment fields (same semantics as on Upload Document).
# Step 1: Get presigned URL
curl -X POST https://faqai.app/api/v1/uploads \
-H "Authorization: Bearer faq_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename": "large-report.pdf", "file_type": "application/pdf", "file_size": 15000000}'
# Step 2: Upload to presigned URL
curl -X PUT "UPLOAD_URL_FROM_STEP_1" -H "Content-Type: application/pdf" --data-binary @./large-report.pdf
# Step 3: Confirm upload
curl -X POST https://faqai.app/api/v1/uploads/UPLOAD_ID/confirm \
-H "Authorization: Bearer faq_YOUR_API_KEY"POSTIngest from URL / Website
POST /v1/documents/from-url
Create a document from a public web page — no file upload needed. By default a single page is fetched. Set crawl: true (or max_pages > 1) to crawl multiple same-domain pages, discovered via the site's sitemap or a breadth-first walk when there is none.
Crawling honors robots.txt (our agent is FAQaiBot) and your plan's per-crawl page cap (Free 5, Basic 50, Starter 150, Pro 500). Only static HTML is read, so JavaScript-rendered pages may yield little content. Only submit URLs you own or are authorized to ingest.
Parameters (JSON body)
| Field | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | Absolute http(s) URL of the page or site to ingest. |
| crawl | boolean | No | Crawl multiple same-domain pages instead of one. Defaults to false. |
| max_pages | integer | No | Max pages to crawl, clamped to your plan cap. A value > 1 implies crawl: true. |
| name | string | No | Custom document name. Defaults to the page title or URL. |
| auto_process | boolean | No | Automatically generate datasets after ingest. Defaults to true. |
| generation_context | string | No | Audience/use-case steering (paid plans). Same values as on Upload Document. |
| chunking | string | object | No | Chunking profile. Same values as on Upload Document. |
| contextual_enrichment | boolean | No | Beta Contextual chunk enrichment (paid plans). Same semantics as on Upload Document. |
Example — Single Page
curl -X POST https://faqai.app/api/v1/documents/from-url \
-H "Authorization: Bearer faq_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/docs/faq"}'Example — Crawl a Site
curl -X POST https://faqai.app/api/v1/documents/from-url \
-H "Authorization: Bearer faq_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/", "crawl": true, "max_pages": 50}'Response (crawl — HTTP 202)
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "example.com",
"status": "processing",
"source_type": "url",
"source_url": "https://example.com/",
"crawl": {
"discovered": 74,
"capped_to": 50,
"estimated_pages": 50,
"mode": "sitemap"
}
}A single-page ingest returns 201 without the crawl object; a crawl returns 202 and runs asynchronously. Poll GET /v1/documents/{id} until status is completed. Pages are metered by extracted content and reconciled after extraction, and generated dataset items carry a source_url citation per chunk.
POSTGenerate Datasets
POST /v1/documents/{id}/processTrigger dataset generation for a document uploaded with auto_process=false, or re-process an existing document. The document must be in pending status.
Optionally accepts a JSON body with generation_context, chunking, and contextual_enrichment (same semantics as on upload — see the Upload Document parameters above).
Example Request
curl -X POST https://faqai.app/api/v1/documents/a1b2c3d4-e5f6-7890-abcd-ef1234567890/process \
-H "Authorization: Bearer faq_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"generation_context": "customer_support_bot", "chunking": "fine_grained"}'GETList Documents
GET /v1/documents
Retrieve all documents for the authenticated user, sorted by most recent first.
Example Request
curl https://faqai.app/api/v1/documents?status=completed&limit=10 \ -H "Authorization: Bearer faq_YOUR_API_KEY"
Response
{
"data": [
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "Product Manual",
"file_type": "application/pdf",
"file_size": 245760,
"status": "completed",
"dataset_count": 4,
"created_at": "2026-02-26T10:30:00.000Z"
}
],
"total": 1,
"limit": 10,
"offset": 0
}GETGet Document Details
GET /v1/documents/{id}Retrieve full details for a single document, including metadata and processing status.
GETGet RAG Config
GET /v1/documents/{id}/rag-configRetrieve the AI-generated RAG configuration for a document. Includes a tailored system prompt, embedding model recommendations, and code snippets for LangChain, LlamaIndex, and Vercel AI SDK.
GETGet Dataset Items
GET /v1/documents/{id}/datasetsRetrieve all datasets and their items for a document. Returns datasets grouped by type with full item details.
Response
{
"document_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"datasets": [
{ "id": "ds-001", "dataset_type": "canonical_qa", "status": "completed", "item_count": 344 },
{ "id": "ds-002", "dataset_type": "query_variants", "status": "completed", "item_count": 344 },
{ "id": "ds-003", "dataset_type": "evaluation", "status": "completed", "item_count": 278 },
{ "id": "ds-004", "dataset_type": "adversarial", "status": "completed", "item_count": 139 }
]
}GETList Datasets
GET /v1/documents/{id}/datasetsRetrieve all datasets generated for a document with metadata including type, status, and item count.
GETDataset Coverage
GET /v1/datasets/coverage/{dataset_id}Analyze how well a dataset covers the source document. Returns coverage percentage and identifies uncovered chunks.
{
"dataset_id": "ds-001",
"total_chunks": 12,
"chunks_with_qa": 10,
"chunks_without_qa": 2,
"coverage_percent": 83.3,
"uncovered_chunks": [
{ "chunk_id": "chunk-07", "page": 5 },
{ "chunk_id": "chunk-11", "page": 8 }
]
}GETSearch Datasets
GET /v1/datasets/search?q={keyword}Full-text keyword search across all your generated Q&A dataset items. Filter by dataset_type, document_id, difficulty, and question_type.
curl "https://faqai.app/api/v1/datasets/search?q=onboarding&dataset_type=canonical_qa&limit=10" \ -H "Authorization: Bearer faq_YOUR_API_KEY"
POSTCancel Processing
POST /v1/documents/{id}/cancelCancel a document that is currently being processed. Stops dataset generation and refunds page credits.
{
"id": "a1b2c3d4-...",
"status": "cancelled",
"message": "Document processing cancelled. Page credits refunded."
}DELETEDelete a Document
DELETE /v1/documents/{id}Remove a document from your account. Deleting a document does not restore your monthly page quota.
Webhooks
Webhooks let you receive real-time HTTP callbacks when events occur. Essential for automation workflows.
No code required: you can create, test, rotate secrets for, and inspect delivery logs of webhooks right in your dashboard under Developers → Webhooks (Pro plan). The endpoints below are the equivalent REST API.
| Event | Fired when |
|---|---|
| document.uploaded | File accepted and record created |
| document.completed | Dataset generation finishes successfully |
| document.failed | Processing encounters an error |
| document.cancelled | Processing cancelled by user |
| dataset.exported | Export finished and file delivered |
Create a Webhook
POST /api/v1/webhooks
{
"url": "https://your-server.com/webhook",
"events": ["document.completed", "document.failed"],
"description": "My automation workflow"
}The response includes a secret for signature verification. Save it securely - it is shown only once.
Signature Verification
Every delivery includes an X-FAQai-Signature header with an HMAC-SHA256 signature:
const crypto = require("crypto");
const expected = crypto
.createHmac("sha256", WEBHOOK_SECRET)
.update(rawBody)
.digest("hex");
const isValid = signature === `sha256=${expected}`;Manage Webhooks
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/webhooks | Create a webhook |
| GET | /api/v1/webhooks | List your webhooks |
| GET | /api/v1/webhooks/{id} | Details + recent deliveries |
| DELETE | /api/v1/webhooks/{id} | Remove a webhook |
Automation Tools
FAQai's REST API and webhooks work out of the box with popular automation platforms including n8n, Make.com, Zapier, Power Automate, and Pipedream. See the Automation Workflows section in the Usage Guide for step-by-step recipes.
Prerequisites
You need a Basic, Starter or Pro plan with an API key. Set the Authorization header to Bearer faq_YOUR_API_KEY on all HTTP requests.
MCP Server (AI Agents)
The official FAQai MCP server (@faqai/mcp-server) lets AI assistants work with your FAQai account directly: upload documents, generate datasets, check coverage, and export to your vector database — all from a chat conversation. MCP is model-agnostic (it is supported by host apps, not by a specific LLM), so the same server works across Claude, GPT, Gemini, and others. Supported hosts include Cursor, Claude Desktop, VS Code (Copilot agent mode), Windsurf, Cline / Roo Code, Zed, JetBrains AI Assistant, Claude Code, and the OpenAI Agents SDK, plus any other Model Context Protocol host.
Add the config below to your host (e.g. claude_desktop_config.json, ~/.cursor/mcp.json, or .vscode/mcp.json). Per-host config formats and copy buttons live in the dashboard under Developers → SDKs & MCP:
{
"mcpServers": {
"faqai": {
"command": "npx",
"args": ["-y", "@faqai/mcp-server"],
"env": {
"FAQAI_API_KEY": "faq_YOUR_API_KEY"
}
}
}
}The server exposes 18 tools covering the full document lifecycle — from upload_document, ingest_url, and get_processing_status to export_dataset, search_datasets, and get_dataset_coverage — plus ready-made prompts for the most common workflows.
Security notes
- The server talks only to this REST API with your key — your plan limits, quotas, and rate limits apply unchanged.
- Destructive actions (deleting documents) require explicit confirmation.
- Use a read-scoped API key if the agent should never upload or delete.
Web-based hosts (ChatGPT connectors, Claude.ai on the web, Grok / xAI, and hosted agent frameworks) connect over a remote HTTPS URL instead of launching a local process. For these, FAQai also offers a remote MCP endpoint over Streamable HTTP at https://faqai.app/api/mcp. Hosts with OAuth connectors can authenticate with one-click OAuth (click Connect, approve access on FAQai, and you're done — no key to copy); developer-mode custom servers can instead send an Authorization: Bearer faq_… header. Per-host remote config (OpenAI Agents SDK, OpenAI Responses API, Cursor, VS Code, ChatGPT/Claude.ai/Grok) and connected-app management live in the dashboard under Developers → SDKs & MCP. Uploading a local file is stdio-only; all other tools work remotely and are metered exactly like the REST API.
Error Codes
All errors return a JSON object with a message field describing the issue.
| Status | Code | Description |
|---|---|---|
| 400 | bad_request | Invalid parameters, file format, or document not in expected state |
| 401 | unauthorized | Missing or invalid API key |
| 403 | forbidden | API key does not have access, or export format not available on your plan |
| 404 | not_found | Document or resource not found |
| 409 | conflict | Document is already being processed or has been completed |
| 413 | payload_too_large | File exceeds plan file size or page limit |
| 422 | unprocessable | Processing failed or dataset is not in a completed state for export |
| 429 | rate_limited | Too many requests, monthly page quota exceeded, API call limit reached, or RAG Playground message limit reached |
| 500 | server_error | Internal server error - contact support |
Code Examples
Complete examples for uploading a document and retrieving the generated dataset items.
Node.js / JavaScript
import fs from "fs";
const API_KEY = process.env.FAQAI_API_KEY;
const BASE = "https://faqai.app/api/v1";
// 1. Upload a document
const form = new FormData();
form.append("file", fs.createReadStream("./manual.pdf"));
form.append("auto_process", "true");
const upload = await fetch(`${BASE}/documents`, {
method: "POST",
headers: { Authorization: `Bearer ${API_KEY}` },
body: form,
});
const doc = await upload.json();
console.log("Document ID:", doc.id);
// 2. Poll until processing completes
let status = doc.status;
while (status === "processing" || status === "pending") {
await new Promise((r) => setTimeout(r, 3000));
const res = await fetch(`${BASE}/documents/${doc.id}`, {
headers: { Authorization: `Bearer ${API_KEY}` },
});
const detail = await res.json();
status = detail.status;
}
// 3. Retrieve generated datasets
const datasetsRes = await fetch(`${BASE}/documents/${doc.id}/datasets`, {
headers: { Authorization: `Bearer ${API_KEY}` },
});
const datasets = await datasetsRes.json();
console.log(`Generated ${datasets.datasets.length} datasets`);Python
import os, time, requests
API_KEY = os.environ["FAQAI_API_KEY"]
BASE = "https://faqai.app/api/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# 1. Upload a document
with open("manual.pdf", "rb") as f:
resp = requests.post(
f"{BASE}/documents",
headers=HEADERS,
files={"file": f},
data={"auto_process": "true"},
)
doc = resp.json()
print(f"Document ID: {doc['id']}")
# 2. Poll until processing completes
status = doc["status"]
while status in ("processing", "pending"):
time.sleep(3)
detail = requests.get(
f"{BASE}/documents/{doc['id']}", headers=HEADERS
).json()
status = detail["status"]
# 3. Retrieve generated datasets
datasets = requests.get(
f"{BASE}/documents/{doc['id']}/datasets", headers=HEADERS
).json()
for ds in datasets["datasets"]:
print(f" {ds['dataset_type']}: {ds['item_count']} items")cURL
# Upload curl -X POST https://faqai.app/api/v1/documents \ -H "Authorization: Bearer faq_YOUR_API_KEY" \ -F "file=@manual.pdf" \ -F "auto_process=true" # Check status curl https://faqai.app/api/v1/documents/DOC_ID \ -H "Authorization: Bearer faq_YOUR_API_KEY" # Get datasets curl https://faqai.app/api/v1/documents/DOC_ID/datasets \ -H "Authorization: Bearer faq_YOUR_API_KEY"
Processing is asynchronous
Dataset generation typically takes 10-60 seconds depending on document size. Poll the GET /v1/documents/{id} endpoint and check the status field, or use webhooks for real-time notifications.