Free setup on annual plans

Sign up today!

Knowledge bases

API Reference: Knowledge bases endpoints

A knowledge base is a searchable collection of files that the AI consults when it answers. Each knowledge base is an OpenAI vector store in the OpenAI project of the account, reached with the account’s own OpenAI key. You link it to prompt documents; a document with vector search switched on then searches its knowledge bases while a reply is written. These endpoints create and link knowledge bases, upload and manage their files, test a search and follow the long-running operations that do the work in the background.

Overview

  • Managed and linked
    A managed knowledge base is created by AnswerPal: AnswerPal uploads the files, keeps a copy of every original and tracks versions. A linked knowledge base points to a vector store that already exists in the account’s OpenAI project; AnswerPal reads it (files, preview, search, download) but never changes its content. Every change to a linked knowledge base answers 409 linked_knowledge_base_read_only. A linked knowledge base can be copied into a new managed one (adoption).
  • Long-running operations
    Creating a knowledge base, uploading, replacing, detaching, restoring, deleting files and deleting a knowledge base answer 202 Accepted with a Location header to /api/knowledge-base-operations/{operationID} and the operation in the body. Poll the operation until its status is Succeeded, Failed or Cancelled.
  • Idempotency-Key
    Every request that starts an operation needs an Idempotency-Key header: 8 to 200 characters, ASCII letters, digits and - _ . :. The same key with the same request returns the original operation again; the same key for another request answers 409 idempotency_key_conflict. Keys are unique per account across all knowledge base operations.
  • Concurrency tokens
    A knowledge base and each file carry a concurrencyToken. Changes send the current token; when it no longer matches, the answer is 409 (knowledge_base_concurrency_conflict or file_concurrency_conflict): read the item again and retry. The token changes often, also after a read that refreshes the state from OpenAI.
  • Who
    Configurator and Administrator.

Endpoints

Knowledge bases

  • GET /api/knowledge-bases
    Access: Bearer JWT (Configurator or Administrator)
    All knowledge bases of the account except deleted ones, by name.
  • POST /api/knowledge-bases
    Access: Bearer JWT (Configurator or Administrator)
    Create an empty managed knowledge base. Answers 202 Accepted with the knowledge base (status Provisioning) and the operation that creates the vector store.
  • GET /api/knowledge-bases/capabilities
    Access: Bearer JWT (Configurator or Administrator)
    Whether managed uploads are possible (sourceStorageConfigured) and the largest file that can be uploaded (maximumSourceFileBytes).
  • POST /api/knowledge-bases/linked
    Access: Bearer JWT (Configurator or Administrator)
    Link an existing vector store of the account’s OpenAI project, optionally to one document. Answers 201 Created for a new link, 200 OK when the store was already linked.
  • GET /api/knowledge-bases/{knowledgeBaseID}
    Access: Bearer JWT (Configurator or Administrator)
    One knowledge base, also when it is deleted.
  • DELETE /api/knowledge-bases/{knowledgeBaseID}
    Access: Bearer JWT (Configurator or Administrator)
    Delete a knowledge base. Body: concurrencyToken and confirmation DELETE KNOWLEDGE BASE. A managed knowledge base loses its files and vector store at OpenAI; for a linked one only AnswerPal’s record goes. Answers 202 Accepted.
  • PUT /api/knowledge-bases/{knowledgeBaseID}/page-image-settings
    Access: Bearer JWT (Configurator or Administrator)
    How many page images of this knowledge base a reply may use. Returns the knowledge base.
  • POST /api/knowledge-bases/{knowledgeBaseID}/search
    Access: Bearer JWT (Configurator or Administrator)
    Try a search as the reply engine would. Returns the best matching passages.
  • POST /api/knowledge-bases/{knowledgeBaseID}/reconcile
    Access: Bearer JWT (Configurator or Administrator)
    Compare AnswerPal’s records with the vector store now and update them. Returns counters.
  • POST /api/knowledge-bases/{knowledgeBaseID}/adoptions
    Access: Bearer JWT (Configurator or Administrator)
    Copy a linked knowledge base into a new managed one and move the chosen document links to it. Answers 202 Accepted.

Linked documents

  • GET /api/knowledge-bases/{knowledgeBaseID}/documents
    Access: Bearer JWT (Configurator or Administrator)
    The prompt documents linked to the knowledge base: totalCount and up to 500 items (documentID, name), by name.
  • DELETE /api/knowledge-bases/{knowledgeBaseID}/documents/{documentID}
    Access: Bearer JWT (Configurator or Administrator)
    Remove the link between a document and the knowledge base. Body: concurrencyToken of the knowledge base. A link that does not exist gives 200 as well. Returns the knowledge base.

Files

  • GET /api/knowledge-bases/{knowledgeBaseID}/files
    Access: Bearer JWT (Configurator or Administrator)
    The files of a knowledge base, paged. Query: pageSize (1 to 100, default 20), continuationToken, status and order (asc or desc, default desc).
  • POST /api/knowledge-bases/{knowledgeBaseID}/files
    Access: Bearer JWT (Configurator or Administrator)
    Upload a file to a managed knowledge base (multipart form). Answers 202 Accepted with the new file, its first version and the operation.
  • GET /api/knowledge-bases/{knowledgeBaseID}/files/{knowledgeBaseFileID}
    Access: Bearer JWT (Configurator or Administrator)
    One file with all its versions.
  • GET /api/knowledge-bases/{knowledgeBaseID}/files/{knowledgeBaseFileID}/content
    Access: Bearer JWT (Configurator or Administrator)
    Download the file: the kept original of a managed file, otherwise the file from OpenAI.
  • GET /api/knowledge-bases/{knowledgeBaseID}/files/{knowledgeBaseFileID}/preview
    Access: Bearer JWT (Configurator or Administrator)
    The text passages OpenAI holds for the file, paged with pageSize (1 to 100) and continuationToken.
  • POST /api/knowledge-bases/{knowledgeBaseID}/files/{knowledgeBaseFileID}/replacements
    Access: Bearer JWT (Configurator or Administrator)
    Upload a new version of a managed file. Answers 202 Accepted; the previous version is kept as superseded.
  • PUT /api/knowledge-bases/{knowledgeBaseID}/files/{knowledgeBaseFileID}/page-images
    Access: Bearer JWT (Configurator or Administrator)
    Switch the use of page images on or off for one managed PDF. Returns the file.
  • POST /api/knowledge-bases/{knowledgeBaseID}/files/{knowledgeBaseFileID}/detach
    Access: Bearer JWT (Configurator or Administrator)
    Take a managed file out of the knowledge base, so it no longer answers. The file at OpenAI and the original are kept. Answers 202 Accepted.
  • POST /api/knowledge-bases/{knowledgeBaseID}/files/{knowledgeBaseFileID}/restore
    Access: Bearer JWT (Configurator or Administrator)
    Put a detached file back. Answers 202 Accepted.
  • DELETE /api/knowledge-bases/{knowledgeBaseID}/files/{knowledgeBaseFileID}/provider-file
    Access: Bearer JWT (Configurator or Administrator)
    Delete the OpenAI file of a detached file for good. Body: concurrencyToken and confirmation DELETE PROVIDER FILE. Answers 202 Accepted.
  • DELETE /api/knowledge-bases/{knowledgeBaseID}/files/{knowledgeBaseFileID}/versions/{knowledgeBaseFileVersionID}/provider-file
    Access: Bearer JWT (Configurator or Administrator)
    The same for one inactive version, for example a superseded one; the file does not have to be detached.
  • DELETE /api/knowledge-bases/{knowledgeBaseID}/files/{knowledgeBaseFileID}/versions/{knowledgeBaseFileVersionID}/source
    Access: Bearer JWT (Configurator or Administrator)
    Delete AnswerPal’s copy of the original of an inactive version, with its page images, once its retention date has passed. Body: concurrencyToken and confirmation PURGE SOURCE. Frees storage. Answers 202 Accepted.

Operations

  • GET /api/knowledge-base-operations/{operationID}
    Access: Bearer JWT (Configurator or Administrator)
    The state of a long-running operation.
  • POST /api/knowledge-base-operations/{operationID}/retry
    Access: Bearer JWT (Configurator or Administrator)
    Start a failed operation again when its retryable is true. Returns the operation (200 OK), back in Pending.
  • POST /api/knowledge-base-operations/{operationID}/cancel
    Access: Bearer JWT (Configurator or Administrator)
    Cancel an adoption that is pending or failed. Returns the operation with status Cancelled.

Knowledge bases

Knowledge base (response)

  • knowledgeBaseID (integer), name
  • provider
    Always OpenAI.
  • managementMode
    Managed or LinkedExternal.
  • status
    Provisioning, Adopting, Ready, Degraded, Inaccessible, Deleting, Deleted or Unknown.
  • isEnabled (boolean), fileCount (files that are not removed), linkedDocumentCount
  • lastSynchronizedAt, lastValidatedAt, lastErrorCode, lastErrorMessage
  • concurrencyToken, adoptedFromKnowledgeBaseID (integer or null), maxPageImagesPerReply (integer or null)

Create (body)

  • name (string, required, 1 to 150 characters)

With the Idempotency-Key header. The account needs an OpenAI key; without one the answer is 401 knowledge_credentials_missing. The answer holds knowledgeBase and operation. The knowledge base is Ready once the operation succeeded.

Link (body)

  • externalStoreID (string, required, max 255)
    The vector store ID, starting with vs_. It must be reachable with the account’s OpenAI key.
  • documentID (integer, optional)
    A prompt document of the account to link to the knowledge base.

The answer is { "knowledgeBase": {...}, "created": true }. The name comes from the vector store. Linking a store that is already linked enables it again, also after it was deleted in AnswerPal, and adds the document link. A store that is one of the account’s managed knowledge bases gives 409 vector_store_managed_by_answerpal.

Page images

For managed PDFs, AnswerPal can store an image of every page and give the AI the pages that match the passages it found. maxPageImagesPerReply (0 to 50, or null) limits how many page images of this knowledge base one reply uses: null follows the account setting, else 10; 0 sends none. The body of PUT .../page-image-settings is { "concurrencyToken": "...", "maxPageImagesPerReply": 4 }. Page images count towards the account’s storage.

Search (body and response)

  • query (string, required, 1 to 2000 characters), maxResults (1 to 50, default 10)

The answer is { "items": [...], "hasMore": false }. Each item has knowledgeBaseFileID (null when AnswerPal does not know the file yet), fileName, score, attributes, content (passages with type and text) and pageNumber. There is no next page. On a managed knowledge base only the active versions of ready files are searched.

Reconcile (response)

discovered, updated, markedMissing, totalProviderFiles, completedAt, lifecycleDrift, stuckOperations, retainedSourcesNotVerified, pageImageDrift and pageImagesNotVerified. The check runs while you wait and can take a while on a large knowledge base; above 10,000 files it answers 400 reconciliation_limit_exceeded, and a second check of the same knowledge base at the same time 409 reconciliation_in_progress. AnswerPal also runs it every hour. When a managed knowledge base differs from its records, its status becomes Degraded.

Delete

A knowledge base that is still linked to a document cannot be deleted (409 knowledge_base_still_linked): remove the document links first. The knowledge base is Deleting right away and Deleted when the operation succeeded. The originals of a deleted managed knowledge base stay for the retention period and can be purged.

POST /api/knowledge-bases
Authorization: Bearer <token>
Idempotency-Key: kb-create-2026-12-01-01
Content-Type: application/json

{ "name": "Product manuals" }

202 Accepted
Location: /api/knowledge-base-operations/6f0c4d0e-2b1a-4b8e-9a51-3c7e2f1d9a40

{
  "knowledgeBase": {
    "knowledgeBaseID": 14,
    "name": "Product manuals",
    "provider": "OpenAI",
    "managementMode": "Managed",
    "status": "Provisioning",
    "isEnabled": true,
    "fileCount": 0,
    "concurrencyToken": "AAAAAAAAB9E=",
    "linkedDocumentCount": 0,
    "maxPageImagesPerReply": null,
    ...
  },
  "operation": {
    "knowledgeBaseOperationID": "6f0c4d0e-2b1a-4b8e-9a51-3c7e2f1d9a40",
    "knowledgeBaseID": 14,
    "type": "Provision",
    "status": "Pending",
    "retryable": false,
    ...
  }
}
POST /api/knowledge-bases/linked
Authorization: Bearer <token>
Content-Type: application/json

{ "externalStoreID": "vs_abc123example", "documentID": 140 }

201 Created
Location: /api/knowledge-bases/15

{
  "knowledgeBase": {
    "knowledgeBaseID": 15,
    "name": "Support articles",
    "managementMode": "LinkedExternal",
    "status": "Ready",
    "linkedDocumentCount": 1,
    ...
  },
  "created": true
}
POST /api/knowledge-bases/14/search
Authorization: Bearer <token>
Content-Type: application/json

{ "query": "How do I reset the thermostat?", "maxResults": 3 }

200 OK
{
  "items": [
    {
      "knowledgeBaseFileID": 301,
      "fileName": "thermostat-manual.pdf",
      "score": 0.82,
      "attributes": { ... },
      "content": [ { "type": "text", "text": "To reset the thermostat, hold the menu button for ten seconds ...", "pageNumber": null } ],
      "pageNumber": 12
    }
  ],
  "hasMore": false
}
DELETE /api/knowledge-bases/14
Authorization: Bearer <token>
Idempotency-Key: kb-delete-14-2026-12-05
Content-Type: application/json

{ "concurrencyToken": "AAAAAAAACA4=", "confirmation": "DELETE KNOWLEDGE BASE" }

202 Accepted
Location: /api/knowledge-base-operations/0d6b3a7e-58c2-4f7d-a1e9-62b4c3d8e015

{ "operation": { "knowledgeBaseOperationID": "0d6b3a7e-58c2-4f7d-a1e9-62b4c3d8e015", "type": "DeleteKnowledgeBase", "status": "Pending", ... } }

Files and versions

Upload (multipart form)

  • file (file, required)
    At most 50 MB (the request at most 52 MB). Allowed: .pdf, .docx, .pptx, .doc, .rtf, .txt, .md, .html, .htm, .json and .csv. The type follows from the extension and the content must match it; the content type you send is not used. The file name may be at most 255 characters.
  • pageImages (true or false, optional)
    Store page images of a PDF. Without it AnswerPal decides from the PDF (mostly visual pages get them); on a replacement the file keeps its current choice.
  • concurrencyToken (replacement only, required)
    The file’s token.

With the Idempotency-Key header; a repeat must send the same file and the same pageImages choice. The knowledge base must be managed, enabled and Ready. AnswerPal keeps the original and counts it towards the account’s storage: an account without storage space, or whose storage is full, gets 409 storage_quota_exceeded. When managed uploads are not available, the answer is 503 knowledge_source_storage_unavailable; GET .../capabilities tells this beforehand. The answer holds knowledgeBaseFileID, knowledgeBaseFileVersionID, fileName, sourceSizeBytes, sha256 and operation.

File (response)

  • knowledgeBaseFileID, displayName, status (Discovered, Pending, Ready, Failed, Removing or Removed), providerStatus
  • sizeBytes, usageBytes, createdAt, lastSynchronizedAt, warningCode, warningMessage
  • currentVersionID, concurrencyToken, pageImagesEnabled
  • versions (newest first)
    knowledgeBaseFileVersionID, versionNumber, fileName, status (PendingUpload, Uploading, Processing, Ready, Failed, Superseded, Removing or Removed), isActive, hasRetainedSource, hasProviderProjection, providerFileOwnedByAnswerPal, sourceSizeBytes, sha256, retainUntil, detachedAt, providerDeletedAt, sourcePurgedAt, lastErrorCode, lastErrorMessage, pdfPageCount, derivedImageSizeBytes and totalStoredSizeBytes.

List filter

status takes active (all but removed), completed (ready), in_progress, failed, cancelled or removed, in lower case. The answer is { "items": [...], "continuationToken": "...", "hasMore": true }; pass continuationToken to get the next page. On a linked knowledge base the list is read from OpenAI.

Detach, restore and permanent deletion

  • Detach takes the file out of the vector store; it becomes Removed and its original is kept until retainUntil (30 days). Body: { "concurrencyToken": "..." }.
  • Restore puts a detached file back, from the kept original when the OpenAI file is gone. Same body.
  • Delete provider file removes the OpenAI file of an inactive version that AnswerPal uploaded. It cannot be undone; when another version still uses the same OpenAI file, the answer is 409 provider_file_may_be_shared.
  • Purge source removes the kept original and the page images of an inactive version after retainUntil; before that the answer is 409 knowledge_source_retention_active. The active version cannot be purged.

A replaced version becomes Superseded with a retainUntil 30 days later. While another operation runs on the same file, a change answers 409 file_operation_in_progress.

Preview and download

The preview returns { "items": [ { "type", "text", "pageNumber" } ], "continuationToken", "hasMore" }; pageNumber is filled for PDFs whose page texts AnswerPal stored. The download returns the file with its content type and file name as an attachment. A managed original is checked against its size and SHA-256 first.

POST /api/knowledge-bases/14/files
Authorization: Bearer <token>
Idempotency-Key: kb14-upload-thermostat-manual-v1
Content-Type: multipart/form-data; boundary=b1

--b1
Content-Disposition: form-data; name="file"; filename="thermostat-manual.pdf"
Content-Type: application/pdf

<binary PDF>
--b1
Content-Disposition: form-data; name="pageImages"

true
--b1--

202 Accepted
Location: /api/knowledge-base-operations/b2a8f1c4-7d3e-4c59-8e6f-1a2b3c4d5e6f

{
  "knowledgeBaseFileID": 301,
  "knowledgeBaseFileVersionID": 412,
  "fileName": "thermostat-manual.pdf",
  "sourceSizeBytes": 2483120,
  "sha256": "9f2c...e41a",
  "operation": { "knowledgeBaseOperationID": "b2a8f1c4-7d3e-4c59-8e6f-1a2b3c4d5e6f", "type": "Ingest", "status": "Pending", ... }
}
GET /api/knowledge-bases/14/files/301
Authorization: Bearer <token>

200 OK
{
  "knowledgeBaseFileID": 301,
  "displayName": "thermostat-manual.pdf",
  "status": "Ready",
  "providerStatus": "completed",
  "sizeBytes": 2483120,
  "currentVersionID": 412,
  "concurrencyToken": "AAAAAAAACB0=",
  "pageImagesEnabled": true,
  "versions": [
    {
      "knowledgeBaseFileVersionID": 412,
      "versionNumber": 1,
      "fileName": "thermostat-manual.pdf",
      "status": "Ready",
      "isActive": true,
      "hasRetainedSource": true,
      "hasProviderProjection": true,
      "retainUntil": null,
      "pdfPageCount": 38,
      ...
    }
  ],
  ...
}
POST /api/knowledge-bases/14/files/301/detach
Authorization: Bearer <token>
Idempotency-Key: kb14-detach-301-01
Content-Type: application/json

{ "concurrencyToken": "AAAAAAAACB0=" }

202 Accepted
{
  "knowledgeBaseFileID": 301,
  "knowledgeBaseFileVersionID": 412,
  "operation": { "type": "Detach", "status": "Pending", ... }
}

Operations and adoption

Operation (response)

  • knowledgeBaseOperationID (GUID), knowledgeBaseID, knowledgeBaseFileID, knowledgeBaseFileVersionID
  • type
    Provision, Ingest, Replace, Detach, Restore, DeleteProviderFile, PurgeSource, DeleteKnowledgeBase or Adopt.
  • status
    Pending, Running, Succeeded, Failed or Cancelled.
  • attemptCount, retryable, creationDate, lastModifiedDate, startedAt, completedAt, lastErrorCode, lastErrorMessage
  • totalItems, completedItems, failedItems
    Progress of an adoption; 0 for the other types.

AnswerPal retries temporary failures itself. A failed operation with retryable true (for example a timeout or an OpenAI error) can be started again with POST .../retry. Only an adoption can be cancelled.

Adoption (body)

  • concurrencyToken (required)
    The token of the linked knowledge base.
  • name (string, required, 1 to 150 characters)
    The name of the new managed knowledge base.
  • documentIDs (array, required, may be empty)
    Documents now linked to the linked knowledge base whose link moves to the new one when the adoption succeeds; no duplicates.

With the Idempotency-Key header. The linked knowledge base must be enabled and Ready. AnswerPal creates a new vector store, copies every file, checks it with the upload rules and keeps the original (this counts towards storage). The new knowledge base is Adopting and disabled until the operation succeeds. The linked knowledge base itself is not changed. A cancelled adoption leaves the new knowledge base disabled.

GET /api/knowledge-base-operations/b2a8f1c4-7d3e-4c59-8e6f-1a2b3c4d5e6f
Authorization: Bearer <token>

200 OK
{
  "knowledgeBaseOperationID": "b2a8f1c4-7d3e-4c59-8e6f-1a2b3c4d5e6f",
  "knowledgeBaseID": 14,
  "knowledgeBaseFileID": 301,
  "knowledgeBaseFileVersionID": 412,
  "type": "Ingest",
  "status": "Succeeded",
  "attemptCount": 1,
  "retryable": false,
  "startedAt": "2026-12-01T10:02:11",
  "completedAt": "2026-12-01T10:02:48",
  "lastErrorCode": null,
  "lastErrorMessage": null,
  "totalItems": 0,
  "completedItems": 0,
  "failedItems": 0,
  ...
}
POST /api/knowledge-bases/15/adoptions
Authorization: Bearer <token>
Idempotency-Key: kb15-adopt-01
Content-Type: application/json

{
  "concurrencyToken": "AAAAAAAAB+k=",
  "name": "Support articles (managed)",
  "documentIDs": [140]
}

202 Accepted
{
  "knowledgeBase": { "knowledgeBaseID": 16, "status": "Adopting", "isEnabled": false, "adoptedFromKnowledgeBaseID": 15, ... },
  "operation": { "type": "Adopt", "status": "Pending", "totalItems": 0, ... }
}

Access and status codes

Every endpoint needs a bearer token with the role Configurator or Administrator. The access line of each endpoint above is the reference. Errors are problem details: type, title, status, detail and a code such as knowledge_base_not_found. Invalid input caught before processing (for example a missing concurrencyToken or a maxResults above 50) answers a list of field errors without code. Times are UTC; times read back from storage are written without the Z.

  • 200 OK, 201 Created, 202 Accepted
    Success; 202 means an operation was started.
  • 400 Bad Request
    Invalid input, a missing or invalid Idempotency-Key, a wrong confirmation, a file type that is not allowed or whose content does not match, a knowledge base that is deleted or disabled.
  • 401 Unauthorized
    No valid token, or OpenAI refused the account’s key (provider_authentication_failed) or the account has none (knowledge_credentials_missing).
  • 403 Forbidden
    A role without access, or OpenAI refused access to the store.
  • 404 Not Found
    No knowledge base, file, version, document or operation with that ID for this account, or the store does not exist at OpenAI.
  • 409 Conflict
    A token or idempotency key that does not match, a linked knowledge base that cannot be changed, a knowledge base that is not ready, an operation that already runs, a full storage, or a retention period that has not passed.
  • 429 Too Many Requests, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout
    OpenAI limited, refused or did not answer in time, or managed uploads are not available. Try again later.

FAQ

Through a prompt document. Link the knowledge base to the document (POST /api/knowledge-bases/linked with documentID for a linked store, or the knowledge base IDs on the document, see the Documents page) and switch on vector search on the document. While AnswerPal writes a reply with that document, it searches the linked knowledge bases.

Managed uploads need storage for the originals. When GET /api/knowledge-bases/capabilities returns sourceStorageConfigured false, uploads, replacements and adoptions answer 503 knowledge_source_storage_unavailable.

No. Change them in OpenAI, or adopt the linked knowledge base: the copy is managed and can be changed through AnswerPal.

The previous version is kept for 30 days. After its retainUntil, delete its original with DELETE .../versions/{knowledgeBaseFileVersionID}/source.

Need more help?

Table of Contents

AnswerPal: AI-powered customer service solutions to elevate your support and communication effortlessly.

Contact

For all support, sales, and partnership inquiries, email us at info@answerpal.eu

AnswerPal
Bisschoppenhoflaan 380
2100 Antwerp
Belgium

+32.36416685

BE 0862.692.858