Create an item with a product from the catalog in a quantity of 4 units with an arbitrary price

How to Use Examples in Documentation

curl -X POST \
        -H "Content-Type: application/json" \
        -H "Accept: application/json" \
        -d '{"fields":{"orderId":5147,"quantity":4,"productId":6544,"currency":"USD","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":"USD","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 set of required fields
                    orderId: 5147,
                    quantity: 4,
                    productId: 6544,
                    currency: 'USD',
                    price: 1100,
                    discountPrice: -1070, // price in the catalog – 30 USD, 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' => 'USD',
                    'price' => 1100,
                    'discountPrice' => -1070,
                    'customPrice' => 'Y',
                ]
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Result

{
            "result": {
                "basketItem": {
                    "basePrice": 30,
                    "canBuy": "Y",
                    "catalogXmlId": "FUTURE-1C-CATALOG",
                    "currency": "USD",
                    "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
            }
        }