
## Delete a smart process type

`DELETE /v1/smart-processes/:entityTypeId`

Deletes a smart process type by `entityTypeId`. Along with the type, all metadata related to it is deleted: pipelines, stages, access permissions, workflow settings.

**You can delete only a type that has no items.** If the type has at least one item — first delete the items via `DELETE /v1/items/:entityTypeId/:id` or move them to another type.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `entityTypeId` (path) | number | **yes** | Entity type ID. List: `GET /v1/smart-processes` |

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/smart-processes/1050" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/smart-processes/1050" \
  -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/smart-processes/1050', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

if (res.status === 204) {
  console.log('Type deleted')
} else {
  const { error } = await res.json()
  console.error('Error:', error.code, error.message)
}
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/smart-processes/1050', {
  method: 'DELETE',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

if (res.status === 204) {
  console.log('Type deleted')
}
```

## Response

On successful deletion the HTTP status `204 No Content` with an empty body is returned — success is checked by the status.

## Response example

```
HTTP/1.1 204 No Content
```

## Error response example

404 — type not found:

```json
{
  "success": false,
  "error": {
    "code": "SMART_PROCESS_NOT_FOUND",
    "message": "Smart process with entityTypeId=99999 not found"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not passed |
| 401 | `INVALID_API_KEY` | The key was not found or was revoked |
| 403 | `SCOPE_DENIED` | The API key does not have the `crm` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 400 | `INVALID_ENTITY_TYPE_ID` | `entityTypeId` is not a positive integer. Message: `entityTypeId must be a positive integer` |
| 404 | `SMART_PROCESS_NOT_FOUND` | A type with this `entityTypeId` was not found. Message: `Smart process with entityTypeId=X not found` |
| 422 | `BITRIX_ERROR` | The type has items (message: `You cannot delete an entity type that has items`) or another error from Bitrix24 |

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

## Known specifics

**Deletion is irreversible.** There is no recycle bin and no rollback — a deleted type cannot be restored. The related metadata (pipelines, stages, permissions) is deleted along with the type.

**Check the number of items before deleting.** If in doubt, get the count:

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/items/1050/aggregate" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"count": true}'
```

If `count > 0` — first delete the items or move them to another type.

**`entityTypeId` is not reused.** After deletion, Bitrix24 will not assign this same `entityTypeId` to a new type — on the next creation you will get a new value from the `≥ 1030` range.

**Relations in other types remain.** If another type references the deleted one via `relations.parent` or `relations.child`, the relation in its settings is preserved but becomes "dangling". Configure relations in the remaining types after deletion.

## See also

- [List types](/docs/entities/smart-processes/list)
- [Get type](/docs/entities/smart-processes/get)
- [Update type](/docs/entities/smart-processes/update)
- [Item aggregation](/docs/entities/items/aggregate)
- [Delete item](/docs/entities/items)
- [Limits and optimization](/docs/optimization)
