
## Delete a payment

`DELETE /v1/payments/:id`

Deletes a payment by identifier. A deleted payment cannot be restored via the API — create a new one if needed.

## Parameters

| Parameter | Type | Req. | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Payment identifier |

## Examples

### curl — personal key

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

### curl — OAuth application

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

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

### JavaScript — OAuth application

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

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

## Response

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

## Response example

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

## Error response example

422 — payment not found:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "payment is not exists"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 422 | `BITRIX_ERROR` | A payment with this ID was not found or has already been deleted |
| 403 | `SCOPE_DENIED` | The API key does not have the `sale` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

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

## Known specifics

**The order is not deleted.** Deleting a payment does not affect the parent order — the order remains, and the `sumPaid` field is recalculated automatically.

**Alternative — mark as a return.** To keep a record of the payment, use [`PATCH /v1/payments/:id`](./update.md) with `{"isReturn": "Y", "comments": "..."}` — the payment will still appear in query results with `filter[isReturn]=Y`.

## See also

- [Payment fields](./fields.md)
- [Update a payment](./update.md)
- [List payments](./list.md)
- [Get a payment](./get.md)
- [Batch](/docs/batch)
- [Limits and optimization](/docs/optimization)
