---
title: "Get Document By Key"
method: GET
path: "/knowledge/{knowledge_base_id}/documents/{document_key}"
tags: ["knowledge"]
---

# Get Document By Key

`GET /knowledge/{knowledge_base_id}/documents/{document_key}`

Get a document from a knowledge base by its key

## Path parameters

- `knowledge_base_id` string, uuid, required — The id of the knowledge base
- `document_key` string, required — The key of the document to retrieve

## Response `200`

Successful Response

- GetDocumentResponse
  - `id` string, uuid, required — The id of the document
  - `key` string, required — The key of the document
  - `segments` DocumentSegment[], required — The content segments of the document. Documents are split into segments for indexing, and segments may have overlapping text.
    - `id` string, uuid, required — The id of the segment
    - `content` string, required — The content of the segment
  - `metadata` object, nullable — The metadata of the document

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `402` — Payment Required (out of credits)
- `404` — Not Found
- `422` — Request Validation Error

---

[API](https://skmtc.dev/opper/apis/opper-api-v2.md) · [All operations](https://skmtc.dev/opper/apis/opper-api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/opper/opper-api-v2/revisions/d3ccdaa15678/schema)
