Create a Position with a Product from the Catalog in a Quantity of 4 Units at an Arbitrary Price
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect the MCP server so that the assistant can utilize the official REST documentation.
How to Use Examples in Documentation
cURL (Webhook)
cURL (OAuth)
JS
PHP
Python
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"fields":{"orderId":5147,"quantity":4,"productId":6544,"currency":"EUR","price":1100,"discountPrice":-1070,"customPrice":"Y"}}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/sale.basketitem.add
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"fields":{"orderId":5147,"quantity":4,"productId":6544,"currency":"EUR","price":1100,"discountPrice":-1070,"customPrice":"Y"},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/sale.basketitem.add
BX24.callMethod(
"sale.basketitem.add",
{
fields: { // minimum required fields
orderId: 5147,
quantity: 4,
productId: 6544,
currency: 'EUR',
price: 1100,
discountPrice: -1070, // catalog price – 30 EUR, indicating the markup
customPrice: 'Y',
}
},
)
.then(
function(result)
{
if (result.error())
{
console.error(result.error());
}
else
{
console.log(result.data());
}
},
function(error)
{
console.info(error);
}
);
require_once('crest.php');
$result = CRest::call(
'sale.basketitem.add',
[
'fields' =>
[
'orderId' => 5147,
'quantity' => 4,
'productId' => 6544,
'currency' => 'EUR',
'price' => 1100,
'discountPrice' => -1070,
'customPrice' => 'Y',
]
]
);
echo '<PRE>';
print_r($result);
echo '</PRE>';
from b24pysdk import BitrixWebhook, Client
from b24pysdk.errors import BitrixAPIError
client = Client(
BitrixWebhook(
domain="your-domain.bitrix24.com",
auth_token="your-webhook-token",
)
)
try:
result = client.sale.basketitem.add(
fields={
"orderId": 5147,
"quantity": 4,
"productId": 6544,
"currency": "EUR",
"price": 1100,
"discountPrice": -1070,
"customPrice": "Y",
},
).response.result
print(result)
except BitrixAPIError as error:
print(error)
Result
{
"result": {
"basketItem": {
"basePrice": 30,
"canBuy": "Y",
"catalogXmlId": "FUTURE-1C-CATALOG",
"currency": "EUR",
"customPrice": "N",
"dateInsert": "2024-04-23T15:59:37+02:00",
"dateUpdate": "2024-04-23T15:59:37+02:00",
"dimensions": "a:3:{s:5:\"WIDTH\";N;s:6:\"HEIGHT\";N;s:6:\"LENGTH\";N;}",
"discountPrice": -1070,
"id": 6790,
"measureCode": "768",
"measureName": "pcs",
"name": "Product",
"orderId": 5147,
"price": 1000,
"productId": 1245,
"productXmlId": "1245",
"properties": [],
"quantity": 1,
"reservations": [],
"sort": 100,
"vatIncluded": "N",
"vatRate": null,
"weight": 0,
"xmlId": "bx_6627bec8c4fdc"
}
},
"total": 1,
"time": {
"start": 1713880776.108755,
"finish": 1713880777.704221,
"duration": 1.595465898513794,
"processing": 0.973701000213623,
"date_start": "2024-04-23T15:59:36+02:00",
"date_finish": "2024-04-23T15:59:37+02:00",
"operating": 0
}
}