---
title: Add a context document
description: Save Markdown as context for a repository.
url: https://www.hacktron.ai/docs/api/context-documents/add-context-document
---

# Add a context document

Saves Markdown, such as a design decision, a product spec, or an accepted risk, as a context document on a repository. Use the repository's id from [`GET /repos`](/docs/api/repos/list-repos). `name` holds up to 200 characters and `content` up to 200,000. You need the member role or above.

Scans read the document, and the next threat model update folds it into the repository's [threat model](/docs/platform/context/threat-models). To start that update now, call [`POST /repositories/{id}/threat-model/sync`](/docs/api/repos/update-repository-threat-model).

## Request

`POST /context-documents`

Send an [API key](/docs/api/authentication) with the `write` scope in the `X-Api-Key` header.

:::examples

```bash title="Request" wrap=false
curl -X POST "https://api.hacktron.ai/v1/context-documents" \
  -H "X-Api-Key: $HACKTRON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "repository_id": "123e4567-e89b-12d3-a456-426614174000",
  "name": "Link previews: security decisions",
  "content": "# Link previews\n\nThe preview service fetches only public http and https URLs..."
}'
```

```json title="Response 200 OK" showLineNumbers=false wrap=false
{
  "id": "5e6f7a8b-9c0d-4e1f-8a2b-3c4d5e6f7a8b",
  "name": "Link previews: security decisions",
  "kind": "document",
  "updated_at": "2026-11-08T10:12:03.000Z",
  "readable": true
}
```

:::

### Body

A required `application/json` body.

| Field | Type | Description |
| --- | --- | --- |
| `repository_id` | string (uuid), required | Id from the repository list. |
| `name` | string, required | Document title. |
| `content` | string, required | Markdown content. |

## Responses

### 200 OK

| Field | Type | Description |
| --- | --- | --- |
| `id` | string (uuid), required | |
| `name` | string, required | |
| `kind` | string, required | One of `threat_model`, `application_threat_model`, or `document`. |
| `updated_at` | string (date-time), required | |
| `readable` | boolean, required | Whether the content is text this API returns; PDFs open in Hacktron. |
