Cart API
This API allows you to create & manage shopping carts, including retrieving cart details and updating cart items.
Create Cart
Create a new fresh cart that you can use in the future to add cart items or create a Checkout.
POST /commerce/cart
{
"userId": "any-unique-id-from-your-system",
"idempotencyKey": "your-optional-idempotency-key",
"currency": "EGP"
}
Response (201)
{
"cartId": "7e81c14b-893d-4c98-b92a-da0f7ccf732b",
"customerAddresses": [
{
"phone": "+201012720555",
"additionalPhone": "+201012720555",
"address": "Street 23, Building 6B, Maadi",
"additionalInfo": "6th Floor, left after elevator",
"region": "Al Beheira",
"city": "Maadi-Maadi Degla",
"id": "ed8b291c-d7e6-4d5c-82cb-0febbe9218cc"
}
]
}
You need to store the cartId in your infrastructure for future requests.
Fetch Cart
Retrieves the current cart details including items, quantities, and totals.
GET /cart/{{cartId}}
Response
{
"cartId": "7e81c14b-893d-4c98-b92a-da0f7ccf732b",
"currency": "EGP",
"idempotencyKey": "your-optional-idempotency-key",
"totals": {
"subtotal": 3333157,
"tax": 466543,
"shipping": null,
"total": 3799800
},
"products": [
// An array of Product Objects
]
}
Update Cart
Modifies the contents of the cart, including adding, updating, or removing items. When you update the cart using this endpoint, you need to provide all the products that you want to see in a cart, similar to a PUT request.
POST /cart
{
"cartId": "7e81c14b-893d-4c98-b92a-da0f7ccf732b",
"products": [
{
"id": "c7d038eb-6b01-4116-92f5-6de418fa1ce7",
"quantity": 12
},
{
"id": "86560079-d869-4fa1-b10d-3aa1de7cd413",
"quantity": 2
}
]
}
Response (200)
{
"cartId": "7e81c14b-893d-4c98-b92a-da0f7ccf732b",
"idempotencyKey": "your-optional-idempotency-key",
"products": [
// An array of Product Objects in the cart
],
"currency": "EGP",
"totals": {
"subtotal": 3333157,
"tax": 466543,
"total": 3799800
}
}
Delete Cart
Carts that are not converted into an Order are automatically deleted 6 months after their creation.