> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elanlanguages.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Documents

> On this page, we'll dive into the different context document endpoints you can use to manage files within your context stores.

Context documents are reference files stored within a context store. These can be glossaries, style guides, or reference materials that support your translation workflows. On this page, we'll dive into the different context document endpoints you can use to manage documents programmatically.

## The context document model

The context document model contains metadata about files stored in a context store, including the title, type, language, and processing status.

### Properties

<ResponseField name="id" type="integer">
  Unique identifier for the context document.
</ResponseField>

<ResponseField name="store_id" type="integer">
  The ID of the context store this document belongs to.
</ResponseField>

<ResponseField name="title" type="string">
  The title of the document.
</ResponseField>

<ResponseField name="description" type="string">
  An optional description of the document.
</ResponseField>

<ResponseField name="document_type" type="string">
  The type of document. Possible values: `glossary`, `styleguide`, `reference`.
</ResponseField>

<ResponseField name="languages" type="array of strings">
  Language codes of the document content (optional).
</ResponseField>

<ResponseField name="status" type="string">
  The processing status. Possible values: `processing`, `ready`, `failed`.
</ResponseField>

<ResponseField name="file_name" type="string">
  The original filename of the uploaded file.
</ResponseField>

<ResponseField name="file_type" type="string">
  The file extension type.
</ResponseField>

<ResponseField name="file_size" type="integer">
  Size of the file in bytes.
</ResponseField>

<ResponseField name="mime_type" type="string">
  The MIME type of the file (optional).
</ResponseField>

<ResponseField name="is_active" type="boolean">
  Whether or not the document is active.
</ResponseField>

<ResponseField name="created_at" type="timestamp">
  Timestamp of when the document was uploaded.
</ResponseField>

<ResponseField name="updated_at" type="timestamp">
  Timestamp of when the document was last updated.
</ResponseField>

***

## List all context documents

**`GET /v1/context/:store_id/documents`**

This endpoint allows you to retrieve a paginated list of all documents in a context store. By default, a maximum of 50 documents are shown per page.

### Optional parameters

<ParamField query="limit" type="integer">
  Maximum number of documents to return (default: 50).
</ParamField>

<ParamField query="offset" type="integer">
  Number of documents to skip (default: 0).
</ParamField>

<ParamField query="document_type" type="string">
  Filter by document type: `glossary`, `styleguide`, or `reference`.
</ParamField>

<ParamField query="language" type="string">
  Filter by document language. Matches documents that have the specified language in their languages list.
</ParamField>

<ParamField query="is_active" type="boolean">
  Filter by active status.
</ParamField>

<ParamField query="order_by" type="string">
  Field to order by (default: "created\_at").
</ParamField>

<ParamField query="order_desc" type="boolean">
  Order in descending order (default: true).
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -G https://api.elanlanguages.ai/v1/context/1/documents \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}"
  ```
</CodeGroup>

```json Response theme={null}
{
  "documents": [
    {
      "id": 1,
      "store_id": 1,
      "title": "Product Style Guide",
      "description": "Official style guide for product documentation",
      "document_type": "styleguide",
      "languages": ["en"],
      "status": "ready",
      "file_name": "style-guide.pdf",
      "file_type": "pdf",
      "file_size": 2048576,
      "mime_type": "application/pdf",
      "is_active": true,
      "created_at": "2025-12-21T10:30:29.114Z",
      "updated_at": "2025-12-21T10:30:29.114Z"
    }
  ],
  "total": 1,
  "limit": 50,
  "offset": 0
}
```

***

## Upload a context document

**`POST /v1/context/:store_id/documents`**

This endpoint allows you to upload a new document to a context store. Documents are uploaded using multipart form data and stored in S3. Metadata is stored in the database with a reference to the S3 file.

### Supported file types

* PDF (.pdf)
* Microsoft Word (.docx)
* CSV (.csv)
* Text (.txt)

### Maximum file size

50MB per file

### Required form fields

<ParamField body="file" type="file" required>
  The document file to upload.
</ParamField>

<ParamField body="title" type="string" required>
  The title for the document.
</ParamField>

<ParamField body="document_type" type="string" required>
  The type of document: `glossary`, `styleguide`, or `reference`.
</ParamField>

### Optional form fields

<ParamField body="description" type="string">
  A description of the document.
</ParamField>

<ParamField body="languages" type="string">
  Comma-separated language codes of the document content.
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.elanlanguages.ai/v1/context/1/documents \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}" \
    -F "file=@/path/to/style-guide.pdf" \
    -F "title=Product Style Guide" \
    -F "document_type=styleguide" \
    -F "description=Official style guide for product documentation" \
    -F "languages=en"
  ```
</CodeGroup>

```json Response theme={null}
{
  "id": 1,
  "store_id": 1,
  "title": "Product Style Guide",
  "description": "Official style guide for product documentation",
  "document_type": "styleguide",
  "languages": ["en"],
  "status": "processing",
  "file_name": "style-guide.pdf",
  "file_type": "pdf",
  "file_size": 2048576,
  "mime_type": "application/pdf",
  "is_active": true,
  "created_at": "2025-12-21T10:34:41.135Z",
  "updated_at": "2025-12-21T10:34:41.135Z"
}
```

***

## Retrieve a context document

**`GET /v1/context/:store_id/documents/:document_id`**

This endpoint allows you to retrieve metadata about a specific context document. To download the actual file content, use the [download endpoint](#download-a-context-document).

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.elanlanguages.ai/v1/context/1/documents/1 \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}"
  ```
</CodeGroup>

```json Response theme={null}
{
  "id": 1,
  "store_id": 1,
  "title": "Product Style Guide",
  "description": "Official style guide for product documentation",
  "document_type": "styleguide",
  "languages": ["en"],
  "status": "ready",
  "file_name": "style-guide.pdf",
  "file_type": "pdf",
  "file_size": 2048576,
  "mime_type": "application/pdf",
  "is_active": true,
  "created_at": "2025-12-21T10:34:41.135Z",
  "updated_at": "2025-12-21T10:34:41.135Z"
}
```

***

## Update a context document

**`PUT /v1/context/:store_id/documents/:document_id`**

This endpoint allows you to update the metadata of a context document. Note: You cannot change the file itself through this endpoint. To replace a file, delete the document and upload a new one.

### Optional attributes

<ParamField body="title" type="string">
  The title of the document.
</ParamField>

<ParamField body="description" type="string">
  A description of the document.
</ParamField>

<ParamField body="document_type" type="string">
  The type of document: `glossary`, `styleguide`, or `reference`.
</ParamField>

<ParamField body="languages" type="array of strings">
  Language codes of the document content.
</ParamField>

<ParamField body="is_active" type="boolean">
  Whether or not the document is active.
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT https://api.elanlanguages.ai/v1/context/1/documents/1 \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}" \
    -H "Content-Type: application/json" \
    -d '{
      "title": "Updated Style Guide",
      "languages": ["en-US"],
      "is_active": true
    }'
  ```
</CodeGroup>

```json Response theme={null}
{
  "id": 1,
  "store_id": 1,
  "title": "Updated Style Guide",
  "description": "Official style guide for product documentation",
  "document_type": "styleguide",
  "languages": ["en-US"],
  "status": "ready",
  "file_name": "style-guide.pdf",
  "file_type": "pdf",
  "file_size": 2048576,
  "mime_type": "application/pdf",
  "is_active": true,
  "created_at": "2025-12-21T10:34:41.135Z",
  "updated_at": "2025-12-21T10:39:04.329Z"
}
```

***

## Download a context document

**`GET /v1/context/:store_id/documents/:document_id/download`**

This endpoint allows you to download the actual file content of a context document from S3. The response will be the document file itself with appropriate content-type headers set based on the file type.

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.elanlanguages.ai/v1/context/1/documents/1/download \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}" \
    --output style-guide.pdf
  ```
</CodeGroup>

***

## Delete a context document

**`DELETE /v1/context/:store_id/documents/:document_id`**

This endpoint allows you to delete a context document. This is a soft delete operation. By default, this will also remove the associated S3 file.

### Optional parameters

<ParamField query="delete_s3_file" type="boolean">
  Whether to delete the associated S3 file (default: true).
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE https://api.elanlanguages.ai/v1/context/1/documents/1 \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}"
  ```
</CodeGroup>
