
## Get file metadata

`GET /v1/note/documents/:documentId/files/:id`

Returns the file metadata and a ready-made markup snippet for inserting the attachment into the document content. Available to a read-only key as well.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `documentId` (path) | integer | yes | Document the file is attached to. Get the identifier from [`POST /v1/note/documents`](/docs/note/documents) |
| `id` (path) | integer | yes | File identifier. Returned from [`POST /v1/note/documents/:documentId/files`](./upload.md) |

## Examples

### curl — personal key

```bash
curl https://vibecode.bitrix24.com/v1/note/documents/77/files/5001 \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl https://vibecode.bitrix24.com/v1/note/documents/77/files/5001 \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/note/documents/77/files/5001', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
console.log(data.assetMarkdown)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/note/documents/77/files/5001', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.id` | number | File identifier |
| `data.documentId` | number | Document the file is attached to |
| `data.name` | string | Original file name |
| `data.size` | number | File size in bytes |
| `data.mimeType` | string | File content type in MIME format, determined at save time |
| `data.assetType` | string | Attachment category: `image`, `video`, or `file` |
| `data.assetMarkdown` | string | Ready-made `[[<assetType> fileId=<id>]]` snippet for inserting into the content |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 5001,
    "documentId": 77,
    "name": "diagram.png",
    "size": 6321,
    "mimeType": "image/png",
    "assetType": "image",
    "assetMarkdown": "[[image fileId=5001]]"
  }
}
```

## Error response example

404 — document or file not found:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Record with ID = `999999` not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `documentId` or `id` is missing, or a parameter has the wrong type |
| 403 | `SCOPE_DENIED` | The key is missing the `note` scope |
| 404 | `ENTITY_NOT_FOUND` | The document or file does not exist, there is no access, or the file is not attached to the document |
| 401 | `TOKEN_MISSING` | The key has no configured tokens |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

**`assetMarkdown` format and inserting the attachment.** To make the attachment appear in the document, add `assetMarkdown` as a separate line in `markdown` and call [`PATCH /v1/note/documents/:id`](/docs/note/documents). The snippet must start at the beginning of a line, with no other characters on that same line. The type is written in lowercase, and `fileId` is a positive integer.

## See also

- [Upload file](/docs/note/files/upload)
- [Documents](/docs/note/documents)
- [Files](/docs/note/files)
- [Knowledge Base overview](/docs/note)
