
## Create section

`POST /v1/product-sections`

Creates a new section in the product catalog. Fields are passed flat at the root of the JSON, without a `fields` wrapper.

## Request fields (body)

| Field | Bitrix24 | Type | Required | Description |
|------|----------|-----|:-----:|---------|
| `name` | `NAME` | string | yes | Section name |
| `catalogId` | `CATALOG_ID` | number | no | Catalog identifier. If omitted, the Bitrix24 account CRM product catalog is used. List: `GET /v1/catalogs` |
| `sectionId` | `SECTION_ID` | number | no | Parent section identifier for nesting. `null` for a top-level section |
| `code` | `CODE` | string | no | Section symbolic code. If omitted, it is generated from `name` |
| `xmlId` | `XML_ID` | string | no | External identifier |
| `sort` | `SORT` | number | no | Sort index |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/product-sections" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Clothing",
    "catalogId": 25
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/product-sections" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Clothing",
    "catalogId": 25
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/product-sections', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Clothing',
    catalogId: 25,
  }),
})

const { success, data } = await res.json()
console.log('Section ID:', data.id)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/product-sections', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Clothing',
    catalogId: 25,
  }),
})

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

## Response fields

The full object of the created section is returned.

| Field | Type | Description |
|------|-----|---------|
| `id` | number | Identifier of the created section |
| `name` | string | Section name |
| `catalogId` | number | Catalog identifier |
| `sectionId` | number | Parent section identifier or `null` |
| `xmlId` | string | External identifier or `null` |
| `code` | string | Section symbolic code |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 197,
    "name": "Clothing",
    "catalogId": 25,
    "sectionId": null,
    "xmlId": null,
    "code": "clothing"
  }
}
```

## Error response example

422 — section name not provided:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Section name is not specified."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 422 | `BITRIX_ERROR` | The `name` field was not provided — message "Section name is not specified." |
| 400 | `READONLY_FIELD` | A read-only field was passed in the body — `id` |
| 403 | `SCOPE_DENIED` | Key is missing the `crm` scope |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not provided |

Full list of common API errors — [Errors](/docs/errors).

## See also

- [List sections](/docs/entities/product-sections/list)
- [Update section](/docs/entities/product-sections/update)
- [Delete section](/docs/entities/product-sections/delete)
- [Catalogs](/docs/entities/catalogs)
- [Batch](/docs/batch)
