---
title: "Create a knowledge base"
method: POST
path: "/v1/workspaces/{workspace_id}/knowledge-bases"
tags: ["Knowledge bases"]
---

# Create a knowledge base

`POST /v1/workspaces/{workspace_id}/knowledge-bases`

## Request

- Base URL: `https://api.stacksync.com`
- URL: `https://api.stacksync.com/v1/workspaces/{workspace_id}/knowledge-bases`
- Auth: HTTP bearer

Creates an empty knowledge base; add documents with Add a knowledge base document. With validate_only, the checks run and 204 answers, nothing is created.

## Path parameters

- `workspace_id` integer, required

## Query parameters

- `region` 'besg' | 'usnv', required

## Headers

- `Idempotency-Key` string, nullable: Makes the create retry-safe for 24 hours: a retry with the same key answers the resource the first call created, with the Idempotent-Replayed: true header, and creates nothing. 1 to 255 visible ASCII characters. The same key with a different request answers 422; while the first call still runs, 409.

## Request body

- CreateKnowledgeBaseBody
  - `name` string, required: Name, unique among the workspace's knowledge bases of the region
  - `resource_id` string, nullable: The id genies reference it by, unique in the region; derived from the name when absent (a renamed knowledge base keeps its own, so its old name needs another one)
  - `folder_id` string, uuid, nullable: Folder to list it in; the root when absent
  - `is_shared_with_workspace` boolean: true lets every member of the workspace use it
  - `validate_only` boolean: Run every check of the write and answer 204 without writing: a refused write answers the error the write would

## Response `201`

Created

- KnowledgeBase: A knowledge base, which genies answer from
  - `knowledge_base_id` string, required
  - `name` string, required
  - `resource_id` string, required
  - `region` string, required
  - `is_shared_with_workspace` boolean, required
  - `folder_id` string, nullable, required
  - `created_time` string, date-time, required
  - `last_modified_time` string, date-time, required

## Other responses

- `204`: No Content
- `400`: Bad Request
- `403`: Forbidden
- `409`: Conflict
- `422`: Unprocessable Content

---

[API](https://skmtc.dev/stacksync/apis/stacksync-api.md) - [All operations](https://skmtc.dev/stacksync/apis/stacksync-api/llms.txt) - [OpenAPI document](https://skmtc.dev/stacksync/apis/stacksync-api/revisions/21f4ba4b214e?raw)
