## List company contacts

`GET /v1/companies/:id/contacts`

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

## Parameters

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

No pagination: the response contains all of the company's links in one call.

## Examples

### curl — personal key

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

### curl — OAuth application

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

const { success, data } = await res.json()
const contactIds = data.map((link) => link.contactId)
console.log('Company contacts:', contactIds)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/companies/3123/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 | The company's links to contacts in `sort` order. An empty array for a company without contacts |
| `data[].contactId` | number | Contact ID. Get the contact: [`GET /v1/contacts/:id`](/docs/entities/contacts/get) |
| `data[].isPrimary` | boolean | This is the contact's primary company: its ID is returned in the contact's `companyId` field |
| `data[].sort` | number | The contact's position in the list |
| `data[].roleId` | number | The contact's role in the company. The link methods do not save it |

## Response example

```json
{
  "success": true,
  "data": [
    { "contactId": 2987, "sort": 10, "isPrimary": true, "roleId": 0 },
    { "contactId": 2989, "sort": 20, "isPrimary": true, "roleId": 0 },
    { "contactId": 2991, "sort": 30, "isPrimary": true, "roleId": 0 }
  ]
}
```

## Error response example

400 — `id` is not a positive integer:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "id must be a positive integer"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `id` is not a positive integer, for example `abc` |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |
| 403 | `SCOPE_DENIED` | The key has no `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 non-existent company returns an empty list.** For an ID that does not belong to any company, the method returns `200` with an empty `data` array, as for a company without contacts. To check that the company exists, use [`GET /v1/companies/:id`](/docs/entities/companies/get): it returns `404` for such an ID.
- **An ID from the list may not lead to a contact.** Linking does not check the contact ID, so the list can contain an ID that does not belong to any contact. Before working with a contact, request it with [`GET /v1/contacts/:id`](/docs/entities/contacts/get).
- **Contacts together with the company.** [`GET /v1/companies/:id?include=contact`](/docs/entities/companies/get) returns the company and the full records of the linked contacts in `data._included.contacts`. The `include` value is `contact`, singular: `include=contacts` returns `400 INVALID_INCLUDE`. The IDs of all linked contacts are returned in the company's `contactIds` field.

## See also

- [Company contacts](/docs/entities/companies/contacts)
- [Link a contact to a company](/docs/entities/companies/contacts-create)
- [Replace company contacts](/docs/entities/companies/contacts-set)
- [Unlink a contact from a company](/docs/entities/companies/contacts-delete-delete)
- [Unlink all contacts from a company](/docs/entities/companies/contacts-delete)
- [Get company](/docs/entities/companies/get)
- [Contacts](/docs/entities/contacts)
- [Related data (include)](/docs/includes)
