
## ATTACH blocks

Extended message formatting via the `fields.attach` field. Maximum size: 60,000 characters after serialization.

## Two transfer formats

**Full format** (with metadata):

```json
{
  "fields": {
    "attach": {
      "ID": 1,
      "COLOR_TOKEN": "primary",
      "COLOR": "#29619b",
      "BLOCKS": [
        { "MESSAGE": [{ "MESSAGE": "Block text", "STYLE": "bold" }] },
        { "DELIMITER": [{ "SIZE": 200, "COLOR": "#c6c6c6" }] }
      ]
    }
  }
}
```

**Short format** (array of blocks):

```json
{
  "fields": {
    "attach": [
      { "MESSAGE": [{ "MESSAGE": "Block text", "STYLE": "bold" }] },
      { "DELIMITER": [{}] },
      { "GRID": [{ "NAME": "Field", "VALUE": "Value" }] }
    ]
  }
}
```

If `attach` has no `BLOCKS` key, the server assumes the short format was passed.

## Block types

### MESSAGE — styled text

| Field | Type | Description |
|------|-----|---------|
| `MESSAGE` | string | Message text |
| `STYLE` | string | Style: `bold`, `italic`, `base` |

```json
{ "MESSAGE": [{ "MESSAGE": "Status updated", "STYLE": "bold" }] }
```

### USER — user card

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

```json
{ "USER": [{ "NAME": "John Smith", "AVATAR": "https://example.com/avatar.jpg", "LINK": "https://portal.bitrix24.com/company/personal/user/1/" }] }
```

### LINK — link preview

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

```json
{ "LINK": [{ "NAME": "API documentation", "LINK": "https://vibecode.bitrix24.com/docs", "DESC": "Full Vibecode API documentation" }] }
```

### DELIMITER — divider line

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

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

### GRID — table / grid

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

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

### IMAGE — image

| Field | Type | Description |
|------|-----|---------|
| `LINK` | string | Full 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 — attached 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 }] }
```

## Color tokens (COLOR_TOKEN)

`primary`, `secondary`, `alert`, `base`

## Full example

```json
{
  "dialogId": "chat123",
  "fields": {
    "message": "",
    "attach": [
      {
        "MESSAGE": [
          { "MESSAGE": "Task status updated", "STYLE": "bold" }
        ]
      },
      { "DELIMITER": [{}] },
      {
        "GRID": [
          { "DISPLAY": "LINE", "NAME": "Task", "VALUE": "Prepare the report" },
          { "DISPLAY": "LINE", "NAME": "Status", "VALUE": "Done" },
          { "DISPLAY": "LINE", "NAME": "Assignee", "VALUE": "A. Smith" }
        ]
      },
      {
        "LINK": [
          { "NAME": "Open task", "LINK": "https://portal.bitrix24.com/tasks/42/" }
        ]
      }
    ]
  }
}
```

## See also

- [Send message](/docs/bots/messages/send)
- [Update message](/docs/bots/messages/update)
- [Text formatting](/docs/bots/messages/formatting)
- [Keyboard](/docs/bots/messages/keyboard)
