
## Delete a line item from a CRM payment

`DELETE /v1/crm-payments/:id/products/:itemId`

Deletes a line item from a CRM payment. The payment amount is recalculated immediately. A deleted line item cannot be restored via the API. Add it again if needed.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Payment ID. Payments of a CRM item: [`GET /v1/crm-payments`](/docs/entities/crm-payments/list) |
| `itemId` (path) | number | yes | Payment line item ID, not the deal product row ID. List: [`GET /v1/crm-payments/:id/products`](/docs/entities/crm-payments/products-list), field `data[].id` |

## Examples

### curl — personal key

```bash
curl -X DELETE "https://vibecode.bitrix24.com/v1/crm-payments/573/products/445" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

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

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

### JavaScript — OAuth application

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

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

## Response

On successful deletion the response is HTTP status `204 No Content` with an empty body. Check success by the status. The new payment amount is returned by [`GET /v1/crm-payments/:id`](/docs/entities/crm-payments/get).

## Response example

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

## Error response example

404 — no line item with this `itemId` in this payment, including one already deleted:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Payable item has not been found in this payment."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 404 | `ENTITY_NOT_FOUND` | No line item with this `itemId` in this payment, including one already deleted, message `Payable item has not been found in this payment.` |
| 404 | `ENTITY_NOT_FOUND` | No payment with this `id`, message `Payment has not been found` |
| 400 | `INVALID_ID` | `id` or `itemId` is not a positive integer |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request. The reason is in `error.message` |
| 422 | `BITRIX_NO_EFFECT` | Bitrix24 did not confirm the deletion |
| 403 | `BITRIX_ACCESS_DENIED` | The key's user has no access to the CRM item or the payment in Bitrix24 |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is not allowed to write |
| 403 | `SCOPE_DENIED` | The API key does not have the `crm` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 401 | `MISSING_API_KEY` | `X-Api-Key` is not provided |

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

## Known specifics

**The line item quantity returns to the row's remainder.** After a line item of 3 units is deleted, the row's `quantity` in the [available product rows](/docs/entities/crm-payments/available-products) again includes these 3 units, and they can be added to this or another payment.

## See also

- [List payment line items](/docs/entities/crm-payments/products-list)
- [Add a line item to a payment](/docs/entities/crm-payments/products-add)
- [Change the quantity in a line item](/docs/entities/crm-payments/products-update)
- [Delete a CRM payment](/docs/entities/crm-payments/delete)
- [CRM payments](/docs/entities/crm-payments)
