Document Ingestion
The webhook ingestion endpoint lets you push documents into your Optimaite workspace from any external system -- scanners, email gateways, custom scripts, or third-party applications.
Endpoint
POST /webhooks/inbox/{tenant_id}
This endpoint is available on both the Law and Business backend services.
Authentication
Every request must include your workspace webhook token in the X-Optimaite-Token header:
X-Optimaite-Token: your-webhook-token
Each workspace has a unique token. You can find and rotate it from Workspace Settings > Webhooks in the Optimaite UI.
Keep your webhook token secure. Anyone with the token can upload documents to your workspace. If you believe it has been compromised, rotate it immediately from the settings page.
Request Format
The endpoint accepts multipart/form-data with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
file | File | Yes | The document to upload. Supported formats: PDF, DOCX, DOC, PNG, JPG, TIFF |
folder_id | String | No | UUID of the folder to place the document in. If omitted, it goes to the inbox. |
metadata | String (JSON) | No | Optional JSON object with custom metadata to attach to the document |
Code Examples
curl -X POST https://api.optimaite.eu/webhooks/inbox/YOUR_TENANT_ID \
-H "X-Optimaite-Token: your-webhook-token" \
-F "file=@contract.pdf"
import requests
url = "https://api.optimaite.eu/webhooks/inbox/YOUR_TENANT_ID"
headers = {"X-Optimaite-Token": "your-webhook-token"}
with open("contract.pdf", "rb") as f:
response = requests.post(
url,
headers=headers,
files={"file": ("contract.pdf", f, "application/pdf")},
)
print(response.status_code, response.json())
import { readFileSync } from "fs";
const formData = new FormData();
const fileBuffer = readFileSync("./contract.pdf");
formData.append("file", new Blob([fileBuffer]), "contract.pdf");
const response = await fetch(
"https://api.optimaite.eu/webhooks/inbox/YOUR_TENANT_ID",
{
method: "POST",
headers: { "X-Optimaite-Token": "your-webhook-token" },
body: formData,
}
);
console.log(response.status, await response.json());
Response
Success (200)
{
"status": "ok",
"document_id": "550e8400-e29b-41d4-a716-446655440000",
"filename": "contract.pdf"
}
Error Responses
| Status | Meaning |
|---|---|
| 401 | Missing or invalid X-Optimaite-Token header |
| 404 | Tenant ID not found |
| 413 | File exceeds the maximum upload size |
| 415 | Unsupported file format |
| 422 | Missing file field or malformed request |
Token Management
Navigate to Workspace Settings > Webhooks in the Optimaite app to view your webhook URL, current token, and rotate the token.
After rotating, the old token is immediately invalidated. Update your external systems before rotating to avoid downtime.
Next Steps
- Audit Export -- Stream audit events to your SIEM
- Cases API -- Manage cases for ingested documents