## Get a link by code

`GET /v1/chats/sharing-links/:code`

Returns a link by its code — a chat link or a guest link. Use it to find out, from the code in a link URL, which chat the link leads to and what kind of link it is.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `code` (path) | string | yes | The link code — the `code` field of the link object or the `IM_CODE` parameter of its address. From 1 to 64 printable characters without spaces |

The request takes no query parameters: they are rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/chats/sharing-links/Xk9pQ2mZ7rT4vB1c" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/chats/sharing-links/Xk9pQ2mZ7rT4vB1c" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/sharing-links/Xk9pQ2mZ7rT4vB1c', {
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { data } = await res.json()
console.log('Chat:', data.sharingLink.entityId, 'type:', data.sharingLink.type)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/sharing-links/Xk9pQ2mZ7rT4vB1c', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { data } = await res.json()
console.log('Chat:', data.sharingLink.entityId, 'type:', data.sharingLink.type)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.sharingLink.id` | number | Link ID |
| `data.sharingLink.entityType` | string | `chat` — a chat link, `guest_chat` — a guest link |
| `data.sharingLink.entityId` | string | Chat ID without the `chat` prefix |
| `data.sharingLink.code` | string | The link code |
| `data.sharingLink.type` | string | `primary` — the primary link, `individual` — an individual link, `custom` — a personal guest invitation |
| `data.sharingLink.dateCreate` | string | Creation date, ISO 8601 |
| `data.sharingLink.dateExpire` | string \| null | Expiration date. `null` — no expiration |
| `data.sharingLink.requireApproval` | boolean | Whether joining requires approval |
| `data.sharingLink.url` | string | The link URL |
| `data.sharingLink.name` | string \| null | Guest links only. For an invitation by email or SMS — the address or number it was sent to; for an individual guest link — `null` |

## Response example

```json
{
  "success": true,
  "data": {
    "sharingLink": {
      "id": 1012,
      "entityId": "42",
      "entityType": "chat",
      "code": "Xk9pQ2mZ7rT4vB1c",
      "type": "individual",
      "dateCreate": "2026-09-24T23:02:28+00:00",
      "dateExpire": null,
      "requireApproval": false,
      "url": "https://portal.bitrix24.com/online/?IM_CODE=Xk9pQ2mZ7rT4vB1c"
    }
  }
}
```

## Error response example

422 — no link with this code exists:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "SHARING_LINK_NOT_FOUND",
    "b24Code": "SHARING_LINK_NOT_FOUND"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `code` does not look like a link code, or a query parameter was passed. Checked before any call to Bitrix24 |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the portal code is in `error.b24Code`. `SHARING_LINK_NOT_FOUND` — no link with this code exists |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 answered with an unspecified "not found" code; the portal code is in `error.b24Code` |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

The full list of general API errors — [Errors](/docs/errors).

## Known specifics

**A revoked link is read the same way as a valid one.** The response has no revocation flag: the only thing that distinguishes a revoked link is that [joining by code](/docs/chats/sharing/join) with it is rejected with `SHARING_LINK_REVOKED` in `error.b24Code`.

**Reading does not require chat membership.** The call does not take a chat and does not make you its member, so it works with a read-only key. Chat permissions are not checked on reading: any user of the Bitrix24 account who knows the code can read the link.

**A guest invitation discloses the address.** For a personal invitation by email or SMS, the `name` field holds the address or number of a person outside the Bitrix24 account — forward the response only to people allowed to see that contact.

## See also

- [Join a chat by code](/docs/chats/sharing/join)
- [Revoke a link by code](/docs/chats/sharing/link-revoke)
- [Links and guests](/docs/chats/sharing)
