> For a complete page index of the Captain API documentation, fetch https://docs.filesearch.dev/llms.txt?excludeSpec=true

# Get Document - v2 (Legacy)

GET https://api.filesearch.dev/v2/collections/{collection_name}/documents/{document_id}

Retrieve a single document by ID using the v2 compatibility shape.

Reference: https://docs.filesearch.dev/reference/v2/document

## Request

### Path parameters

- `collection_name` (string, required)
- `document_id` (string, required)

### Query parameters

- `include_bbox` (boolean, optional, default: false) — When true, include normalized element layout (bounding boxes) for the document under `bounding_boxes`. Omitted by default to keep the response lean.

## Response

### 200

Successful Response

- `chunk_count` (integer, required)
- `chunks` (list of DocumentChunk, required)
- `collection_name` (string, required)
- `document_id` (string, required)
- `metadata` (DocumentMetadata, required)
- `regions` (list of FileSearchRegion, optional, nullable)

## Types

### DocumentChunk

A chunk returned by the get-document endpoint.

- `chunk_id` (string, required)
- `content` (string, required, default: )
- `chunk_index` (integer, optional, nullable)
- `location` (FileSearchLocation, optional, nullable) — Source position for a returned chunk. Fields that do not apply to the source type are returned as null.
- `regions` (list of FileSearchRegion, optional, nullable)
- `custom_metadata` (map from string to any, optional, nullable)
- `relations` (list of ChunkRelation, optional, nullable)
- `related_chunks` (list of RelatedChunk, optional, nullable)
- `metadata` (map from string to any, optional, nullable)
- `page_start` (integer, optional, nullable)
- `page_end` (integer, optional, nullable)
- `start_sec` (double, optional, nullable)
- `end_sec` (double, optional, nullable)
- `tokens` (integer, optional, nullable)
- `category` (string, optional, nullable)
- `parent_chunk_index` (integer, optional, nullable)

### DocumentMetadata

- `created_at` (string, optional, nullable)
- `file_size` (integer, optional, nullable)
- `file_type` (string, optional, nullable)
- `filename` (string, optional, nullable)
- `indexed_at` (string, optional, nullable)
- `indexing_status` (string, optional, nullable)
- `mime_type` (string, optional, nullable)
- `summary` (string, optional, nullable)
- `tags` (list of string, optional, nullable)
- `uri` (string, optional, nullable)
- `custom_metadata` (map from string to any, optional, nullable)

### FileSearchRegion

Extracted layout region from a document, page, or image.

- `region_id` (string, optional, nullable)
- `type` (string, optional, nullable) — Region category, such as `text`, `title`, `section_header`, `key_value`, `table`, `chart`, or `image`.
- `page` (integer, optional, nullable) — Page number where the region appears.
- `bbox` (FileSearchRegionBbox, optional, nullable) — Bounding box for rendering the region. The origin is the top-left corner of the rendered page or image. Values are expressed as fractions of rendered dimensions, so draw with `x = left * renderedWidth`, `y = top * renderedHeight`, `width = width * renderedWidth`, and `height = height * renderedHeight`.
- `text` (string, optional, nullable) — Text extracted from the region when available.
- `description` (string, optional, nullable) — Generated description of the region when available.
- `image_url` (string, optional, nullable) — Image URL for the region when the extraction pipeline produced one.
- `confidence` (double, optional, nullable) — Extraction confidence for the region when available.
- `metadata` (map from string to any, optional, nullable)
- `extraction` (enum, optional, nullable) — Whether this region's parsed content is included. "unavailable" marks a region whose extracted text was withheld because it could not be verified as reliable (for example a chart the parser could not read accurately): its text and description are null while bbox and image_url remain valid, so the original region can still be rendered. Null or absent means the content is included ("ok"); the field is never backfilled onto older data. When present, extraction supersedes confidence.
  - Allowed values: `ok`, `unavailable`

### FileSearchLocation

Source position for a returned chunk. Fields that do not apply to the source type are returned as null.

- `page_start` (integer, optional, nullable) — First page covered by the chunk for paged documents.
- `page_end` (integer, optional, nullable) — Last page covered by the chunk for paged documents.
- `start_sec` (double, optional, nullable)
- `end_sec` (double, optional, nullable)
- `sheet_name` (string, optional, nullable) — Worksheet name for spreadsheet chunks.
- `section` (string, optional, nullable)
- `row_start` (integer, optional, nullable) — First spreadsheet row covered by the chunk.
- `row_end` (integer, optional, nullable) — Last spreadsheet row covered by the chunk.
- `col_start` (integer, optional, nullable) — First spreadsheet column covered by the chunk.
- `col_end` (integer, optional, nullable) — Last spreadsheet column covered by the chunk.
- `columns` (list of string, optional, nullable)
- `row_role` (string, optional, nullable)

### ChunkRelation

Graph relation between chunks.

- `relation_id` (string, required) — Relation identifier.
- `source_chunk_id` (string, required) — Chunk ID where the relation starts.
- `target_chunk_id` (string, required) — Chunk ID where the relation points.
- `target_status` (string, required) — Whether the target chunk could be resolved.
- `relation_type` (string, required) — Application-defined relation label.
- `metadata` (map from string to any, required) — Application-supplied metadata for the relation.
- `target_document_id` (string, optional, nullable) — Document ID for the target chunk when known.
- `created_at` (string, optional, nullable) — Relation creation timestamp.
- `updated_at` (string, optional, nullable) — Relation update timestamp.

### RelatedChunk

- `chunk_id` (string, required)
- `document_id` (string, optional, nullable)
- `text` (string, optional, nullable)
- `location` (FileSearchLocation, optional, nullable) — Source position for a returned chunk. Fields that do not apply to the source type are returned as null.
- `metadata` (map from string to any, optional, nullable)

### FileSearchRegionBbox

Bounding box for rendering the region. The origin is the top-left corner of the rendered page or image. Values are expressed as fractions of rendered dimensions, so draw with `x = left * renderedWidth`, `y = top * renderedHeight`, `width = width * renderedWidth`, and `height = height * renderedHeight`.

- `top` (double, optional)
- `left` (double, optional)
- `width` (double, optional)
- `height` (double, optional)

## Examples

**Response**

```json
{
  "chunk_count": 1,
  "chunks": [
    {
      "chunk_id": "doc_abc123:3",
      "content": "The contract shall commence on the Effective Date...",
      "chunk_index": 3
    }
  ],
  "collection_name": "my_documents",
  "document_id": "doc_abc123",
  "metadata": {
    "filename": "contract.pdf"
  }
}
```

**SDK Code**

```python Python REST
import requests
import json

BASE_URL = "https://api.filesearch.dev"
API_KEY = "your_api_key"
COLLECTION_NAME = "my_documents"
DOCUMENT_ID = "doc_abc123"

response = requests.get(
    f"{BASE_URL}/v2/collections/{COLLECTION_NAME}/documents/{DOCUMENT_ID}",
    headers={"Authorization": f"Bearer {API_KEY}"},
    timeout=30.0,
)

print(json.dumps(response.json(), indent=2))
```

```typescript TypeScript REST
const BASE_URL = "https://api.filesearch.dev";
const API_KEY = "your_api_key";
const collectionName = "my_documents";
const documentId = "doc_abc123";

const response = await fetch(
  `${BASE_URL}/v2/collections/${collectionName}/documents/${documentId}`,
  { headers: { Authorization: `Bearer ${API_KEY}` } },
);

console.log(JSON.stringify(await response.json(), null, 2));
```