## List deal contacts

`GET /v1/deals/:id/contacts`

Returns all contacts linked to a deal, so that you know the current set before linking, replacing, or unlinking contacts.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | number | yes | Deal ID. List: [`GET /v1/deals`](/docs/entities/deals/list) |

There is no pagination: one call returns all of the deal's links.

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/deals/8785/contacts" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/deals/8785/contacts" \
  -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/deals/8785/contacts', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
const primary = data.find((link) => link.isPrimary)
console.log('Primary contact:', primary?.contactId)
```

### JavaScript — OAuth application

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

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

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | Always `true` on success |
| `data` | array | Links between the deal and its contacts, ordered by `sort`. An empty array for a deal without contacts |
| `data[].contactId` | number | Contact ID. Get the contact: [`GET /v1/contacts/:id`](/docs/entities/contacts/get) |
| `data[].isPrimary` | boolean | Primary contact of the deal. For a deal with contacts, exactly one link has `true` |
| `data[].sort` | number | Position of the contact in the list |
| `data[].roleId` | number | Role of the contact in the deal. The link methods do not save it |

## Response example

```json
{
  "success": true,
  "data": [
    { "contactId": 2921, "sort": 10, "isPrimary": false, "roleId": 0 },
    { "contactId": 2923, "sort": 20, "isPrimary": true, "roleId": 0 },
    { "contactId": 2925, "sort": 30, "isPrimary": false, "roleId": 0 }
  ]
}
```

## Error response example

404 — no deal with this `id`:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `id` is not a positive integer, for example `abc` |
| 404 | `ENTITY_NOT_FOUND` | No deal with this `id` |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | No Bitrix24 tokens are attached to the key |
| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |
| 429 | `RATE_LIMITED` | Rate limit exceeded: 300 requests per minute per portal. All API keys of the portal share one limit. The current limit is returned in the `x-ratelimit-limit` header. Retry after the delay in the `Retry-After` header |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable. Retry the request later |

For the full list of common API errors, see [Errors](/docs/errors).

## Known specifics

- **A listed ID may not lead to a contact.** Linking does not check the contact ID, so the list can contain an ID that matches no contact. Before working with a contact, request it through [`GET /v1/contacts/:id`](/docs/entities/contacts/get).
- **Contacts together with the deal.** [`GET /v1/deals/:id?include=contact`](/docs/entities/deals/get) returns the deal and the full records of the linked contacts in `data._included.contacts`. The primary contact ID is returned in the deal's `contactId` field, and all linked contact IDs are returned in `contactIds`.

## See also

- [Deal contacts](/docs/entities/deals/contacts)
- [Link a contact to a deal](/docs/entities/deals/contacts-create)
- [Replace deal contacts](/docs/entities/deals/contacts-set)
- [Unlink a contact from a deal](/docs/entities/deals/contacts-delete-delete)
- [Unlink all contacts from a deal](/docs/entities/deals/contacts-delete)
- [Get deal](/docs/entities/deals/get)
- [Contacts](/docs/entities/contacts)
