Knowledge
Upload a PDF
Uploads a PDF as multipart/form-data, in the file field (up to 25 MB).
POST https://api.diska.ai/v1/knowledge-bases/{knowledge_base_id}/documents/pdf
Scope: knowledge:write
Parameters
Path
| Name | Type | Required | Description |
|---|---|---|---|
knowledge_base_id | string | Yes | The knowledge base's ID. |
Request body
multipart/form-data
| Field | Type | Required | Description |
|---|---|---|---|
file | file | Yes | The PDF (up to 25 MB). |
Examples
curl -X POST "https://api.diska.ai/v1/knowledge-bases/<knowledge_base_id>/documents/pdf" \
-H "Authorization: Bearer $DISKA_API_KEY" \
-F "file=@tabela-de-precos.pdf;type=application/pdf"
import os
import requests
response = requests.post(
"https://api.diska.ai/v1/knowledge-bases/<knowledge_base_id>/documents/pdf",
headers={"Authorization": f"Bearer {os.environ['DISKA_API_KEY']}"},
files={"file": ("tabela-de-precos.pdf", open("tabela-de-precos.pdf", "rb"), "application/pdf")},
timeout=30,
)
response.raise_for_status()
print(response.json())
// Node.js 20 or later, in a .mjs file
import { openAsBlob } from 'node:fs'
const form = new FormData()
form.append('file', await openAsBlob('tabela-de-precos.pdf', { type: 'application/pdf' }), 'tabela-de-precos.pdf')
const response = await fetch('https://api.diska.ai/v1/knowledge-bases/<knowledge_base_id>/documents/pdf', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.DISKA_API_KEY}` },
body: form
})
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`)
console.log(await response.json())
<?php
$ch = curl_init('https://api.diska.ai/v1/knowledge-bases/<knowledge_base_id>/documents/pdf');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('DISKA_API_KEY')],
CURLOPT_POSTFIELDS => ['file' => new CURLFile('tabela-de-precos.pdf', 'application/pdf')],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
if ($status >= 400) {
throw new RuntimeException("HTTP $status: $body");
}
print_r(json_decode($body, true));
Try it
Send the request from this page, with your key. The key stays on this page: it is not stored and is only sent to api.diska.ai. Use a test key with the fewest scopes you need. In Try it, pick a PDF from your computer.
POST
https://api.diska.ai/v1/knowledge-bases/{knowledge_base_id}/documents/pdfStarts with dsk_. It stays in this browser tab only.
path
Enter an API key (dsk_…).
Response 201
| Field | Type | Description |
|---|---|---|
id | string | ID. |
organization_id | string | Organization it belongs to. |
knowledge_base_id | string | Base the document belongs to. |
name | string | Document name. |
source_type | string | manual (text), pdf or url. |
status | string | Overall document state. One of: pending, uploading, processing, ready, failed, indexing_pending. Default: pending. |
extraction_status | string | Text extraction state. One of: pending, extracted, skipped, failed. Default: pending. |
indexing_status | string | Indexing state: indexed when the agent can use it. One of: pending, indexing_pending, indexed, skipped, failed. Default: indexing_pending. |
content_text | string | null | The extracted text. |
original_url | string | null | Imported address (url documents). |
storage_path | string | null | Internal file location. |
mime_type | string | null | File type. |
size_bytes | integer | null | Size in bytes. |
error_message | string | null | Error, when it failed. |
metadata | object | Technical metadata. |
created_at | string | null | Creation date (ISO 8601). |
updated_at | string | null | Last change date (ISO 8601). |
has_file | boolean | true when a file is stored. Default: false. |
{
"id": "5c2e8a14-7d3b-4f9e-a1c6-0b8d2f4e6a93",
"organization_id": "5c2e8a14-7d3b-4f9e-a1c6-0b8d2f4e6a93",
"knowledge_base_id": "b2e4c6d8-1a3f-4e5b-9c7d-0f2a4b6c8e10",
"name": "Horários",
"source_type": "manual",
"status": "ready",
"extraction_status": "extracted",
"indexing_status": "indexed",
"content_text": "Abrimos de segunda a sexta, das 8h às 17h.",
"original_url": null,
"storage_path": null,
"mime_type": "text/plain",
"size_bytes": 48213,
"error_message": "…",
"metadata": {},
"created_at": "2026-10-25T18:40:00Z",
"updated_at": "2026-10-25T18:40:00Z",
"has_file": false
}
Errors
| Code | When |
|---|---|
400 | Content refused — for example Ficheiro vazio. (empty file), PDF demasiado grande (máx. 25 MB). (PDF too large), Apenas ficheiros PDF são aceites. (only PDFs), O ficheiro não parece ser um PDF válido. (not a valid PDF), Tempo esgotado ao obter a página. (page timed out), A página não devolveu texto legível. (no readable text) or a URL blocked for security. |
404 | Base de conhecimento não encontrada. (knowledge base not found). |
Errors common to every endpoint (401, 403, 422, 429 and 5xx) are in Errors.

