
## Product rows available for CRM payment

`GET /v1/crm-payments/available-products`

Returns the product rows of a CRM entity, such as a deal, with the quantity not yet included in payments.

Pass a row ID from this response as `rowId` when [adding an item to a payment](/docs/entities/crm-payments/products-add).

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `entityTypeId` (query) | number | yes | CRM entity type. For a deal, `2` |
| `entityId` (query) | number | yes | CRM entity ID. For a deal, an ID from [`GET /v1/deals`](/docs/entities/deals/list) |

The generic `filter` parameter is not applied by this endpoint. By default, the API preserves the previous HTTP 200 response and data, adds `Warning: 299 - "filter is not supported on this endpoint and was ignored"`, and records unsupported-filter use in the server log.

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/crm-payments/available-products?entityTypeId=2&entityId=8761" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/crm-payments/available-products?entityTypeId=2&entityId=8761" \
  -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/available-products?entityTypeId=2&entityId=8761', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { data } = await res.json()
for (const row of data.productRows) {
  console.log(`${row.id}: ${row.productName} — ${row.quantity} ${row.measureName} available`)
}
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-payments/available-products?entityTypeId=2&entityId=8761', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | `true` on success |
| `data.productRows` | array | Product rows of the entity |
| `data.productRows[].id` | number | ID of the entity's product row. Pass it as `rowId` to [`POST /v1/crm-payments/:id/products`](/docs/entities/crm-payments/products-add) |
| `data.productRows[].ownerId` | number | CRM entity ID |
| `data.productRows[].ownerType` | string | CRM entity type as a letter code, `D` for a deal |
| `data.productRows[].productId` | number | Product ID. Catalog: [`GET /v1/products`](/docs/entities/products/list). `0` means the row has no catalog product |
| `data.productRows[].productName` | string | Product name |
| `data.productRows[].price` | number | Price |
| `data.productRows[].priceAccount` | number | Price in the reporting currency |
| `data.productRows[].priceExclusive` | number | Price excluding tax, with discount |
| `data.productRows[].priceNetto` | number | Net price |
| `data.productRows[].priceBrutto` | number | Gross price |
| `data.productRows[].quantity` | number | Quantity not yet included in the entity's payments |
| `data.productRows[].discountTypeId` | number | How the discount is set: `1` as an amount, `2` as a percentage |
| `data.productRows[].discountRate` | number | Discount percentage |
| `data.productRows[].discountSum` | number | Discount amount |
| `data.productRows[].taxRate` | number \| null | Tax rate in percent. `null` means no tax is set |
| `data.productRows[].taxIncluded` | string | Tax included in the price: `Y` or `N` |
| `data.productRows[].customized` | string | Row edited manually: `Y` or `N` |
| `data.productRows[].measureCode` | number | Unit of measure code |
| `data.productRows[].measureName` | string | Unit of measure |
| `data.productRows[].sort` | number | Sort order |
| `data.productRows[].xmlId` | string | External row code |
| `data.productRows[].type` | number | Product type |
| `data.productRows[].taxName` | string | Tax name |

## Response example

```json
{
  "success": true,
  "data": {
    "productRows": [
      {
        "id": 2355,
        "ownerId": 8761,
        "ownerType": "D",
        "productId": 0,
        "productName": "TEST item for payment",
        "price": 1500,
        "priceAccount": 1500,
        "priceExclusive": 1500,
        "priceNetto": 1500,
        "priceBrutto": 1500,
        "quantity": 1,
        "discountTypeId": 2,
        "discountRate": 0,
        "discountSum": 0,
        "taxRate": null,
        "taxIncluded": "N",
        "customized": "Y",
        "measureCode": 796,
        "measureName": "pcs",
        "sort": 0,
        "xmlId": "",
        "type": 1,
        "taxName": "No VAT"
      }
    ]
  }
}
```

## Error response example

400: `entityTypeId` holds an unknown CRM entity type:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_ENTITY_TYPE",
    "message": "This CRM entity type has no payable product rows."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 200 | `Warning: 299` | The filter is ignored by default; previous data is preserved and the warning is sent in the `Warning` header. |
| 400 (strict mode only) | `UNSUPPORTED_FILTER` | The server mode is disabled by default; until it is enabled, the endpoint preserves HTTP 200 and the previous data. |
| 400 | `MISSING_REQUIRED_FIELDS` | `entityTypeId` or `entityId` is missing, or the value is not a positive integer |
| 400 | `INVALID_ENTITY_TYPE` | `entityTypeId` is not a CRM entity type, for example `999` |
| 404 | `ENTITY_NOT_FOUND` | No CRM entity with this `entityTypeId` and `entityId` exists |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request. The reason is in `error.message` |
| 403 | `BITRIX_ACCESS_DENIED` | The key's user has no access to the CRM entity or payment in Bitrix24 |
| 403 | `SCOPE_DENIED` | The API key lacks the `crm` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 401 | `MISSING_API_KEY` | `X-Api-Key` is missing |

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

## Known specifics

**The remainder is counted across all payments of the entity.** For a row with quantity `3`, of which `2` are already added to a payment, `quantity` is `1`. After that payment is deleted, the remainder returns to `3`.

## See also

- [Add an item to a payment](/docs/entities/crm-payments/products-add)
- [Create a CRM payment](/docs/entities/crm-payments/create)
- [Deal product rows](/docs/entities/deals/products-get)
- [CRM payments](/docs/entities/crm-payments)
