alRetrieval
Ingest documents and query them with natural-language semantic retrieval. Supports PDF, DOCX, PPTX, TXT, and Markdown files.
- Path
- /v1/alRetrieval
- Key scope
- alretrieval
Supported file formats
PDF, DOCX, PPTX, TXT, MD
PDFs are processed via OCR; DOCX, PPTX, TXT, and MD have text extracted directly — no OCR cost
Scope Required: All alRetrieval endpoints require an API key with the alretrieval scope. Pass it as a Bearer token in the Authorization header.
POSTUpload a document
Send a file or a URL as multipart/form-data, or text you have already extracted as JSON pages. Returns 202 with the document in status: "processing" and a Location header pointing at its status endpoint. A collection holds up to 500 documents.
POST /v1/alRetrieval/collections/{collection_id}/documents
Parameters:
| Parameter | Type | Description |
|---|---|---|
file | file | PDF, DOCX, PPTX, TXT or MD, up to 100 MB. |
url | string | Instead of file: a public HTTPS link alAPI downloads the document from (optional filename). |
title | string | optional — defaults to the file name without its extension. |
pages | object[] | JSON body instead of a file: 1 to 5,000 entries of {"page_num", "text"}, with optional title and filename. |
The document includes a view_url for the original file as soon as the upload is accepted, including while processing. Get and list responses include the same link; JSON pages have view_url: null. Request the link from your server with the same API key; keep the key out of the URL.
PDFs are OCR'd and charged per page from your OCR balance; the upload is refused with 402 when the file has more pages than you have available. Once processed, PDFs also get section-aware retrieval.
Response (202 Accepted):
{
"id": "3146366e04ff",
"collection_id": "6a51b4e5c0d24f0e9b1a7c3d2e8f4a10",
"title": "Leave policy",
"filename": "leave-policy.pdf",
"view_url": "https://alapi.deep.sa/v1/alRetrieval/collections/6a51b4e5c0d24f0e9b1a7c3d2e8f4a10/documents/3146366e04ff/file",
"source": "pdf",
"page_count": 0,
"created_at": "2026-10-03T10:01:12Z",
"status": "processing",
"ingest": { "stage": "queued", "error": null },
"deep_tree": { "status": "waiting", "degraded": false, "error": null },
"pipeline": null
}
Code Examples:
import requests
headers = {"Authorization": "Bearer YOUR_API_KEY"}
url = "https://alapi.deep.sa/v1/alRetrieval/collections/COLLECTION_ID/documents"
# A file
with open("leave-policy.pdf", "rb") as f:
doc = requests.post(url, files={"file": f}, data={"title": "Leave policy"}, headers=headers).json()
# A public URL
doc = requests.post(url, data={"url": "https://example.com/handbook.pdf"}, headers=headers).json()
# Text you already extracted
doc = requests.post(url, json={
"title": "دليل الموظف",
"pages": [{"page_num": 1, "text": "سياسة الإجازات: ..."}],
}, headers=headers).json()
print(doc["id"], doc["status"])
Ready to Get Started?
Generate an API key from your dashboard and start building