## Attachments (ATTACH blocks)

Rich message layout — cards, field-value tables, images, files and dividers. Passed in the `attach` field together with `message`.

`attach` is an array of blocks. Each block is an object with a single type key. The `MESSAGE` text block takes a string; the other blocks take an array of objects with fields.

## Block types

### MESSAGE — text

A text string. Supports [BB codes](/docs/chats/messages/formatting).

```json
{ "MESSAGE": "Task status updated" }
```

### GRID — field-value table

| Field | Type | Description |
|------|-----|---------|
| `NAME` | string | Field name |
| `VALUE` | string | Field value |
| `DISPLAY` | string | Layout: `LINE` (inline), `BLOCK`, `ROW` |
| `WIDTH` | integer | Column width in pixels |

```json
{ "GRID": [
  { "NAME": "Task", "VALUE": "Prepare the report", "DISPLAY": "LINE" },
  { "NAME": "Status", "VALUE": "Done", "DISPLAY": "LINE" }
] }
```

### LINK — link preview

| Field | Type | Description |
|------|-----|---------|
| `NAME` | string | Link title |
| `LINK` | string | URL |
| `DESC` | string | Description |
| `PREVIEW` | string | Preview image URL |

```json
{ "LINK": [{ "NAME": "Documentation", "LINK": "https://example.com/docs", "DESC": "API reference" }] }
```

### IMAGE — image

| Field | Type | Description |
|------|-----|---------|
| `LINK` | string | Image URL |
| `NAME` | string | Caption |
| `PREVIEW` | string | Preview URL |
| `WIDTH` | integer | Width in pixels |
| `HEIGHT` | integer | Height in pixels |

```json
{ "IMAGE": [{ "LINK": "https://example.com/chart.png", "NAME": "Sales chart", "WIDTH": 600, "HEIGHT": 400 }] }
```

### FILE — file

| Field | Type | Description |
|------|-----|---------|
| `LINK` | string | File URL |
| `NAME` | string | File name |
| `SIZE` | integer | Size in bytes |

```json
{ "FILE": [{ "LINK": "https://example.com/report.pdf", "NAME": "report.pdf", "SIZE": 2048576 }] }
```

### USER — user card

| Field | Type | Description |
|------|-----|---------|
| `NAME` | string | User name |
| `AVATAR` | string | Avatar URL |
| `LINK` | string | Profile URL |

```json
{ "USER": [{ "NAME": "John Brown", "LINK": "https://example.com/u/42" }] }
```

### DELIMITER — divider line

| Field | Type | Description |
|------|-----|---------|
| `SIZE` | integer | Width in pixels |
| `COLOR` | string | Color in hexadecimal format |

```json
{ "DELIMITER": [{ "SIZE": 200, "COLOR": "#c6c6c6" }] }
```

## Full example

```json
{
  "message": "Task report",
  "attach": [
    { "MESSAGE": "[B]Task status updated[/B]" },
    { "DELIMITER": [{}] },
    { "GRID": [
      { "NAME": "Task", "VALUE": "Prepare the report", "DISPLAY": "LINE" },
      { "NAME": "Status", "VALUE": "Done", "DISPLAY": "LINE" }
    ] },
    { "LINK": [{ "NAME": "Open the task", "LINK": "https://example.com/tasks/42" }] }
  ]
}
```

## See also

- [Send a message](/docs/chats/messages/send)
- [Text formatting](/docs/chats/messages/formatting)
- [Keyboard](/docs/chats/messages/keyboard)
