# List text document versions

Read a text document's version history, newest first. Includes version IDs, labels, word counts, contributors and timestamps.

POST https://api.brigg.app/v1/operations/documents.ListTextDocumentVersions

## Access & visibility

Allow `documents.ListTextDocumentVersions` on your API key.

**Workspace access by default.** Private member data requires [approved member delegation](https://developer.brigg.app/authentication#member-delegation) through `Brigg-Act-As`; the key supplies permissions while private ownership and project boundaries remain enforced.

[Set up authentication](https://developer.brigg.app/authentication) · [Choose permissions](https://developer.brigg.app/permissions)

## Request fields

Send a JSON object with the following fields. Required fields must be included; omit optional fields you do not need.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `file_id` | string | Yes | Use the file_id of a collaborative text document. Find an existing document with [ListDocuments](https://developer.brigg.app/reference/documents/ListDocuments) and select kind=text_document. An uploaded PDF, Word file or plain-text file is not a collaborative text document. [documents.CreateTextDocument](https://developer.brigg.app/reference/documents/CreateTextDocument). At least 1 character. |

## Work with text and saved versions

All documents use a stable `file_id`. Select `document_kind=text_document` from the listing for these collaborative text operations. [Read text document](https://developer.brigg.app/reference/documents/ReadTextDocument) returns its current Markdown and location.

For an exact change, use [Edit text document](https://developer.brigg.app/reference/documents/EditTextDocument) with the existing text and its replacement; this avoids sending an old full copy over another edit. [Replace text document](https://developer.brigg.app/reference/documents/ReplaceTextDocument) replaces the entire Markdown body. Send the read response’s `revision` as `expected_revision` to refuse intervening changes atomically. Re-read before resolving a failed match or revision conflict.

A saved `version_id` identifies historical content. List versions before reading or reverting one, and use [Checkpoint text document](https://developer.brigg.app/reference/documents/CheckpointTextDocument) when you need a named saved point. A revert changes current content; it is not just a historical read.

## Response

Returns **200 OK** with a JSON body.

This operation has no continuation cursor. An empty `items` array means no matching visible results were returned.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `items` | array of [Document version](#document-version-response-items) | Yes | Saved versions of the selected text document. This operation has no cursor pagination. |

### Document version · response.items[]

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `version_id` | string | Yes | Saved version identity. Keep it together with the document's file_id to read or restore this version. |
| `kind` | string | Yes | How the version was saved: named is a user-labelled checkpoint; auto is an automatic checkpoint, and pre_revert preserves the state before a restore. |
| `label` | string or null | Yes | Name supplied for a named checkpoint, or null when no label was recorded. |
| `word_count` | number | Yes | Number of words in the saved content. |
| `participants` | array of string | No | Account IDs of the people who edited this version. |
| `created_by` | string or null | Yes | Account that created the record, or null when no account is recorded. |
| `created_at` | number | Yes | Creation time in Unix milliseconds. |

## Errors & retries

This operation reads data. It needs no idempotency key and can be retried after a transient failure.

For rate limits, follow the server’s retry guidance and back off. See [HTTP errors](https://developer.brigg.app/http#errors) and [safe retries and limits](https://developer.brigg.app/reliability).

| HTTP status | Code | What to do |
| --- | --- | --- |
| 400 | `invalid_json` | Send a JSON object with Content-Type: application/json. |
| 400 | `invalid_input` | Check the request fields and types. |
| 401 | `invalid_key` | The workspace API key is missing, invalid or revoked. |
| 403 | `forbidden` | Check the key’s operation and resource grants. If Brigg-Act-As is supplied, the key must be authorized to delegate to that member. |
| 404 | `not_found` | The requested operation or resource is not available to this credential. |
| 429 | `rate_limited` | Wait for Retry-After before retrying. |
| 409 | `not_text_document` | This file is not a collaborative text document. Use CreateTextDocument or select kind=text_document from ListDocuments. |

## Next steps

- [Get text document version](https://developer.brigg.app/reference/documents/GetTextDocumentVersion)
- [Checkpoint text document](https://developer.brigg.app/reference/documents/CheckpointTextDocument)
- [Revert text document](https://developer.brigg.app/reference/documents/RevertTextDocument)
- [Create text document](https://developer.brigg.app/reference/documents/CreateTextDocument)

[Download OpenAPI](https://developer.brigg.app/openapi.json) · [Versioning & retirement](https://developer.brigg.app/versioning)

## Examples

### Inspect saved versions

These are historical snapshots, not separate files. Keep file_id alongside a selected version_id.
#### cURL


```sh
curl 'https://api.brigg.app/v1/operations/documents.ListTextDocumentVersions' \
  -H "Authorization: Bearer $BRIGG_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "file_id": "f_project_notes"
}'
```

#### TypeScript


```typescript
const response = await fetch("https://api.brigg.app/v1/operations/documents.ListTextDocumentVersions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "file_id": "f_project_notes"
  }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.error} — ${result.message}`);
console.log(result);
```

#### Python


```python
import json
import os
from urllib.request import Request, urlopen
from urllib.error import HTTPError

payload = {
  "file_id": "f_project_notes"
}
request = Request(
    "https://api.brigg.app/v1/operations/documents.ListTextDocumentVersions",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
    },
    method="POST",
)
try:
    with urlopen(request) as response:
        print(json.load(response))
except HTTPError as error:
    print(error.code, json.load(error))
    raise
```

#### Response example


```json
{
  "items": [
    {
      "version_id": "tdv_project_notes_2",
      "kind": "named",
      "label": "Before legal review",
      "word_count": 7,
      "participants": [
        "a_jamie"
      ],
      "created_by": "a_jamie",
      "created_at": 1794301200000
    }
  ]
}
```

## JSON schemas


```json-schema-request
{
  "type": "object",
  "properties": {
    "file_id": {
      "type": "string",
      "minLength": 1,
      "description": "Use the file_id of a collaborative text document. Find an existing document with [ListDocuments](https://developer.brigg.app/reference/documents/ListDocuments) and select kind=text_document. An uploaded PDF, Word file or plain-text file is not a collaborative text document. [documents.CreateTextDocument](https://developer.brigg.app/reference/documents/CreateTextDocument)."
    }
  },
  "required": [
    "file_id"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "file_id": "f_project_notes"
    }
  ]
}
```


```json-schema-response
{
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "version_id": {
            "type": "string",
            "description": "Saved version identity. Keep it together with the document's file_id to read or restore this version.",
            "examples": [
              "version_proposal_2"
            ]
          },
          "kind": {
            "type": "string",
            "description": "How the version was saved: named is a user-labelled checkpoint; auto is an automatic checkpoint, and pre_revert preserves the state before a restore.",
            "examples": [
              "named"
            ]
          },
          "label": {
            "type": [
              "string",
              "null"
            ],
            "description": "Name supplied for a named checkpoint, or null when no label was recorded.",
            "examples": [
              "Revised proposal"
            ]
          },
          "word_count": {
            "type": "number",
            "description": "Number of words in the saved content.",
            "examples": [
              420
            ]
          },
          "participants": {
            "description": "Account IDs of the people who edited this version.",
            "type": "array",
            "items": {
              "type": "string"
            },
            "examples": [
              [
                "account_alex"
              ]
            ]
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Account that created the record, or null when no account is recorded.",
            "examples": [
              "account_alex"
            ]
          },
          "created_at": {
            "type": "number",
            "description": "Creation time in Unix milliseconds."
          }
        },
        "required": [
          "version_id",
          "kind",
          "label",
          "word_count",
          "created_by",
          "created_at"
        ],
        "additionalProperties": false,
        "title": "Document version"
      },
      "description": "Saved versions of the selected text document. This operation has no cursor pagination."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "items": [
        {
          "version_id": "tdv_project_notes_2",
          "kind": "named",
          "label": "Before legal review",
          "word_count": 7,
          "participants": [
            "a_jamie"
          ],
          "created_by": "a_jamie",
          "created_at": 1794301200000
        }
      ]
    }
  ]
}
```

