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

Add a product to an invoice

POST /v1/invoices/:id/products

Adds a single product line to an invoice. Unlike PUT /v1/invoices/:id/products, it does not replace existing lines.

Request fields (body)

Parameter Type Req. Description
id (path) number yes Invoice ID
productId number no Catalog product ID. If set without productName, the name is taken from the catalog. Catalog: GET /v1/products
productName string no Product line name — for an arbitrary line without a catalog product. Specify at least one of productId / productName.
price number no Price per unit
quantity number no Quantity
discount number no Discount amount
taxRate number no Tax rate (%)
taxIncluded boolean no Tax included in the price

Examples

curl — personal key

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/invoices/58/products" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "productId": 1, "price": 25000, "quantity": 2 }'

curl — OAuth application

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/invoices/58/products" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "productId": 1, "price": 25000, "quantity": 2 }'

JavaScript — personal key

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/invoices/58/products', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ productId: 1, price: 25000, quantity: 2 }),
})

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

JavaScript — OAuth application

javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/invoices/58/products', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ productId: 1, price: 25000, quantity: 2 }),
})

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

Response fields

Field Type Description
data.id number ID of the created product line

Response example

JSON
{
  "success": true,
  "data": {
    "id": 1465
  }
}

Error response example

404 — invoice not found:

JSON
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Item not found"
  }
}

Errors

HTTP Code Description
404 ENTITY_NOT_FOUND Invoice not found
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.

See also