
## Create a pipeline

`POST /v1/categories/:entityTypeId`

Creates a new pipeline for the specified CRM entity type. Fields are passed flat at the root of the JSON — without a `fields` wrapper.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `entityTypeId` (path) | number | yes | CRM entity type ID. `2` for deals, `3` for contacts, `4` for companies, `31` for invoices; for a smart process, the value from [GET /v1/smart-processes](/docs/entities/smart-processes/list) |

## Request fields (body)

| Field | Bitrix24 | Type | Required | Description |
|------|-----------|-----|:-----:|---------|
| `name` | `name` | string | yes | Pipeline name |
| `sort` | `sort` | number | no | Sort order among the pipelines of this type |

## Examples

The examples use `entityTypeId = 2` (deals); replace it with the type you need.

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/categories/2" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Partners pipeline",
    "sort": 500
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/categories/2" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Partners pipeline",
    "sort": 500
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/categories/2', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Partners pipeline',
    sort: 500,
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/categories/2', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Partners pipeline',
    sort: 500,
  }),
})

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

## Response fields

Returns the full object of the created pipeline with the assigned `id`.

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | `true` when the request succeeds |
| `data` | object | The created pipeline |
| `data.id` | number | Identifier of the created pipeline |
| `data.entityTypeId` | number | CRM entity type ID, same as the path parameter |
| `data.name` | string | Pipeline name |
| `data.sort` | number | Sort order |
| `data.isDefault` | boolean | Whether this is the type's main pipeline |
| `data.originId` | string \| null | External source identifier. `null` for pipelines with no external binding. Deal pipelines only |
| `data.originatorId` | string \| null | External system identifier. `null` for pipelines with no external binding. Deal pipelines only |
| `data.isSystem` | string | System pipeline: `N` for one created through the API. Contact and company pipelines only |
| `data.code` | string \| null | Symbolic code of a system pipeline. `null` for one created through the API. Contact and company pipelines only |

The field set depends on the entity type. For deals, the response includes `originId` and `originatorId`; for contacts (`3`) and companies (`4`), `isSystem` and `code`; for invoices and smart processes, only the common fields. The `createdDate` field from the [pipeline schema](/docs/entities/categories/fields) is not returned.

## Response example

```json
{
  "success": true,
  "data": {
    "id": 15,
    "name": "Partners pipeline",
    "sort": 500,
    "entityTypeId": 2,
    "isDefault": false,
    "originId": null,
    "originatorId": null
  }
}
```

## Error response example

422 — required field `name` not provided:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Field 'NAME' is required."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `READONLY_FIELD` | A read-only field was sent: `id`, `entityTypeId`, `isDefault`, `code`, `createdDate`, `originId` or `originatorId`. The message names the specific field |
| 422 | `BITRIX_ERROR` | Required field `name` not provided — message `Field 'NAME' is required.` |
| 422 | `BITRIX_ERROR` | `isSystem: "Y"` was sent — Bitrix24 does not allow creating a system pipeline |
| 404 | `ENTITY_NOT_FOUND` | `entityTypeId` does not match an existing type — message `Smart process not found` |
| 422 | `BITRIX_ERROR` | Entity type does not support pipelines, for example, quotes (type `7`) — message `CRM Quote entity is not supported` |
| 403 | `SCOPE_DENIED` | API key lacks the `crm` scope |
| 401 | `TOKEN_MISSING` | API key has no configured tokens |

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

## Known specifics

**Only `name` and `sort` are writable.** The other pipeline fields except `isSystem` are read-only — leave them out of the request body, or the request returns `400 READONLY_FIELD`. `isSystem` goes to Bitrix24, which does not allow creating a pipeline with `Y`. The type's main pipeline is assigned in the Bitrix24 interface.

## See also

- [List pipelines](/docs/entities/categories/list)
- [Update a pipeline](/docs/entities/categories/update)
- [Delete a pipeline](/docs/entities/categories/delete)
- [Smart process types](/docs/entities/smart-processes)
- [Batch](/docs/batch)
- [Limits and optimization](/docs/optimization)
