## Get a guest link

`POST /v1/chats/:dialogId/guest-links`

Returns your guest link to the chat and creates it if the link does not exist yet. A person outside the Bitrix24 account joins the chat through the link URL, and each member has their own guest link.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `dialogId` (path) | string | yes | Dialog ID: `chatXXX` for a group chat, a numeric user ID for a private chat, `me` — your personal dialog. List — [`GET /v1/chats/recent`](/docs/chats/discovery/recent) |

The request takes no body: body fields and query parameters are rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

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

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/chats/chat42/guest-links" \
  -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/chat42/guest-links', {
  method: 'POST',
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { data } = await res.json()
console.log('Guest link:', data.sharingLink.url, 'until', data.sharingLink.dateExpire)
```

### JavaScript — OAuth application

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

const { data } = await res.json()
console.log('Guest link:', data.sharingLink.url, 'until', data.sharingLink.dateExpire)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.sharingLink.id` | number | Link ID |
| `data.sharingLink.entityType` | string | `guest_chat` — a guest link |
| `data.sharingLink.entityId` | string | Chat ID without the `chat` prefix |
| `data.sharingLink.code` | string | The link code — for [reading](/docs/chats/sharing/link-get) and [revoking by code](/docs/chats/sharing/link-revoke) |
| `data.sharingLink.type` | string | `individual` — an individual guest link |
| `data.sharingLink.dateCreate` | string | Creation date, ISO 8601 |
| `data.sharingLink.dateExpire` | string | Expiration date — one day after creation |
| `data.sharingLink.requireApproval` | boolean | Whether joining requires approval |
| `data.sharingLink.url` | string | The URL the guest opens |
| `data.sharingLink.name` | null | Always `null` for an individual guest link |

## Response example

```json
{
  "success": true,
  "data": {
    "sharingLink": {
      "id": 1014,
      "entityId": "42",
      "entityType": "guest_chat",
      "code": "Pq7Rs2Tu9Vw4Xy1Z",
      "type": "individual",
      "dateCreate": "2026-09-24T23:07:13+00:00",
      "dateExpire": "2026-09-25T23:07:13+00:00",
      "requireApproval": false,
      "url": "https://b24.to/gi/a1b2c3d4e5-Pq7Rs2Tu9Vw4Xy1Z?IM_DIALOG=chat42",
      "name": null
    }
  }
}
```

## Error response example

422 — the chat does not exist in the Bitrix24 account:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "CHAT_NOT_FOUND",
    "hint": "dialogId must be a userId (number as string) for DMs or \"chat{N}\" for group chats. Examples: \"1\" for user 1, \"chat123\" for group chat 123. Create a group chat first via POST /v1/bots/:botId/chats if needed.",
    "b24Code": "CHAT_NOT_FOUND"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | A body field 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`. `GUEST_FEATURE_DISABLED` — guests are disabled on the portal, `CHAT_NOT_FOUND` — the chat does not exist on the portal |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 answered with an unspecified "not found" code; the portal code is in `error.b24Code` |
| 502 | `ME_ALIAS_RESOLUTION_FAILED` | Failed to resolve the user for the `me` alias |
| 403 | `BITRIX_ACCESS_DENIED` | No right to manage the chat's guest links — Bitrix24 refused with the `ACCESS_DENIED` code |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only and the call is a write — see [access rights](/docs/access-rights) |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |

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

## Known specifics

**Automatic chat membership.** The call can make the key owner a member of a chat that allows auto-join, even if the link operation is subsequently refused. A read-only key is blocked before Bitrix24 is called.

**Links count toward the invitation limit.** Every new guest link, including regenerated and revoked ones, counts toward the author's limit of 10 guest links per hour, which is checked by [invitations by email](/docs/chats/sharing/invite-email) and [by SMS](/docs/chats/sharing/invite-phone).

## See also

- [Regenerate a guest link](/docs/chats/sharing/guest-link-regenerate)
- [Revoke a guest link](/docs/chats/sharing/guest-link-revoke)
- [Invite guests by email](/docs/chats/sharing/invite-email)
- [Links and guests](/docs/chats/sharing)
