Skip to content

Rearrange Basket Order

POST basket/rearrangeBasketOrder

The "Rearrange Basket Order" API lets you reorder one or more existing orders inside a basket without modifying their parameters. Pass the basketId and either a single basketOrderId or an array of basketOrderId values listed in the new sequence you want them executed in. The server returns the updated order list reflecting the new arrangement.

Parameters

NameTypeRequiredDescription
basketIdstring | numbertrueUnique identifier of the basket whose orders are being rearranged.
basketOrderIdstring | number | arraytrueEither a single basketOrderId to reposition, or an array of basketOrderId values listed in the desired execution order.

Sample Code

bash
curl -X POST 'https://tradeapi.samco.in/basket/rearrangeBasketOrder' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-session-token: <SESSION_TOKEN>' \
  -d '{
    "basketId": "6",
    "basketOrderId": ["4", "3", "2", "1"]
  }'
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Sample {
  public static void main(String[] args) throws Exception {
    HttpClient client = HttpClient.newHttpClient();

    String requestBody = "{\n" +
        "  \"basketId\": \"6\",\n" +
        "  \"basketOrderId\": [\"4\", \"3\", \"2\", \"1\"]\n" +
        "}";

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://tradeapi.samco.in/basket/rearrangeBasketOrder"))
        .header("Content-Type", "application/json")
        .header("Accept", "application/json")
        .header("x-session-token", "<SESSION_TOKEN>")
        .POST(HttpRequest.BodyPublishers.ofString(requestBody))
        .build();

    HttpResponse<String> response =
        client.send(request, HttpResponse.BodyHandlers.ofString());
    System.out.println(response.body());
  }
}
js
(async () => {
  const headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'x-session-token': '<SESSION_TOKEN>',
  };

  const requestBody = {
    basketId: "6",
    basketOrderId: ["4", "3", "2", "1"],
  };

  const response = await fetch('https://tradeapi.samco.in/basket/rearrangeBasketOrder', {
    method: 'POST',
    headers,
    body: JSON.stringify(requestBody),
  });

  const data = await response.json();
  console.log(data);
})();
py
import requests
import json

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token': '<SESSION_TOKEN>',
}

payload = {
  "basketId": "6",
  "basketOrderId": ["4", "3", "2", "1"],
}

r = requests.post('https://tradeapi.samco.in/basket/rearrangeBasketOrder',
  headers=headers, json=payload)

print(r.json())

Sample Responses

json
{
    "serverTime": "21/08/24 17:30:14",
    "msgId": "a4b7d930-1c1e-4ad1-9a85-dc09a2c2f8e3",
    "status": "Success",
    "statusMessage": "Basket orders rearranged successfully",
    "rearrangeOrderList": {
        "basketId": 6,
        "orders": [
            { "basketOrderId": 4, "sequence": 1 },
            { "basketOrderId": 3, "sequence": 2 },
            { "basketOrderId": 2, "sequence": 3 },
            { "basketOrderId": 1, "sequence": 4 }
        ]
    }
}
json
{
    "serverTime": "21/08/24 17:30:32",
    "msgId": "f01e1c44-9c34-4b35-89ac-fa9c54b7ab21",
    "status": "Failure",
    "statusMessage": "No such Basket found"
}

Response Schema

Status Code 200

NameTypeDescription
serverTimestringThe server's timestamp when the response was generated.
msgIdstringUnique message ID associated with the response.
statusstringIndicates the success or failure of the API call.
statusMessagestringProvides additional information about the status of the API call.
rearrangeOrderListobjectUpdated ordering of the basket's orders, reflecting the new sequence.
basketIdnumberIdentifier of the basket whose orders were rearranged.
ordersarrayArray of orders in the basket, each with its basketOrderId and new sequence position.