
## Pin an entry

`POST /v1/timeline-logs/:id/pin`

Pins a log entry to the top of the parent CRM entity's timeline. Pinned entries are always visible when the card is opened — the manager does not need to scroll through the history to see an important event.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Log entry ID (or another timeline item) |

## Request body fields

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| **`entityTypeId`** | number | yes | Parent CRM entity type |
| **`entityId`** | number | yes | Parent record ID |

## Examples

### curl — personal key

```bash
curl -X POST https://vibecode.bitrix24.com/v1/timeline-logs/5012/pin \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "entityTypeId": 2, "entityId": 100 }'
```

### curl — OAuth application

```bash
curl -X POST https://vibecode.bitrix24.com/v1/timeline-logs/5012/pin \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "entityTypeId": 2, "entityId": 100 }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/timeline-logs/5012/pin', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ entityTypeId: 2, entityId: 100 }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/timeline-logs/5012/pin', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ entityTypeId: 2, entityId: 100 }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.pinned` | boolean | Always `true` — confirmation that the entry is pinned |

## Response example

```json
{
  "success": true,
  "data": { "pinned": true }
}
```

## Error response example

400 — required fields missing:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Required body: entityTypeId, entityId (positive ints)"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `entityTypeId` / `entityId` missing or invalid, or `id` is not a positive integer |
| 404 | `ENTITY_NOT_FOUND` | Timeline item with the given `id` does not exist |
| 403 | `SCOPE_DENIED` | API key does not have the `crm` scope |
| 401 | `TOKEN_MISSING` | API key has no configured tokens |

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

## Known specifics

**Pinning works not only for log entries.** The endpoint accepts the `id` of any timeline item — including user comments from [`/v1/timelines`](/docs/entities/timelines) and activities ([`/v1/activities`](/docs/entities/activities)). If you know the `id` of a comment, it can be pinned through this endpoint too.

**Repeated pin is idempotent.** Pinning an already-pinned entry also returns `200 + {pinned: true}`. Unpinning an entry is a separate call [`POST /unpin`](/docs/timeline-logs/pins/unpin).

**Pinning is independent of bindings.** If an entry is bound to several entities via [`bind`](/docs/timeline-logs/bindings/bind), pin pins it only in the specified `entityTypeId+entityId` pair. To pin it in all related cards, make separate pin calls for each.

## See also

- [Unpin an entry](/docs/timeline-logs/pins/unpin) — the reverse operation
- [Bind to another entity](/docs/timeline-logs/bindings/bind) — multi-binding with the ability to pin in each
- [Create an entry](/docs/timeline-logs/logs/create) — create before pinning
