Export knowledge base documents
GET all active documents from an owned knowledge base using a user API key.
Export every active document in a knowledge base you own. The response includes metadata, plain-text bodies, and optionally rendered HTML—suitable for backups, search indexing, and downstream ETL.
For authentication and the Open API prefix, see the developer documentation home. To create documents instead, use Import a document.
Endpoint
GET /api/v1/open/books/{bookSlug}/docs
Authorization: Bearer YOUR_API_KEY| Item | Value |
|---|---|
| Method | GET |
| Auth | Authorization: Bearer + full API key |
| Path parameter | bookSlug — knowledge base slug (x_book.slug) |
| Default scope | Active documents only (status = 1) |
| Ownership | Key must belong to the knowledge base owner |
Query parameters
| Parameter | Default | Description |
|---|---|---|
excludeCategories | true | When true, omits folder nodes (type === "category"). Set to false to include them. |
includeContentHtml | true | When true, includes contentHtml on each document. Set to false for a lighter payload (contentHtml is still present as null). |
Example with categories included and HTML omitted:
GET /api/v1/open/books/my-library/docs?excludeCategories=false&includeContentHtml=falseExample request
Replace YOUR_API_KEY and BOOK_SLUG with your values. Use your deployment origin instead of https://your-domain.com when not running locally.
curl -sS \
-H "Authorization: Bearer YOUR_API_KEY" \
"https://your-domain.com/api/v1/open/books/BOOK_SLUG/docs"$headers = @{ Authorization = "Bearer YOUR_API_KEY" }
Invoke-RestMethod `
-Uri "https://your-domain.com/api/v1/open/books/BOOK_SLUG/docs" `
-Headers $headersSuccess response
Status: 200 OK
{
"success": true,
"book": {
"id": "…",
"slug": "BOOK_SLUG",
"name": "Product notes",
"description": "Internal team library",
"coverImage": "https://cdn.example.com/book-cover.png",
"createdAt": "2026-04-01T08:00:00.000Z",
"updatedAt": "2026-05-21T10:00:00.000Z"
},
"documents": [
{
"id": "…",
"slug": "doc-slug",
"name": "Requirements",
"type": "document",
"parentId": null,
"orderKey": "a",
"description": null,
"emojiInfo": null,
"cover": { "url": "https://cdn.example.com/doc-cover.png", "position": "center" },
"tags": ["guide"],
"themeId": "default",
"backgroundThemeId": "transparent",
"bodyFontSize": "default",
"updatedAt": "2026-05-21T09:00:00.000Z",
"createdAt": "2026-05-20T08:00:00.000Z",
"contentStr": "Plain-text body when available",
"contentHtml": "<p>Rendered HTML body</p>"
}
],
"meta": { "count": 1 }
}Response fields
book
| Field | Type | Description |
|---|---|---|
id | string | Knowledge base ID |
slug | string | Knowledge base slug |
name | string | Display name |
description | string | null | Short description |
coverImage | string | null | Cover image URL |
createdAt | string (ISO 8601) | Created at |
updatedAt | string (ISO 8601) | Last updated at |
documents[]
| Field | Type | Description |
|---|---|---|
id | string | Document ID |
slug | string | Document slug |
name | string | Title |
type | string | document, category, etc. |
parentId | string | null | Parent node ID (tree) |
orderKey | string | Sibling sort key |
description | string | null | Summary |
emojiInfo | string | null | Icon metadata |
cover | object | null | Cover header image: { url, position } (url is proxy-resolved; position is the CSS object-position, center when unset) |
tags | string[] | null | Tags |
themeId | string | Editor typography theme (default when unset) |
backgroundThemeId | string | Editor background theme (transparent when unset) |
bodyFontSize | string | Body font preset: default, 14, or 12 |
createdAt | string (ISO 8601) | Created at |
updatedAt | string (ISO 8601) | Last updated at |
contentStr | string | null | Plain-text body |
contentHtml | string | null | Rendered HTML body (null when includeContentHtml=false). Relative image and attachment URLs are rewritten with the same CDN proxy prefix used in the editor (config.storage.proxyUrls.cmsFile), so exported <img src="..."> values are directly fetchable. |
Notes:
contentStrandcontentHtmlare included by default. Large libraries may produce heavy responses; useincludeContentHtml=falsewhen you only need plain text.contentYjsandcontentJson(editor-internal formats) are not returned.- Documents are ordered by
orderKeywithin the knowledge base.
Error responses
All errors use a flat envelope:
{ "success": false, "code": "<MACHINE_CODE>", "message": "<human readable>" }| HTTP | code | When |
|---|---|---|
401 | INVALID_API_KEY | Missing header, invalid, expired, or revoked key |
404 | BOOK_NOT_FOUND | Unknown slug, or library not owned by the key user |
429 | RATE_LIMITED | API key verification rate limit exceeded |
500 | EXPORT_FAILED | Unexpected server error (cause is logged server-side, not echoed) |
Example:
{
"success": false,
"code": "BOOK_NOT_FOUND",
"message": "Knowledge base not found"
}404 vs 403
Non-owned slugs return 404 instead of 403 to avoid leaking whether a slug exists.
Limitations (current version)
- Read-only: does not update or delete documents.
- No pagination; all matching documents are returned in one response.
- No per-key knowledge base allowlist (any owned slug works).
- Does not access public or password-protected libraries you do not own.
See also
- Import a document
- Manage API keys
- Browser session list (not for scripts):
GET /api/books/docs/list/{bookSlug}