For AI agents: markdown of this page — /docs-content-en/entities/crm-payments/products-update.md documentation index — /llms.txt

Change the quantity in a CRM payment line item

PATCH /v1/crm-payments/:id/products/:itemId

Sets a new quantity for a CRM payment line item. The payment amount is recalculated immediately.

The field is passed flat at the JSON root, without a fields wrapper.

Parameters

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

Request fields (body)

Field Type Required Description
quantity number yes New quantity, a positive integer. No more than the line item's current quantity plus the row's remainder in the available product rows

Examples

curl — personal key

Terminal
curl -X PATCH "https://vibecode.bitrix24.com/v1/crm-payments/573/products/445" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "quantity": 3 }'

curl — OAuth application

Terminal
curl -X PATCH "https://vibecode.bitrix24.com/v1/crm-payments/573/products/445" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "quantity": 3 }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-payments/573/products/445', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ quantity: 3 }),
})

const { data } = await res.json()
console.log(`Payment ${data.accountNumber} amount: ${data.sum} ${data.currency}`)

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-payments/573/products/445', {
  method: 'PATCH',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ quantity: 3 }),
})

const { data } = await res.json()

Response fields

The response is the payment after the change, not the line item. The updated line item quantity is in GET /v1/crm-payments/:id/products.

Field Type Description
success boolean true on success
data object Payment object. Key payment fields are on the CRM payments page
data.id number Payment ID
data.accountNumber string Payment number: the linked order number and the payment's sequence number separated by /, for example 1035/1
data.paid string Paid mark: Y — paid, N — not paid
data.datePaid string | null Time of the last "paid" mark, ISO 8601 with a time zone offset. null if the payment was never marked
data.empPaidId number | null ID of the employee who last marked the payment as paid. List: GET /v1/users
data.paySystemId number Payment system ID. List: GET /v1/pay-systems
data.sum number Payment amount including the new quantity
data.currency string Currency code. List: GET /v1/currencies
data.paySystemName string Payment system name
meta.readbackUnavailable boolean Returned only with the value true when the quantity was changed but the payment could not be read back. In that case data contains only id. Do not repeat the change. Check the line items via GET /v1/crm-payments/:id/products

Response example

JSON
{
  "success": true,
  "data": {
    "id": 573,
    "accountNumber": "1035/1",
    "paid": "N",
    "datePaid": null,
    "empPaidId": null,
    "paySystemId": 19,
    "sum": 4500,
    "currency": "USD",
    "paySystemName": "Card payment"
  }
}

Error response example

404 — no line item with this itemId in this payment:

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

Errors

HTTP Code Description
400 MISSING_REQUIRED_FIELDS The body is missing and there is no Content-Type header, quantity is not provided, or the value is not a positive integer, for example 0 or 1.5
400 FST_ERR_CTP_EMPTY_JSON_BODY The Content-Type: application/json header is sent with an empty body
400 READONLY_FIELD The body contains a field other than quantity, or the body is not a JSON object, for example null or an array
400 INVALID_ID id or itemId is not a positive integer
404 ENTITY_NOT_FOUND No line item with this itemId in this payment, 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
422 BITRIX_ERROR quantity exceeds the line item's current quantity plus the row's remainder, message Not enough product to add to the payment
422 BITRIX_ERROR Bitrix24 rejected the request. The reason is in error.message
422 BITRIX_NO_EFFECT Bitrix24 did not confirm the quantity change
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.

Known specifics

Reducing the quantity returns it to the row's remainder. After a line item is reduced from 2 to 1 unit, the row's quantity in the available product rows increases by 1.

See also