## Save a block in My blocks

`POST /v1/pages/:pageId/blocks/:blockId/favorite`

Creates a block template in the Bitrix24 account catalog (My blocks). ALL account editors can see it; this is not a personal bookmark. sections is an optional catalog section array; [] is allowed. The response contains the template blockId and a code in the form sourceCode@blockId. preview is unsupported: Bitrix24 deletes that file from the original block. Remove unused templates with [Delete a saved block](/docs/entities/block-repository/favorites/delete).

Requires the `landing` scope; READONLY keys receive 403 before mutation. Page-scoped actions check that the block belongs to the page.

Optional query `scope`: `KNOWLEDGE`, `GROUP` or `MAINPAGE` for that page context; omit for a regular site. IDs must be positive safe integers.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/pages/42/blocks/50/favorite" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Reusable block","sections":["text"]}'
```

### JavaScript — personal key

```javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/pages/42/blocks/50/favorite", {
  method: "POST",
  headers: {"X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
  body: JSON.stringify({"name": "Reusable block", "sections": ["text"]}),
})
const result = await response.json()
if (!response.ok) throw new Error(result.error.message)
console.log(result.data)
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/pages/42/blocks/50/favorite" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Reusable block","sections":["text"]}'
```

### JavaScript — OAuth application

```javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/pages/42/blocks/50/favorite", {
  method: "POST",
  headers: {"X-Api-Key": "YOUR_APP_KEY", "Authorization": "Bearer USER_SESSION_TOKEN", "Content-Type": "application/json"},
  body: JSON.stringify({"name": "Reusable block", "sections": ["text"]}),
})
const result = await response.json()
if (!response.ok) throw new Error(result.error.message)
console.log(result.data)
```

## Response

```json
{
  "success": true,
  "data": {
    "blockId": 50,
    "code": "03.1.three_cols_big_with_text_and_titles@50"
  }
}
```

## Errors

| HTTP | Code |
|---|---|
| 400 | INVALID_PARAMS / MISSING_REQUIRED_FIELDS / INVALID_SCOPE |
| 401 | MISSING_API_KEY / INVALID_API_KEY / TOKEN_MISSING |
| 403 | SCOPE_DENIED / WRITE_BLOCKED_READONLY_KEY / BITRIX_ACCESS_DENIED |
| 404 | ENTITY_NOT_FOUND |
| 409 | PORTAL_ADDRESS_CHANGED / LANDING_MODULE_NOT_ENABLED |
| 422 | BITRIX_ERROR / BITRIX_NO_EFFECT |
| 429 | RATE_LIMITED |
| 502 | BITRIX_ERROR |
| 503 | SERVICE_UNAVAILABLE |
