Cart (2.0.0)

Download OpenAPI specification:Download

fabric's Cart API lets you add, update, and remove items from your Storefront cart, either as a guest user or as a logged-in user. It also provides functionality to merge carts when you switch from guest user to logged-in user, and apply coupon codes and other attributes (for example, gift wrapping) to the cart items. Additionally, it supports more advanced use cases such as using multiple carts within a B2B organization and sharing of carts, as well as supporting a unified cart experience for multi-region and multi-brand businesses.

This API provides high performance, scalability, multi-tenancy, and configurability to the end-to-end order processing actions that start from an item being added to the cart, through the pre-checkout stage that includes billing, shipping, and payment details, to the checkout stage where the order is processed and confirmed by the Order Management System (OMS).

Note: This is the new Cart v2 API. To view fabric's legacy Cart v1 API, navigate to OMS > Commerce APIs > Cart from the left side navigation pane.

Cart

Cart endpoints let you do basic cart operations, such as create a cart, add item to the cart, update items, remove items, delete cart, update status of the cart, and more.

Get all carts

Get all carts belonging to the user or to a merchant by authorization token

Request
query Parameters
offset
integer or null <int32>
limit
integer or null <int32>
header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

Authorization
required
string

Authorization token for the user

Example: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZjIyMTU4...
x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Responses
200

OK

400

Client error

404

Not found

500

Internal server error

get/v2/carts
Response samples
application/json
{
  • "count": 5,
  • "carts": [
    ],
  • "offset": 3,
  • "limit": 7
}

Add items to cart

Add items to cart, or create a new cart if cart does not exist

Request
header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

Authorization
string

Authorization token for the user

Example: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZjIyMTU4...
x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Request Body schema: application/json

Request body for adding items to, or updating items in the cart

cartId
string or null

Existing cart ID, or NULL for new cart

required
Array of objects (CartItemPayload) non-empty

Items to add to cart

userId
string or null

Cart user ID

name
string or null

Name for the cart

description
string or null

Description for the cart

networkCode
string or null

networkCode for the cart. Must pass it if you're using inventoryV2 with CartV2

Responses
200

OK

400

Client error

404

Not found

500

Internal server error

post/v2/carts/items
Request samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ],
  • "userId": "61b8e921d0cf2e000882b09f",
  • "name": "cart_it",
  • "description": "cart for the IT department",
  • "networkCode": "ShipToHome"
}
Response samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ],
  • "createdAt": "2022-02-11T14:09:40.836703",
  • "updatedAt": "2022-02-22T22:36:40.194293",
  • "totalItems": 3,
  • "totalUniqueItems": 2,
  • "cartState": "string",
  • "tenantId": "5f689caa4216e7000750d1ef",
  • "accountId": "5f689caa4216e7000750d1ef",
  • "userId": "61b8e921d0cf2e000882b09f",
  • "totalAmount": 55.1,
  • "subTotal": 60,
  • "totalDiscount": "4.9",
  • "currency": "USD",
  • "attributes": [
    ],
  • "metadata": {
    },
  • "allPromosApplied": [
    ],
  • "sharedUserIds": [
    ],
  • "error": {
    }
}

Search for carts

Search for carts meeting specified criteria, including creation date, status, user, approver, and purchase order

Request
header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

Authorization
required
string

Authorization token for the user

Example: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZjIyMTU4...
x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Request Body schema: application/json

Request body for search cart

offset
required
integer <int32>

Pagination offset (starts with zero)

limit
required
integer <int32>

Number of cart responses per page

required
object (CartFilter)

Parameters used to search for carts

Responses
200

OK

400

Client error

500

Internal server error

post/v2/carts/search
Request samples
application/json
{
  • "offset": 0,
  • "limit": 10,
  • "filter": {
    }
}
Response samples
application/json
{
  • "offset": 0,
  • "limit": 10,
  • "count": 10,
  • "carts": [
    ]
}

Get specific cart

Get cart for specified cart ID

Request
path Parameters
cartId
required
string

Cart ID

Example: d7e78a21-bee3-4448-bf1c-d5b5461dbda2
header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Responses
200

OK

400

Client error

404

Not found

500

Internal server error

get/v2/carts/{cartId}
Response samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ],
  • "createdAt": "2022-02-11T14:09:40.836703",
  • "updatedAt": "2022-02-22T22:36:40.194293",
  • "totalItems": 3,
  • "totalUniqueItems": 2,
  • "cartState": "string",
  • "tenantId": "5f689caa4216e7000750d1ef",
  • "accountId": "5f689caa4216e7000750d1ef",
  • "userId": "61b8e921d0cf2e000882b09f",
  • "totalAmount": 55.1,
  • "subTotal": 60,
  • "totalDiscount": "4.9",
  • "currency": "USD",
  • "attributes": [
    ],
  • "metadata": {
    },
  • "allPromosApplied": [
    ],
  • "sharedUserIds": [
    ],
  • "error": {
    }
}

Delete cart items

Deletes cart information after purchase of cart items is complete. This is a soft delete that sets the status of the cart to deleted after the cart items are purchased and the order moves to shipping. The cart ID is not deleted.

Request
path Parameters
cartId
required
string

ID of cart to be deleted

Example: d7e78a21-bee3-4448-bf1c-d5b5461dbda2
header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
orderNumber
string or null
Example: 2947-5955-82579
Responses
200

OK

400

Client error

404

Not found

500

Internal server error

delete/v2/carts/{cartId}
Response samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ],
  • "createdAt": "2022-02-11T14:09:40.836703",
  • "updatedAt": "2022-02-22T22:36:40.194293",
  • "totalItems": 3,
  • "totalUniqueItems": 2,
  • "cartState": "string",
  • "tenantId": "5f689caa4216e7000750d1ef",
  • "accountId": "5f689caa4216e7000750d1ef",
  • "userId": "61b8e921d0cf2e000882b09f",
  • "totalAmount": 55.1,
  • "subTotal": 60,
  • "totalDiscount": "4.9",
  • "currency": "USD",
  • "attributes": [
    ],
  • "metadata": {
    },
  • "allPromosApplied": [
    ],
  • "sharedUserIds": [
    ],
  • "error": {
    }
}

Delete items from specific cart

Removes all items from specified cart

Request
path Parameters
cartId
required
string

ID of cart for which all the items need to be removed

Example: d7e78a21-bee3-4448-bf1c-d5b5461dbda2
header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Responses
200

OK

400

Client error

404

Not found

500

Internal server error

delete/v2/carts/{cartId}/items
Response samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ],
  • "createdAt": "2022-02-11T14:09:40.836703",
  • "updatedAt": "2022-02-22T22:36:40.194293",
  • "totalItems": 3,
  • "totalUniqueItems": 2,
  • "cartState": "string",
  • "tenantId": "5f689caa4216e7000750d1ef",
  • "accountId": "5f689caa4216e7000750d1ef",
  • "userId": "61b8e921d0cf2e000882b09f",
  • "totalAmount": 55.1,
  • "subTotal": 60,
  • "totalDiscount": "4.9",
  • "currency": "USD",
  • "attributes": [
    ],
  • "metadata": {
    },
  • "allPromosApplied": [
    ],
  • "sharedUserIds": [
    ],
  • "error": {
    }
}

Update items in specific cart

Updates item information, such as quantity, price, attributes, in a specified cart

Request
path Parameters
cartId
required
string

ID of cart for which items need to be updated

Example: d7e78a21-bee3-4448-bf1c-d5b5461dbda2
header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Request Body schema: application/json

Request body containing item information to be updated

cartId
string or null

Cart ID

required
Array of objects (CartItemModifyPayload) non-empty

Items to be updated

Responses
200

OK

400

Client error

404

Not found

500

Internal server error

patch/v2/carts/{cartId}/items
Request samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ]
}
Response samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ],
  • "createdAt": "2022-02-11T14:09:40.836703",
  • "updatedAt": "2022-02-22T22:36:40.194293",
  • "totalItems": 3,
  • "totalUniqueItems": 2,
  • "cartState": "string",
  • "tenantId": "5f689caa4216e7000750d1ef",
  • "accountId": "5f689caa4216e7000750d1ef",
  • "userId": "61b8e921d0cf2e000882b09f",
  • "totalAmount": 55.1,
  • "subTotal": 60,
  • "totalDiscount": "4.9",
  • "currency": "USD",
  • "attributes": [
    ],
  • "metadata": {
    },
  • "allPromosApplied": [
    ],
  • "sharedUserIds": [
    ],
  • "error": {
    }
}

Remove an item from the cart

Deletes a specified item from a specified cart

Request
path Parameters
cartId
required
string

ID of cart for which the specified item needs to be removed

Example: d7e78a21-bee3-4448-bf1c-d5b5461dbda2
lineItemId
required
integer <int32>

Cart item sequence number (starts at 1) of item to be removed from cart

header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

Authorization
string

Authorization token for the user

Example: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZjIyMTU4...
x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Responses
200

OK

400

Client error

404

Not found

500

Internal server error

delete/v2/carts/{cartId}/items/{lineItemId}
Response samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ],
  • "createdAt": "2022-02-11T14:09:40.836703",
  • "updatedAt": "2022-02-22T22:36:40.194293",
  • "totalItems": 3,
  • "totalUniqueItems": 2,
  • "cartState": "string",
  • "tenantId": "5f689caa4216e7000750d1ef",
  • "accountId": "5f689caa4216e7000750d1ef",
  • "userId": "61b8e921d0cf2e000882b09f",
  • "totalAmount": 55.1,
  • "subTotal": 60,
  • "totalDiscount": "4.9",
  • "currency": "USD",
  • "attributes": [
    ],
  • "metadata": {
    },
  • "allPromosApplied": [
    ],
  • "sharedUserIds": [
    ],
  • "error": {
    }
}

Merge carts

Merges guest cart and logged-in user cart

Request
path Parameters
cartId
required
string

ID of guest cart which is to be merged

Example: d7e78a21-bee3-4448-bf1c-d5b5461dbda2
header Parameters
Authorization
required
string

Authorization token for the user

required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Responses
200

OK

400

Client error

404

Not found

500

Internal server error

patch/v2/carts/{cartId}/merge
Response samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ],
  • "createdAt": "2022-02-11T14:09:40.836703",
  • "updatedAt": "2022-02-22T22:36:40.194293",
  • "totalItems": 3,
  • "totalUniqueItems": 2,
  • "cartState": "string",
  • "tenantId": "5f689caa4216e7000750d1ef",
  • "accountId": "5f689caa4216e7000750d1ef",
  • "userId": "61b8e921d0cf2e000882b09f",
  • "totalAmount": 55.1,
  • "subTotal": 60,
  • "totalDiscount": "4.9",
  • "currency": "USD",
  • "attributes": [
    ],
  • "metadata": {
    },
  • "allPromosApplied": [
    ],
  • "sharedUserIds": [
    ],
  • "error": {
    }
}

Remove an individual promotion from all items in a specific cart

Removes a specified promotion from all items in specified cart

Request
path Parameters
cartId
required
string

ID of cart ID from which promotion needs to be removed

Example: d7e78a21-bee3-4448-bf1c-d5b5461dbda2
promoCode
required
string

Code of promotion to be removed

header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Responses
200

OK

400

Client error

404

Not found

500

Internal server error

delete/v2/carts/{cartId}/promo/{promoCode}
Response samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ],
  • "createdAt": "2022-02-11T14:09:40.836703",
  • "updatedAt": "2022-02-22T22:36:40.194293",
  • "totalItems": 3,
  • "totalUniqueItems": 2,
  • "cartState": "string",
  • "tenantId": "5f689caa4216e7000750d1ef",
  • "accountId": "5f689caa4216e7000750d1ef",
  • "userId": "61b8e921d0cf2e000882b09f",
  • "totalAmount": 55.1,
  • "subTotal": 60,
  • "totalDiscount": "4.9",
  • "currency": "USD",
  • "attributes": [
    ],
  • "metadata": {
    },
  • "allPromosApplied": [
    ],
  • "sharedUserIds": [
    ],
  • "error": {
    }
}

Apply a specific promotion to all items in a specific cart

Apply a specified promotion or coupon to all items of a specific cart

Request
path Parameters
cartId
required
string

ID of cart ID to which promotion needs to be applied

Example: d7e78a21-bee3-4448-bf1c-d5b5461dbda2
promoCode
required
string

Code of promotion to be applied

header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Responses
200

OK

400

Client error

404

Not found

500

Internal server error

post/v2/carts/{cartId}/promos/{promoCode}
Response samples
application/json
{
  • "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  • "items": [
    ],
  • "createdAt": "2022-02-11T14:09:40.836703",
  • "updatedAt": "2022-02-22T22:36:40.194293",
  • "totalItems": 3,
  • "totalUniqueItems": 2,
  • "cartState": "string",
  • "tenantId": "5f689caa4216e7000750d1ef",
  • "accountId": "5f689caa4216e7000750d1ef",
  • "userId": "61b8e921d0cf2e000882b09f",
  • "totalAmount": 55.1,
  • "subTotal": 60,
  • "totalDiscount": "4.9",
  • "currency": "USD",
  • "attributes": [
    ],
  • "metadata": {
    },
  • "allPromosApplied": [
    ],
  • "sharedUserIds": [
    ],
  • "error": {
    }
}

Update status of specific cart

Update status of specified cart

Request
path Parameters
cartId
required
string

ID for cart whose status is to be updated

Example: d7e78a21-bee3-4448-bf1c-d5b5461dbda2
cartStatus
required
string

New cart status

Enum: "PENDING" "PENDING_APPROVAL" "APPROVED" "SUBMITTED" "DELETED"
header Parameters
required
object (xSiteContext)

JSON object containing channel, account, stage, and date.

x-api-key
required
string

API Key for Gateway

Example: zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx
Responses
200

OK

400

Client error