> Documentation index: https://beezr.io/developers/api/llms.txt

# Download a file

`POST /api/v4/records/content`

Returns the bytes of one file attached to a record. Take `unstructuredId` and `module`
from the file reference in the record, and use the record's `id` as `objectId`.
Files are up to 10 MB.


## Requirements

| Requirement | Value |
| --- | --- |
| Auth | `X-API-Key` |
| Counts as | 1 request |
| Idempotency | not supported |
| Batch limit | n/a |
| Files | up to 10 MB each |

## Headers

| Parameter | Type | Presence | Description |
| --- | --- | --- | --- |
| `X-API-Key` | string | required | Read from your server environment. |
| `Content-Type` | string | required | `application/json`. |

## Body parameters

| Parameter | Type | Presence | Description |
| --- | --- | --- | --- |
| `unstructuredId` | string | required | From the file reference |
| `objectId` | integer | required | The record's id |
| `unstructuredModel` | object | required | — |
| `unstructuredModel.module` | string | required | From the file reference |

## Returns

HTTP 200. The file bytes.

Raw file bytes. Content-Type is application/pdf, image/png, image/jpeg, otherwise application/octet-stream. Headers include Content-Length, Content-Disposition, X-Beezr-File-Name and X-Beezr-File-Extension.

## Errors

| HTTP | Code | What to do |
| --- | --- | --- |
| 400 | [`MISSING_REQUIRED_FIELD`](/developers/api/errors/#missing-required-field) | Send the required body fields. |
| 401 | [`AUTHENTICATION_FAILED`](/developers/api/errors/#authentication-failed) | Check the API key. |
| 404 | [`CONTENT_NOT_FOUND`](/developers/api/errors/#content-not-found) | Check the reference and record id. |
| 400 · 413 | [`CONTENT_TOO_LARGE`](/developers/api/errors/#content-too-large) | Keep files within 10 MB. |
| 429 | [`RATE_LIMIT_EXCEEDED`](/developers/api/errors/#rate-limit-exceeded) | Wait for the rate-limit reset. |
| 429 | [`TOO_MANY_CONCURRENT_REQUESTS`](/developers/api/errors/#too-many-concurrent-requests) | Wait; keep at most 2 in flight. |
| 429 | [`MONTHLY_QUOTA_EXCEEDED`](/developers/api/errors/#monthly-quota-exceeded) | Stop retries until the 1st. |
| 500 | [`FIELD_LOAD_FAILED`](/developers/api/errors/#field-load-failed) | Retry later. |
| 500 | [`INTERNAL_ERROR`](/developers/api/errors/#internal-error) | Retry later. |

## Request

```curl
curl --fail-with-body --silent --show-error \
  'https://services.beezr.io/generic/api/v4/records/content' \
  -H "X-API-Key: $BEEZR_API_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
  "unstructuredId": "a1b2c3d4",
  "objectId": 482913,
  "unstructuredModel": {"module":"cm_equipment_requests_base"}
}' \
  --output contract.pdf
```

```javascript
import { writeFile } from "node:fs/promises";

const response = await fetch("https://services.beezr.io/generic/api/v4/records/content", {
  method: "POST",
  headers: {
    "X-API-Key": process.env.BEEZR_API_KEY,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "unstructuredId": "a1b2c3d4",
    "objectId": 482913,
    "unstructuredModel": {"module":"cm_equipment_requests_base"}
  })
});
if (!response.ok) throw new Error(await response.text());
await writeFile("contract.pdf", Buffer.from(await response.arrayBuffer()));
```

```python
import os
import requests

response = requests.post(
    "https://services.beezr.io/generic/api/v4/records/content",
    headers={"X-API-Key": os.environ["BEEZR_API_KEY"]},
    json={
      "unstructuredId": "a1b2c3d4",
      "objectId": 482913,
      "unstructuredModel": {"module":"cm_equipment_requests_base"}
    }
)
response.raise_for_status()
with open("contract.pdf", "wb") as output:
    output.write(response.content)
```

## Success response

```text
HTTP 200
Content-Type: application/pdf
Content-Disposition: attachment; filename="contract.pdf"

<raw file bytes>
```

## Common error

```json
{"success":false,"error":{"code":"AUTHENTICATION_FAILED","message":"Invalid or missing API key"}}
```
