Create a Position with a Product That Does Not Exist on the Site (2 pcs at a price of 900 RUB)
If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to 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,"productId":0,"name":"Trial Product","quantity":2,"basePrice":1000,"price":900,"discountPrice":100,"customPrice":"Y","canBuy":"Y","weight":40,"measureCode":"768","measureName":"pcs","sort":400,"xmlId":"BasketPositionId","dimensions":"a:3:{s:5:\"WIDTH\";i:244;s:6:\"HEIGHT\";i:100;s:6:\"LENGTH\";i:31;}","vatRate":10,"vatIncluded":"Y","productXmlId":"ProductKey","currency":"RUB"}}' \
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,"productId":0,"name":"Trial Product","quantity":2,"basePrice":1000,"price":900,"discountPrice":100,"customPrice":"Y","canBuy":"Y","weight":40,"measureCode":"768","measureName":"pcs","sort":400,"xmlId":"BasketPositionId","dimensions":"a:3:{s:5:\"WIDTH\";i:244;s:6:\"HEIGHT\";i:100;s:6:\"LENGTH\";i:31;}","vatRate":10,"vatIncluded":"Y","productXmlId":"ProductKey","currency":"RUB"},"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/sale.basketitem.add
BX24.callMethod(
"sale.basketitem.add",
{
fields: { // all fields are filled
orderId: 5147,
productId: 0,
name: 'Trial Product',
quantity: 2,
basePrice: 1000,
price: 900,
discountPrice: 100,
customPrice: 'Y',
canBuy: 'Y',
weight: 40,
measureCode: '768',
measureName: 'pcs',
sort: 400,
xmlId: 'BasketPositionId',
dimensions: 'a:3:{s:5:"WIDTH";i:244;s:6:"HEIGHT";i:100;s:6:"LENGTH";i:31;}', // serialized array
vatRate: 10,
vatIncluded: 'Y',
productXmlId: 'ProductKey',
currency: 'RUB',
}
},
)
.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,
'productId' => 0,
'name' => 'Trial Product',
'quantity' => 2,
'basePrice' => 1000,
'price' => 900,
'discountPrice' => 100,
'customPrice' => 'Y',
'canBuy' => 'Y',
'weight' => 40,
'measureCode' => '768',
'measureName' => 'pcs',
'sort' => 400,
'xmlId' => 'BasketPositionId',
'dimensions' => 'a:3:{s:5:"WIDTH";i:244;s:6:"HEIGHT";i:100;s:6:"LENGTH";i:31;}',
'vatRate' => 10,
'vatIncluded' => 'Y',
'productXmlId' => 'ProductKey',
'currency' => 'RUB',
]
]
);
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,
"productId": 0,
"name": "Trial Product",
"quantity": 2,
"basePrice": 1000,
"price": 900,
"discountPrice": 100,
"customPrice": "Y",
"canBuy": "Y",
"weight": 40,
"measureCode": "768",
"measureName": "pcs",
"sort": 400,
"xmlId": "BasketPositionId",
"dimensions": 'a:3:{s:5:"WIDTH";i:244;s:6:"HEIGHT";i:100;s:6:"LENGTH";i:31;}',
"vatRate": 10,
"vatIncluded": "Y",
"productXmlId": "ProductKey",
"currency": "RUB",
},
).response.result
print(result)
except BitrixAPIError as error:
print(error)
Result
{
"result": {
"basketItem": {
"basePrice": 1000,
"canBuy": "Y",
"currency": "RUB",
"customPrice": "Y",
"dateInsert": "2024-04-23T18:51:28+02:00",
"dateUpdate": "2024-04-23T18:51:28+02:00",
"dimensions": "a:3:{s:5:\"WIDTH\";i:244;s:6:\"HEIGHT\";i:100;s:6:\"LENGTH\";i:31;}",
"discountPrice": 100,
"id": 6791,
"measureCode": "768",
"measureName": "pcs",
"name": "Trial Product",
"orderId": 5147,
"price": 900,
"productId": 0,
"productXmlId": "ProductKey",
"properties": [],
"quantity": 2,
"reservations": [],
"sort": 400,
"vatIncluded": "Y",
"vatRate": 10,
"weight": 40,
"xmlId": "BasketPositionId"
}
},
"total": 1,
"time": {
"start": 1713891087.689427,
"finish": 1713891089.165652,
"duration": 1.4762251377105713,
"processing": 0.8683149814605713,
"date_start": "2024-04-23T18:51:27+02:00",
"date_finish": "2024-04-23T18:51:29+02:00",
"operating": 0
}
}