## Delete a template from "My blocks"

`DELETE /v1/block-repository/favorites/:blockId`

Deletes a template saved to "My blocks" in the block catalog. Deletion is irreversible: the template cannot be restored, so save the block again if needed.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `blockId` (path) | number | yes | Template ID in "My blocks" — the `blockId` from the response of [saving a block](/docs/entities/pages/favorite). The ID of a regular page block does not work here |
| `scope` (query) | string | no | Internal landing scope: `KNOWLEDGE` — knowledge base, `GROUP` — group knowledge base, `MAINPAGE` — main page. Omit it for a regular site |

The request has no body.

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/block-repository/favorites/29417" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/block-repository/favorites/29417" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/block-repository/favorites/29417", {
  method: "DELETE",
  headers: {"X-Api-Key": "YOUR_API_KEY"},
})
const result = await response.json()
if (!response.ok) throw new Error(result.error.message)
console.log(result.data)
```

### JavaScript — OAuth application

```javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/block-repository/favorites/29417", {
  method: "DELETE",
  headers: {"X-Api-Key": "YOUR_APP_KEY", "Authorization": "Bearer USER_SESSION_TOKEN"},
})
const result = await response.json()
if (!response.ok) throw new Error(result.error.message)
console.log(result.data)
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | Always `true` on success |
| `data.deleted` | boolean | Always `true`: the template is deleted |
| `data.blockId` | number | ID of the deleted template, the same as in the request path |

## Response example

```json
{
  "success": true,
  "data": {
    "deleted": true,
    "blockId": 29417
  }
}
```

## Error response example

404 — there is no template with this ID, it is already deleted, or this is the ID of a regular page block:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Page, block or card not found."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 404 | `ENTITY_NOT_FOUND` | There is no template with this `blockId`: it never existed, is already deleted, or the ID of a regular page block was passed |
| 400 | `INVALID_PARAMS` | `pageId and blockId must be positive safe integers.` — `blockId` is not a positive integer |
| 400 | `INVALID_PARAMS` | `Body must be a JSON object.` — the body passed is not a JSON object |
| 400 | `INVALID_PARAMS` | `Body contains an unsupported field.` — a body with fields was passed |
| 400 | `INVALID_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |
| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not confirm favorite removal.` — Bitrix24 did not confirm the template deletion |
| 403 | `SCOPE_DENIED` | The API key does not have the `landing` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only; the request is rejected before reaching Bitrix24 |
| 403 | `BITRIX_ACCESS_DENIED` | The Bitrix24 user the key is issued for has no permission for this action |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `INVALID_API_KEY` | The key in `X-Api-Key` is not found or has been revoked |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 409 | `LANDING_MODULE_NOT_ENABLED` | The Sites module is unavailable on the Bitrix24 account. Ask the account administrator to enable it — while the module is off, retrying the request returns the same rejection |
| 409 | `PORTAL_ADDRESS_CHANGED` | The on-premise Bitrix24 moved to a new address, but the key's webhook was issued for the old one. Reissue the key's webhook |
| 429 | `RATE_LIMITED` | The Bitrix24 request limit is exceeded. Retry the request in 1-2 seconds |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 did not respond or responded with a server error |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 did not respond in time. Before retrying, check the catalog: the template may already be deleted |

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

## Known specifics

- **Other users' templates cannot be deleted.** Only a template saved by the same Bitrix24 user the key is issued for can be deleted.
- **The source page block remains.** Deletion removes the template from the block catalog and does not change the block the template was saved from.

## See also

- [Save a block to "My blocks"](/docs/entities/pages/favorite)
- [Saved blocks](/docs/entities/block-repository)
- [Block catalog](/docs/entities/pages/catalog)
