# List text document shares

List active, unexpired share links for a text document you can access, including expiry and access counts. Treat each returned URL as a bearer credential. Use share_id to revoke an individual link.

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

## Access & visibility

Allow `documents.ListTextDocumentShares` on your API key.

**Acting member required.** Send `Brigg-Act-As` with an [approved member account ID](https://developer.brigg.app/authentication#member-delegation). The key supplies permissions; the member selects whose data is used.

The selected member must be active and approved by the credential. This selects whose private data is used; the credential supplies permissions. Private ownership and project boundaries still apply.

[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. |

## A share link grants access

The returned `url` is a bearer link: someone holding it can open the shared content within that link's terms. Keep it out of application logs and analytics. The separate `share_id` identifies a link for management and revocation; it is not sufficient to read content.

Sharing a text document uses `file_id`; sharing a generated document uses `document_id` and can name a `version_id`. Do not substitute one ID type for another. Revoking one share link does not remove other links or change the content's underlying workspace/private visibility.

## 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.

An empty items array means no active links remain. Each URL still grants access to the current content; this response contains bearer links and should not be logged.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `items` | array of [Document share link](#document-share-link-response-items) | Yes | Active, unexpired share links for this text document, newest first. Revoked and expired links are excluded. This operation has no cursor pagination. |

### Document share link · response.items[]

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `share_id` | string | Yes | Non-secret identifier of a share link returned by a share or share-list operation. Use it to revoke that link; it cannot be used to open the document. Treat the separate url value as a bearer credential. |
| `url` | string | Yes | Bearer link that grants access to this document. Treat it as a secret and share it only with intended readers. |
| `created_by` | string or null | Yes | Account ID of the person who created this link. |
| `created_at` | number | Yes | Share-link creation time in Unix milliseconds. |
| `expires_at` | number | Yes | Expiry time in Unix milliseconds. Access through this link stops after this time. |
| `access_count` | number | Yes | Number of recorded accesses through this share link. |
| `last_accessed_at` | number or null | Yes | Most recent access time in Unix milliseconds, or null if the link has not been used. |

## 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. Supply Brigg-Act-As with a member authorized by the key’s delegation grant. The selected member must be active and approved by the credential. This selects whose private data is used; the credential supplies permissions. Private ownership and project boundaries still apply. |
| 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

- [Share text document](https://developer.brigg.app/reference/documents/ShareTextDocument)
- [Revoke text document share](https://developer.brigg.app/reference/documents/RevokeTextDocumentShare)
- [Read text document](https://developer.brigg.app/reference/documents/ReadTextDocument)
- [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

### List active links

This link has been opened twice; counters describe accesses, not unique people.
#### cURL


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

#### TypeScript


```typescript
const actAs = process.env.BRIGG_ACT_AS;
if (!actAs) throw new Error("Set BRIGG_ACT_AS to an approved member account ID.");

const response = await fetch("https://api.brigg.app/v1/operations/documents.ListTextDocumentShares", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
    "Brigg-Act-As": actAs,
  },
  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.ListTextDocumentShares",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
        "Brigg-Act-As": os.environ["BRIGG_ACT_AS"],
    },
    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": [
    {
      "share_id": "share_project_notes",
      "url": "https://app.example.com/share/fictional-link?org=o_northstar",
      "expires_at": 1794906000000,
      "created_by": "a_jamie",
      "created_at": 1794301200000,
      "access_count": 2,
      "last_accessed_at": 1794387600000
    }
  ]
}
```

## 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": {
          "share_id": {
            "type": "string",
            "description": "Non-secret identifier of a share link returned by a share or share-list operation. Use it to revoke that link; it cannot be used to open the document. Treat the separate url value as a bearer credential.",
            "examples": [
              "share_proposal"
            ]
          },
          "url": {
            "type": "string",
            "description": "Bearer link that grants access to this document. Treat it as a secret and share it only with intended readers.",
            "examples": [
              "https://example.com/share/proposal"
            ]
          },
          "created_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "Account ID of the person who created this link.",
            "examples": [
              "account_alex"
            ]
          },
          "created_at": {
            "type": "number",
            "description": "Share-link creation time in Unix milliseconds."
          },
          "expires_at": {
            "type": "number",
            "description": "Expiry time in Unix milliseconds. Access through this link stops after this time.",
            "examples": [
              1794906000000
            ]
          },
          "access_count": {
            "type": "number",
            "description": "Number of recorded accesses through this share link.",
            "examples": [
              0
            ]
          },
          "last_accessed_at": {
            "type": [
              "number",
              "null"
            ],
            "description": "Most recent access time in Unix milliseconds, or null if the link has not been used.",
            "examples": [
              null
            ]
          }
        },
        "required": [
          "share_id",
          "url",
          "created_by",
          "created_at",
          "expires_at",
          "access_count",
          "last_accessed_at"
        ],
        "additionalProperties": false,
        "title": "Document share link"
      },
      "description": "Active, unexpired share links for this text document, newest first. Revoked and expired links are excluded. This operation has no cursor pagination."
    }
  },
  "required": [
    "items"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "items": [
        {
          "share_id": "share_project_notes",
          "url": "https://app.example.com/share/fictional-link?org=o_northstar",
          "expires_at": 1794906000000,
          "created_by": "a_jamie",
          "created_at": 1794301200000,
          "access_count": 2,
          "last_accessed_at": 1794387600000
        }
      ]
    }
  ]
}
```

