# Get file download

Get a temporary download URL for a file the caller may currently read. The URL is pinned to the verified file version and expires after five minutes.

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

## Access & visibility

Allow `documents.GetFileDownload` 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 a file_id returned by this listing or by CompleteUpload. It is not an upload ID, storage path or filename. [documents.ListDocuments](https://developer.brigg.app/reference/documents/ListDocuments). At least 1 character. |

## Fetch the bytes

The response is JSON containing a URL, not the file bytes. Make a separate GET request to url, for example `curl --fail --location "$DOWNLOAD_URL" --output agreement.pdf`. Do not forward your Brigg API key or member header to that host. Treat the URL as a short-lived credential.

The URL identifies the verified version of this file and expires after five minutes. Request a new one if it expires before use. The [file guide](https://developer.brigg.app/files) also provides a streaming server helper that performs both steps.

## Response

Returns **200 OK** with a JSON body.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | Yes | Temporary bearer URL for a GET request. Fetch it exactly as returned without the Brigg Authorization or Brigg-Act-As headers. Keep it out of logs and obtain another URL after expiry. |
| `filename` | string | Yes | Current filename to use when saving the downloaded bytes. |
| `expires_at` | number | Yes | Expiry time in Unix milliseconds. Obtain a fresh transfer or download URL after expiry. |

## 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 | `file_scan_blocked` | The file's scan prevents this download. Inspect details.scan_status. Do not repeatedly retry a threats_found, failed or unsupported verdict. Only the original uploader can retrieve an unsupported file as a forced download; it remains unavailable for processing. |

## Next steps

- [Upload and download files](https://developer.brigg.app/files)
- [List documents](https://developer.brigg.app/reference/documents/ListDocuments)

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

## Examples

### Example request

Fictional values. Replace IDs and business details with values from your workspace.
#### cURL


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

#### TypeScript


```typescript
const response = await fetch("https://api.brigg.app/v1/operations/documents.GetFileDownload", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "file_id": "f_example"
  }),
});
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_example"
}
request = Request(
    "https://api.brigg.app/v1/operations/documents.GetFileDownload",
    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
{
  "url": "https://example.com/temporary-download",
  "filename": "Agreement.pdf",
  "expires_at": 1794301500000
}
```

## JSON schemas


```json-schema-request
{
  "type": "object",
  "properties": {
    "file_id": {
      "type": "string",
      "minLength": 1,
      "description": "Use a file_id returned by this listing or by CompleteUpload. It is not an upload ID, storage path or filename. [documents.ListDocuments](https://developer.brigg.app/reference/documents/ListDocuments)."
    }
  },
  "required": [
    "file_id"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "file_id": "f_example"
    }
  ]
}
```


```json-schema-response
{
  "type": "object",
  "properties": {
    "url": {
      "type": "string",
      "description": "Temporary bearer URL for a GET request. Fetch it exactly as returned without the Brigg Authorization or Brigg-Act-As headers. Keep it out of logs and obtain another URL after expiry."
    },
    "filename": {
      "type": "string",
      "description": "Current filename to use when saving the downloaded bytes."
    },
    "expires_at": {
      "type": "number",
      "description": "Expiry time in Unix milliseconds. Obtain a fresh transfer or download URL after expiry."
    }
  },
  "required": [
    "url",
    "filename",
    "expires_at"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "url": "https://example.com/temporary-download",
      "filename": "Agreement.pdf",
      "expires_at": 1794301500000
    }
  ]
}
```

