## Get card layout

`GET /v1/crm/card-config/:entityTypeId`

Returns the current layout of card sections and fields for the given CRM object type and scope. Returns an array of sections or `null` if there was no explicit configuration yet.

## Path parameter

| Parameter | Type | Description |
|----------|-----|---------|
| `entityTypeId` | number | CRM object type:<br>`1` — lead<br>`2` — deal<br>`3` — contact<br>`4` — company<br>`7` — quote<br>`31` — invoice<br>smart process — numeric type ID from [`GET /v1/smart-processes`](/docs/entities/smart-processes), field `entityTypeId` |

## Query parameters

| Parameter | Type | Description |
|----------|-----|---------|
| `scope` | string | Layout scope: `P` — personal (default), `C` — common |
| `userId` | number | Employee whose personal layout to read. Defaults to the API key owner. Only meaningful with `scope=P`. Source: [`GET /v1/users`](/docs/entities/users) |
| `dealCategoryId` | number | Deal pipeline, deals only (`entityTypeId=2`). Source: [`GET /v1/categories/2`](/docs/entities/categories) |
| `categoryId` | number | Smart process pipeline, smart processes only. Source: [`GET /v1/categories/:entityTypeId`](/docs/entities/categories) |
| `leadCustomerType` | number | Lead type, leads only (`entityTypeId=1`): `1` — simple, `2` — repeat |

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/crm/card-config/2?scope=C&dealCategoryId=9" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/crm/card-config/2?scope=C&dealCategoryId=9" \
  -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/crm/card-config/2?scope=C&dealCategoryId=9', {
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { success, data } = await res.json()
if (data === null) {
  console.log('No explicit layout — the default layout is used')
} else {
  console.log('Sections in the layout:', data.length)
}
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm/card-config/2?scope=C&dealCategoryId=9', {
  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 \| null | Array of layout sections. `null` — there was no explicit configuration yet |
| `data[].name` | string | Internal section name |
| `data[].title` | string | Displayed section title |
| `data[].type` | string | Always `section` |
| `data[].elements` | array | Section fields in display order |
| `data[].elements[].name` | string | CRM field name in Bitrix24 format |
| `data[].elements[].optionFlags` | string | Field flag: `"0"` — regular, `"1"` — customer field |
| `data[].elements[].options` | object | Options of a specific field, if set |

## Response example

Layout set explicitly:

```json
{
  "success": true,
  "data": [
    {
      "name": "main",
      "title": "About the deal",
      "type": "section",
      "elements": [
        { "name": "TITLE", "optionFlags": "0" },
        { "name": "STAGE_ID", "optionFlags": "0" },
        { "name": "OPPORTUNITY_WITH_CURRENCY", "optionFlags": "0" }
      ]
    }
  ]
}
```

No explicit configuration for the scope yet:

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

## Error response example

400 — invalid `scope` value:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_SCOPE",
    "message": "scope must be \"P\" (personal) or \"C\" (common)."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_ENTITY_TYPE_ID` | `entityTypeId` in the path is not a positive integer |
| 400 | `INVALID_SCOPE` | `scope` is not `P` or `C` |
| 400 | `INVALID_USER_ID` | `userId` is not a positive integer |
| 400 | `INVALID_DEAL_CATEGORY_ID` | `dealCategoryId` is not a positive integer |
| 400 | `INVALID_CATEGORY_ID` | `categoryId` is not a positive integer |
| 400 | `INVALID_LEAD_CUSTOMER_TYPE` | `leadCustomerType` is not `1` or `2` |
| 422 | `BITRIX_ERROR` | Bitrix24 did not recognize the object type — for example, for a nonexistent `entityTypeId`. The message is in `error.message` |
| 403 | `SCOPE_DENIED` | The API key does not have the `crm` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

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

## Known specifics

**`data: null` differs from an empty layout.** `null` means there was no explicit configuration for the given scope yet, and the card is drawn with the built-in default layout. An empty array `[]` means an explicitly saved empty layout. The `data === null` branch is worth handling separately in code.

**In the response `optionFlags` comes as a string.** For previously saved layouts the flag value is returned as the string `"0"` or `"1"`. When writing via [`PUT`](./set.md) the flag is passed as a number.

## See also

- [Set layout](/docs/entities/crm-card-config/set)
- [Reset layout](/docs/entities/crm-card-config/reset)
- [Smart processes](/docs/entities/smart-processes)
- [CRM categories](/docs/entities/categories)
- [CRM custom fields](/docs/userfields)
