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

# List Chunk Relations

GET https://api.filesearch.dev/v3/collections/{collection_name}/chunks/{chunk_id}/relations

List typed graph relations connected to a chunk.

Reference: https://docs.filesearch.dev/reference/v3/documents/chunk/relations

## Request

### Path parameters

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

### Query parameters

- `relation_types` (list of string, optional, nullable)
- `relation_direction` (enum, optional, default: outgoing)
  - Allowed values: `outgoing`, `incoming`, `both`

## Response

### 200

List Chunk Relations response.

- `chunk_id` (string, required)
- `relations` (list of ChunkRelationFromV3, optional)

## Errors

### 401 Unauthorized Error

Missing or invalid authentication.

- `error` (string, required) — Error kind. `HTTP_ERROR` for errors raised by the route.
- `message` (string, required) — What went wrong.
- `path` (string, required) — The request path.
- `status_code` (integer, optional) — The HTTP status code.

### 403 Forbidden Error

Collection is inactive.

- `error` (string, required) — Error kind. `HTTP_ERROR` for errors raised by the route.
- `message` (string, required) — What went wrong.
- `path` (string, required) — The request path.
- `status_code` (integer, optional) — The HTTP status code.

### 404 Not Found Error

Collection not found.

- `error` (string, required) — Error kind. `HTTP_ERROR` for errors raised by the route.
- `message` (string, required) — What went wrong.
- `path` (string, required) — The request path.
- `status_code` (integer, optional) — The HTTP status code.

## Types

### ChunkRelationFromV3

- `relation_id` (string, required)
- `source_chunk_id` (string, required)
- `target_chunk_id` (string, required)
- `relation_type` (string, required)
- `target_document_id` (string, optional, nullable)
- `target_status` (enum, optional, default: unknown)
  - Allowed values: `found`, `missing`, `unknown`
- `metadata` (ChunkRelationFromV3Metadata, optional)
- `created_at` (string, optional, nullable)
- `updated_at` (string, optional, nullable)

### ChunkRelationFromV3Metadata

## Examples

**Response**

```json
{
  "chunk_id": "chunk_agri_report_001",
  "relations": [
    {
      "relation_id": "rel_agri_cites_001",
      "source_chunk_id": "chunk_agri_report_001",
      "target_chunk_id": "chunk_ipcc_summary_014",
      "relation_type": "cites",
      "target_document_id": "doc_ipcc_summary_2023",
      "target_status": "found",
      "metadata": {
        "citation": "IPCC AR6 WGII Chapter 5"
      },
      "created_at": "2024-05-22T14:31:00Z",
      "updated_at": "2024-05-22T14:31:00Z"
    },
    {
      "relation_id": "rel_agri_supports_002",
      "source_chunk_id": "chunk_agri_report_001",
      "target_chunk_id": "chunk_yield_spreadsheet_018",
      "relation_type": "supports",
      "target_document_id": "doc_crop_yield_timeseries",
      "target_status": "found",
      "metadata": {
        "note": "Yield table supports the claim in this paragraph."
      },
      "created_at": "2024-05-22T14:36:00Z",
      "updated_at": "2024-05-22T14:36:00Z"
    }
  ]
}
```

**SDK Code**

```python
import json
import requests

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

headers = {
    "Authorization": f"Bearer {API_KEY}",
}

params = {
    "relation_types": [
        "example_relation_types"
    ],
    "relation_direction": "outgoing"
}

response = requests.get(
    f"{BASE_URL}/v3/collections/{COLLECTION_NAME}/chunks/{CHUNK_ID}/relations",
    headers=headers,
    params=params,
    timeout=30.0
)

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

```typescript
const BASE_URL = "https://api.filesearch.dev";

const API_KEY = "your_api_key";

const collection_name = "my_documents";

const chunk_id = "doc_abc123:0";

const headers = {
  Authorization: `Bearer ${API_KEY}`,
};

const params = new URLSearchParams({
  "relation_direction": "outgoing"
});

params.append("relation_types", "example_relation_types");

const response = await fetch(`${BASE_URL}/v3/collections/${collection_name}/chunks/${chunk_id}/relations?${params}`, {
  method: "GET",
  headers,
});

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