Knowledge
Import a web page
Imports the text of a public web page.
POST https://api.diska.ai/v1/knowledge-bases/{knowledge_base_id}/documents/url
Scope: knowledge:write
The page must answer within 15 seconds, be up to 2 MB and be HTML, text or JSON. Private or internal addresses are refused, and at most 3 redirects are followed.
Parameters
Path
| Name | Type | Required | Description |
|---|---|---|---|
knowledge_base_id | string | Yes | The knowledge base's ID. |
Request body
application/json
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Document name. Up to 200 characters. |
url | string | Yes | Full http:// or https:// address of the page. 8 to 2000 characters. |
{
"name": "Página de preços",
"url": "https://www.exemplo.ao/precos"
}
Examples
curl -X POST "https://api.diska.ai/v1/knowledge-bases/<knowledge_base_id>/documents/url" \
-H "Authorization: Bearer $DISKA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Página de preços","url":"https://www.exemplo.ao/precos"}'
import os
import requests
response = requests.post(
"https://api.diska.ai/v1/knowledge-bases/<knowledge_base_id>/documents/url",
headers={"Authorization": f"Bearer {os.environ['DISKA_API_KEY']}"},
json={
"name": "Página de preços",
"url": "https://www.exemplo.ao/precos",
},
timeout=30,
)
response.raise_for_status()
print(response.json())
// Node.js 18 or later, in a .mjs file
const response = await fetch('https://api.diska.ai/v1/knowledge-bases/<knowledge_base_id>/documents/url', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.DISKA_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
"name": "Página de preços",
"url": "https://www.exemplo.ao/precos"
})
})
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/url');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('DISKA_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Página de preços',
'url' => 'https://www.exemplo.ao/precos',
]),
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.
POST
https://api.diska.ai/v1/knowledge-bases/{knowledge_base_id}/documents/urlStarts 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.

