Description

This endpoint adds a new text resource to a specified knowledge base. The content is automatically split into chunks and embedded for vector similarity search.

Endpoint

POST /api/v1/knowledge-bases/add

Headers

  • Content-Type: application/json
  • Authorization: Bearer <API_KEY> (required for API access)

Request Body

{
  "knowledgeBaseId": "string", // Required. The ID of the knowledge base to add to.
  "name": "string", // Required. The name of the resource.
  "content": "string" // Required. The text content to add.
}

Responses

Success (201)

Returns the created resource object.

{
  "id": "string",
  "name": "string",
  "mimeType": "text/plain",
  "size": "number",
  "knowledgeBaseId": "string",
  "content": "string",
  "characterCount": "number",
  "createdAt": "string",
  "updatedAt": "string"
}
  • X-RateLimit-Limit: The rate limit for the user.
  • X-RateLimit-Remaining: The remaining number of requests for the user.

Bad Request (400)

Returned if required fields are missing or if adding the resource would exceed the knowledge base character limit.

{
  "error": "Error message describing the issue"
}

Unauthorized (401)

Returned if the API key is invalid or missing.

{
  "error": "Invalid or missing Authorization header"
}

Not Found (404)

Returned if the specified knowledge base is not found.

{
  "error": "Knowledge base not found"
}

Internal Server Error (500)

Returned if there’s an error during the addition process.

{
  "error": "Failed to query knowledge base"
}

Example Request

curl -X POST https://app.dumplingai.com/api/v1/knowledge-bases/add \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
  "knowledgeBaseId": "kb123456",
  "name": "Company Guidelines",
  "content": "This document outlines our company guidelines..."
}'

Notes

  • Credits used are calculated based on character count (1 credit per 10,000 characters).
  • There is a total character limit of 10,000,000 characters per knowledge base.
  • The content is automatically split into chunks and embedded for vector similarity search.
  • The resource is stored with metadata including size, character count, and mime type.
  • Usage is recorded for each addition, including the knowledge base ID and the number of credits used.
  • The content must be in plain text format (mime type: text/plain).

Rate Limiting

Rate limit headers (X-RateLimit-Limit and X-RateLimit-Remaining) are included in the response to indicate the user’s current rate limit status.