Articles in this section

Knowledge base API reference

Use the knowledge base API to create and manage knowledge bases, link files from Celigo Storage, and check indexing status and health. This reference is for developers who automate knowledge bases through the API. You attach a knowledge base to an AI agent through the agent's import, using the imports API. For setup instructions and examples, see Create and manage knowledge bases for AI agents.

Base URL

Region you sign in to Base URL
integrator.io https://api.integrator.io/v1/knowledgebases
eu.integrator.io https://api.eu.integrator.io/v1/knowledgebases
au.integrator.io https://api.au.integrator.io/v1/knowledgebases
ca.integrator.io https://api.ca.integrator.io/v1/knowledgebases

Each environment has its own knowledge bases. A request reads and changes the knowledge bases of its token's environment.

Authentication

Send an API token with Full access as a bearer token:

Authorization: Bearer <token>

A request without a token gets 401 access_token_required. A request with any other token gets 401 access_restricted. Requests that send a body must use Content-Type: application/json, or they get 415 invalid_content_type.

Endpoints

Method and path What it does
GET /v1/knowledgebases Lists knowledge bases.
POST /v1/knowledgebases Creates a knowledge base.
GET /v1/knowledgebases/{_id} Returns one knowledge base.
PATCH /v1/knowledgebases/{_id} Changes the fields in the body.
PUT /v1/knowledgebases/{_id} Replaces every field.
DELETE /v1/knowledgebases/{_id} Deletes a knowledge base and its index.
GET /v1/knowledgebases/{_id}/files Lists the files linked to a knowledge base.
POST /v1/knowledgebases/{_id}/files/link Links a Celigo Storage file and queues it for indexing.
DELETE /v1/knowledgebases/{_id}/files/{_kbFileId} Removes a file from a knowledge base.
GET /v1/knowledgebases/{_id}/health Returns one knowledge base's health.
GET /v1/knowledgebases/health?ids= Returns the health of up to 50 knowledge bases.

Knowledge base

Field Description
_id The knowledge base's ID. Read-only.
name Required. Up to 100 characters. Unique within the environment, ignoring case.
description Up to 2,000 characters. The agent reads it, with the name, to decide when to search.
contentExpiration What a search does when the content is older than contentAge: never, warn, or block. Default: warn.
contentAge { "value": <1 to 10000>, "unit": "days" \| "weeks" \| "months" }. A month is 30 days. Required unless contentExpiration is never.
_integrationId The integration the knowledge base is registered to, which controls who can see and change it. Must be an integration in the environment. Optional with an API token with Full access.
createdAt, lastModified Timestamps. Read-only.

Unknown fields in a request body are ignored.

List knowledge bases

GET /v1/knowledgebases
Parameter Description
limit Knowledge bases per page, from 1 to 1,000. Default: 1000.
sort_by name or lastModified. Default: name.
after, before Opaque cursors from the Link header's rel="next" and rel="prev" links. Send them back unchanged, and never both together.
_integrationId Returns only knowledge bases registered to this integration.
ids Comma-separated knowledge base IDs, up to 50.

The response is 200 OK with an array of knowledge bases. When there are more, the Link header holds the next and previous pages.

Create a knowledge base

POST /v1/knowledgebases

The body takes name, description, contentExpiration, contentAge, and _integrationId. The response is 201 Created with the knowledge base. Send contentExpiration with every create: a body that leaves out both contentExpiration and contentAge gets 422 missing_required_field, because the default, warn, needs a contentAge.

Update a knowledge base

PATCH /v1/knowledgebases/{_id}
PUT /v1/knowledgebases/{_id}

PATCH changes only the fields in the body, and null clears an optional field. PUT replaces every field: a field it leaves out is cleared, contentExpiration returns to warn, and leaving out _integrationId removes the registration. Use PATCH for routine changes. Both return 200 OK with the knowledge base, and the change applies at each agent's next search.

Delete a knowledge base

DELETE /v1/knowledgebases/{_id}

The response is 204 No Content. Deleting removes the knowledge base's index and can't be undone. Its files stay in Celigo Storage.

  • 409 knowledge_base_in_use: AI agents still list the knowledge base. The message names up to 10 of them. Detach it and try again.
  • 502 knowledge_base_delete_failed: Celigo couldn't remove the index, and the knowledge base wasn't deleted. Try again later.

List a knowledge base's files

GET /v1/knowledgebases/{_id}/files
Parameter Description
limit Files per page, from 1 to 200. Default: 50.
after The cursor from the Link header's rel="next" link. The last page has no Link header.

The response is 200 OK with an array of files:

Field Description
_id The file's ID within the knowledge base. Use it to remove the file.
_fileId The file's Celigo Storage ID.
filename The file name sent when the file was linked.
source How the file was added. manual means it was linked with POST /files/link.
status queued, processing, indexed, or failed.
errorMessage Why indexing failed, or null.
chunkCount The number of passages the file was split into, or null until it's indexed.
indexedAt When the file was last indexed, or null.
sizeBytes The file's size, or null.
lastModified When the file's entry in the knowledge base last changed, or null.
addedAt, _addedByUserId When the file was added and by whom. null until the file is indexed.
_lastRunId The ID of the file's latest indexing run, or null.

Link a file

POST /v1/knowledgebases/{_id}/files/link
{ "_fileId": "683b2a0e1c3d5f001a9e8b01", "filename": "returns-policy-2026.pdf" }

Both fields are required. _fileId is the file's Celigo Storage ID, and filename is up to 256 characters. Your token must be able to open the file in Celigo Storage. The response is 202 Accepted, and indexing runs in the background:

{
  "_id": "6a1f0c9d9b0c4d001e8f7b10",
  "_fileId": "683b2a0e1c3d5f001a9e8b01",
  "filename": "returns-policy-2026.pdf",
  "status": "queued",
  "_runId": "6a1f0c9d9b0c4d001e8f7b11"
}
Status Code When it happens
404 knowledge_base_not_found The knowledge base doesn't exist, or your token can't see it.
404 storage_file_not_found The file doesn't exist, its upload hasn't finished, or your token can't open it.
409 FileAlreadyLinked The file is already linked to this knowledge base.
413 UploadAssetTooLarge The file is larger than 50 MB.
415 UploadAssetUnsupported The file isn't a PDF.
429 ratelimit_exceeded Too many file requests in a short period. Retry after the time in the Retry-After header.
502 knowledge_base_link_failed The file couldn't be queued for indexing. Try again.

Remove a file

DELETE /v1/knowledgebases/{_id}/files/{_kbFileId}

{_kbFileId} is the file's _id within the knowledge base, not its Celigo Storage ID. The response is 202 Accepted, and the file is removed from the index in the background. The file stays in Celigo Storage. A file that isn't in the knowledge base gets 404 knowledge_base_file_not_found.

Knowledge base health

GET /v1/knowledgebases/{_id}/health
GET /v1/knowledgebases/health?ids=<id>,<id>

The second form takes up to 50 comma-separated IDs and returns an array. IDs that don't exist, or that your token can't see, are left out.

Field Description
availabilityState Processing: a file is being indexed. Current: every file is indexed, or there are no files. Limited: some files are indexed and some failed. Error: every file failed.
needsAttention true when reasons isn't empty.
reasons fileFailed: a file failed to index. contentExpired: content is past its age, and expiration is warn. contentBlocked: content is past its age, and expiration is block.
filesTotal, filesIndexed, filesProcessing, filesFailed File counts.
contentExpiration, contentAge The knowledge base's settings.
contentAgeSeconds The content's age: the time since a file with new content last finished indexing.
contentAgeLimitSeconds contentAge in seconds, or null.
lastContentChangedAt When the content last changed. null until a file is indexed.
contentExpiresAt When the content passes its content age. null when contentExpiration is never or no file is indexed.
lastProcessingRunAt When the knowledge base's latest indexing run was queued, or null.

Attach knowledge bases to an AI agent

An AI agent import lists its knowledge bases in aiAgent.attachedKnowledgeBaseIds, an array of up to 50 distinct knowledge base IDs. Save it with the imports API (/v1/imports):

  • Use PATCH with replace on /aiAgent/attachedKnowledgeBaseIds, sending the whole list. An empty list detaches every knowledge base. add at /- and remove at an array index aren't supported.
  • With PUT, include the list in the aiAgent object. A PUT that leaves it out can clear it.
  • Each knowledge base the save adds is checked. It must exist in the agent's environment, and the token must be able to see it. Knowledge bases already on the agent aren't checked again, so an agent whose knowledge base was deleted can still be saved, and you can detach it.
Status Code When it happens
422 attached_knowledge_base_invalid A knowledge base the save adds doesn't exist in this environment, or the token can't see it. The message lists the IDs.
422 invalid_field The list holds more than 50 knowledge base IDs.
503 knowledge_base_validation_unavailable Celigo couldn't verify the knowledge bases. Nothing was saved. Try again.

A clone within the same environment keeps the list. A clone into another environment, and a template or integration app install, starts with an empty list.

Errors

Error responses have this shape:

{
  "errors": [
    {
      "field": "name",
      "code": "name_already_taken",
      "message": "A knowledge base named 'Returns policy' already exists in this account. Knowledge base names are case insensitive.",
      "source": "resource"
    }
  ]
}

field is present on validation errors.

Status When it happens
400 invalid_ref An ID in the path or query isn't a valid ID.
400 invalid_request The body isn't a JSON object.
401 access_token_required The request has no API token.
401 access_restricted The token isn't an API token with Full access.
403 access_restricted The caller can't change knowledge bases registered to that integration.
404 knowledge_base_not_found The knowledge base doesn't exist, or the caller can't see it.
409 See Delete a knowledge base and Link a file.
413, 415 See Link a file. 415 invalid_content_type means the body isn't application/json.
422 Validation failed: missing_required_field, invalid_field, name_already_taken, knowledge_base_integration_required, knowledge_base_invalid_integration, or invalid_query_param.
429 ratelimit_exceeded Too many requests in a short period. Retry after the time in the Retry-After header.
502, 503 A Celigo service couldn't complete the request (downstream_error) or didn't respond (downstream_unreachable). Try again.

Related articles