Add items to cart - Fabric

Documentation Index

Fetch the complete documentation index at: /llms.txt

Use this file to discover all available pages before exploring further.

Skip to main content

Add items to cart

cURL

curl --request POST \
  --url https://prod.cart.fabric.inc/v2/carts/items \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --header 'x-site-context: <x-site-context>' \
  --data '
{
  "items": [\
    {\
      "itemId": "1000000001",\
      "quantity": 1,\
      "price": {\
        "currency": "USD",\
        "amount": 100,\
        "discount": {\
          "price": 80,\
          "promosApplied": [\
            {\
              "promoId": "fza065tdr787",\
              "promoCode": "coupon123",\
              "value": "20",\
              "unit": "%OFF"\
            }\
          ],\
          "discounts": [\
            {\
              "promoId": "fza065tdr787",\
              "promoCode": "coupon123",\
              "promoTitle": "New Year discount",\
              "quantity": 1,\
              "amount": 20,\
              "value": 20,\
              "groupId": "new-items",\
              "promotionType": "PROMOTION",\
              "priority": 1,\
              "stackable": false,\
              "sku": "16B2GS8LD5FDS",\
              "itemId": "1000000001",\
              "itemKey": "Key1234",\
              "message": "New Year Promotion",\
              "unit": "%OFF",\
              "proratedQuantity": 1,\
              "proratedAmount": 3.33\
            }\
          ],\
          "discountAmount": 20\
        },\
        "sale": 80\
      },\
      "sku": "16B2GS8LD5FDS",\
      "priceListId": "100000",\
      "type": "WEB_SHIP",\
      "subType": "Border-free",\
      "extra": {\
        "productFamily": "Laptop computers"\
      },\
      "fulfillment": {\
        "type": "WEB_SHIP",\
        "networkCode": "ShipToCNC",\
        "channelId": "12"\
      },\
      "group": [\
        "61d38e117162b7dba69c3d6d"\
      ]\
    }\
  ],
  "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  "name": "cart_it",
  "description": "cart for the IT department",
  "networkCode": "ShipToHome"
}
'
import requests

url = "https://prod.cart.fabric.inc/v2/carts/items"

payload = {
    "items": [\
        {\
            "itemId": "1000000001",\
            "quantity": 1,\
            "price": {\
                "currency": "USD",\
                "amount": 100,\
                "discount": {\
                    "price": 80,\
                    "promosApplied": [\
                        {\
                            "promoId": "fza065tdr787",\
                            "promoCode": "coupon123",\
                            "value": "20",\
                            "unit": "%OFF"\
                        }\
                    ],\
                    "discounts": [\
                        {\
                            "promoId": "fza065tdr787",\
                            "promoCode": "coupon123",\
                            "promoTitle": "New Year discount",\
                            "quantity": 1,\
                            "amount": 20,\
                            "value": 20,\
                            "groupId": "new-items",\
                            "promotionType": "PROMOTION",\
                            "priority": 1,\
                            "stackable": False,\
                            "sku": "16B2GS8LD5FDS",\
                            "itemId": "1000000001",\
                            "itemKey": "Key1234",\
                            "message": "New Year Promotion",\
                            "unit": "%OFF",\
                            "proratedQuantity": 1,\
                            "proratedAmount": 3.33\
                        }\
                    ],\
                    "discountAmount": 20\
                },\
                "sale": 80\
            },\
            "sku": "16B2GS8LD5FDS",\
            "priceListId": "100000",\
            "type": "WEB_SHIP",\
            "subType": "Border-free",\
            "extra": { "productFamily": "Laptop computers" },\
            "fulfillment": {\
                "type": "WEB_SHIP",\
                "networkCode": "ShipToCNC",\
                "channelId": "12"\
            },\
            "group": ["61d38e117162b7dba69c3d6d"]\
        }\
    ],
    "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
    "name": "cart_it",
    "description": "cart for the IT department",
    "networkCode": "ShipToHome"
}
headers = {
    "x-site-context": "<x-site-context>",
    "Authorization": "<authorization>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {
    'x-site-context': '<x-site-context>',
    Authorization: '<authorization>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    items: [\
      {\
        itemId: '1000000001',\
        quantity: 1,\
        price: {\
          currency: 'USD',\
          amount: 100,\
          discount: {\
            price: 80,\
            promosApplied: [{promoId: 'fza065tdr787', promoCode: 'coupon123', value: '20', unit: '%OFF'}],\
            discounts: [\
              {\
                promoId: 'fza065tdr787',\
                promoCode: 'coupon123',\
                promoTitle: 'New Year discount',\
                quantity: 1,\
                amount: 20,\
                value: 20,\
                groupId: 'new-items',\
                promotionType: 'PROMOTION',\
                priority: 1,\
                stackable: false,\
                sku: '16B2GS8LD5FDS',\
                itemId: '1000000001',\
                itemKey: 'Key1234',\
                message: 'New Year Promotion',\
                unit: '%OFF',\
                proratedQuantity: 1,\
                proratedAmount: 3.33\
              }\
            ],\
            discountAmount: 20\
          },\
          sale: 80\
        },\
        sku: '16B2GS8LD5FDS',\
        priceListId: '100000',\
        type: 'WEB_SHIP',\
        subType: 'Border-free',\
        extra: {productFamily: 'Laptop computers'},\
        fulfillment: {type: 'WEB_SHIP', networkCode: 'ShipToCNC', channelId: '12'},\
        group: ['61d38e117162b7dba69c3d6d']\
      }\
    ],
    cartId: 'd7e78a21-bee3-4448-bf1c-d5b5461dbda2',
    name: 'cart_it',
    description: 'cart for the IT department',
    networkCode: 'ShipToHome'
  })
};

fetch('https://prod.cart.fabric.inc/v2/carts/items', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://prod.cart.fabric.inc/v2/carts/items",\
  CURLOPT_RETURNTRANSFER => true,\
  CURLOPT_ENCODING => "",\
  CURLOPT_MAXREDIRS => 10,\
  CURLOPT_TIMEOUT => 30,\
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
  CURLOPT_CUSTOMREQUEST => "POST",\
  CURLOPT_POSTFIELDS => json_encode([\
    'items' => [\
        [\
                'itemId' => '1000000001',\
                'quantity' => 1,\
                'price' => [\
                                'currency' => 'USD',\
                                'amount' => 100,\
                                'discount' => [\
                                                                'price' => 80,\
                                                                'promosApplied' => [\
                                                                                                                                [\
                                                                                                                                                                                                                                                                'promoId' => 'fza065tdr787',\
                                                                                                                                                                                                                                                                'promoCode' => 'coupon123',\
                                                                                                                                                                                                                                                                'value' => '20',\
                                                                                                                                                                                                                                                                'unit' => '%OFF'\
                                                                                                                                ]\
                                                                ],\
                                                                'discounts' => [\
                                                                                                                                [\
                                                                                                                                                                                                                                                                'promoId' => 'fza065tdr787',\
                                                                                                                                                                                                                                                                'promoCode' => 'coupon123',\
                                                                                                                                                                                                                                                                'promoTitle' => 'New Year discount',\
                                                                                                                                                                                                                                                                'quantity' => 1,\
                                                                                                                                                                                                                                                                'amount' => 20,\
                                                                                                                                                                                                                                                                'value' => 20,\
                                                                                                                                                                                                                                                                'groupId' => 'new-items',\
                                                                                                                                                                                                                                                                'promotionType' => 'PROMOTION',\
                                                                                                                                                                                                                                                                'priority' => 1,\
                                                                                                                                                                                                                                                                'stackable' => false,\
                                                                                                                                                                                                                                                                'sku' => '16B2GS8LD5FDS',\
                                                                                                                                                                                                                                                                'itemId' => '1000000001',\
                                                                                                                                                                                                                                                                'itemKey' => 'Key1234',\
                                                                                                                                                                                                                                                                'message' => 'New Year Promotion',\
                                                                                                                                                                                                                                                                'unit' => '%OFF',\
                                                                                                                                                                                                                                                                'proratedQuantity' => 1,\
                                                                                                                                                                                                                                                                'proratedAmount' => 3.33\
                                                                                                                                ]\
                                                                ],\
                                                                'discountAmount' => 20\
                                ],\
                                'sale' => 80\
                ],\
                'sku' => '16B2GS8LD5FDS',\
                'priceListId' => '100000',\
                'type' => 'WEB_SHIP',\
                'subType' => 'Border-free',\
                'extra' => [\
                                'productFamily' => 'Laptop computers'\
                ],\
                'fulfillment' => [\
                                'type' => 'WEB_SHIP',\
                                'networkCode' => 'ShipToCNC',\
                                'channelId' => '12'\
                ],\
                'group' => [\
                                '61d38e117162b7dba69c3d6d'\
                ]\
        ]\
    ],\
    'cartId' => 'd7e78a21-bee3-4448-bf1c-d5b5461dbda2',\
    'name' => 'cart_it',\
    'description' => 'cart for the IT department',\
    'networkCode' => 'ShipToHome'\
  ]),\
  CURLOPT_HTTPHEADER => [\
    "Authorization: <authorization>",\
    "Content-Type: application/json",\
    "x-site-context: <x-site-context>"\
  ],\
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io"
)

func main() {

url := "https://prod.cart.fabric.inc/v2/carts/items"

payload := strings.NewReader("{\n  \"items\": [\n    {\n      \"itemId\": \"1000000001\",\n      \"quantity\": 1,\n      \"price\": {\n        \"currency\": \"USD\",\n        \"amount\": 100,\n        \"discount\": {\n          \"price\": 80,\n          \"promosApplied\": [\n            {\n              \"promoId\": \"fza065tdr787\",\n              \"promoCode\": \"coupon123\",\n              \"value\": \"20\",\n              \"unit\": \"%OFF\"\n            }\n          ],\n          \"discounts\": [\n            {\n              \"promoId\": \"fza065tdr787\",\n              \"promoCode\": \"coupon123\",\n              \"promoTitle\": \"New Year discount\",\n              \"quantity\": 1,\n              \"amount\": 20,\n              \"value\": 20,\n              \"groupId\": \"new-items\",\n              \"promotionType\": \"PROMOTION\",\n              \"priority\": 1,\n              \"stackable\": false,\n              \"sku\": \"16B2GS8LD5FDS\",\n              \"itemId\": \"1000000001\",\n              \"itemKey\": \"Key1234\",\n              \"message\": \"New Year Promotion\",\n              \"unit\": \"%OFF\",\n              \"proratedQuantity\": 1,\n              \"proratedAmount\": 3.33\n            }\n          ],\n          \"discountAmount\": 20\n        },\n        \"sale\": 80\n      },\n      \"sku\": \"16B2GS8LD5FDS\",\n      \"priceListId\": \"100000\",\n      \"type\": \"WEB_SHIP\",\n      \"subType\": \"Border-free\",\n      \"extra\": {\n        \"productFamily\": \"Laptop computers\"\n      },\n      \"fulfillment\": {\n        \"type\": \"WEB_SHIP\",\n        \"networkCode\": \"ShipToCNC\",\n        \"channelId\": \"12\"\n      },\n      \"group\": [\n        \"61d38e117162b7dba69c3d6d\"\n      ]\n    }\n  ],\n  \"cartId\": \"d7e78a21-bee3-4448-bf1c-d5b5461dbda2\",\n  \"name\": \"cart_it\",\n  \"description\": \"cart for the IT department\",\n  \"networkCode\": \"ShipToHome\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-site-context", "<x-site-context>")
    req.Header.Add("Authorization", "<authorization>")
    req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://prod.cart.fabric.inc/v2/carts/items")
  .header("x-site-context", "<x-site-context>")
  .header("Authorization", "<authorization>")
  .header("Content-Type", "application/json")
  .body("{\n  \"items\": [\n    {\n      \"itemId\": \"1000000001\",\n      \"quantity\": 1,\n      \"price\": {\n        \"currency\": \"USD\",\n        \"amount\": 100,\n        \"discount\": {\n          \"price\": 80,\n          \"promosApplied\": [\n            {\n              \"promoId\": \"fza065tdr787\",\n              \"promoCode\": \"coupon123\",\n              \"value\": \"20\",\n              \"unit\": \"%OFF\"\n            }\n          ],\n          \"discounts\": [\n            {\n              \"promoId\": \"fza065tdr787\",\n              \"promoCode\": \"coupon123\",\n              \"promoTitle\": \"New Year discount\",\n              \"quantity\": 1,\n              \"amount\": 20,\n              \"value\": 20,\n              \"groupId\": \"new-items\",\n              \"promotionType\": \"PROMOTION\",\n              \"priority\": 1,\n              \"stackable\": false,\n              \"sku\": \"16B2GS8LD5FDS\",\n              \"itemId\": \"1000000001\",\n              \"itemKey\": \"Key1234\",\n              \"message\": \"New Year Promotion\",\n              \"unit\": \"%OFF\",\n              \"proratedQuantity\": 1,\n              \"proratedAmount\": 3.33\n            }\n          ],\n          \"discountAmount\": 20\n        },\n        \"sale\": 80\n      },\n      \"sku\": \"16B2GS8LD5FDS\",\n      \"priceListId\": \"100000\",\n      \"type\": \"WEB_SHIP\",\n      \"subType\": \"Border-free\",\n      \"extra\": {\n        \"productFamily\": \"Laptop computers\"\n      },\n      \"fulfillment\": {\n        \"type\": \"WEB_SHIP\",\n        \"networkCode\": \"ShipToCNC\",\n        \"channelId\": \"12\"\n      },\n      \"group\": [\n        \"61d38e117162b7dba69c3d6d\"\n      ]\n    }\n  ],\n  \"cartId\": \"d7e78a21-bee3-4448-bf1c-d5b5461dbda2\",\n  \"name\": \"cart_it\",\n  \"description\": \"cart for the IT department\",\n  \"networkCode\": \"ShipToHome\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://prod.cart.fabric.inc/v2/carts/items")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"items\": [\n    {\n      \"itemId\": \"1000000001\",\n      \"quantity\": 1,\n      \"price\": {\n        \"currency\": \"USD\",\n        \"amount\": 100,\n        \"discount\": {\n          \"price\": 80,\n          \"promosApplied\": [\n            {\n              \"promoId\": \"fza065tdr787\",\n              \"promoCode\": \"coupon123\",\n              \"value\": \"20\",\n              \"unit\": \"%OFF\"\n            }\n          ],\n          \"discounts\": [\n            {\n              \"promoId\": \"fza065tdr787\",\n              \"promoCode\": \"coupon123\",\n              \"promoTitle\": \"New Year discount\",\n              \"quantity\": 1,\n              \"amount\": 20,\n              \"value\": 20,\n              \"groupId\": \"new-items\",\n              \"promotionType\": \"PROMOTION\",\n              \"priority\": 1,\n              \"stackable\": false,\n              \"sku\": \"16B2GS8LD5FDS\",\n              \"itemId\": \"1000000001\",\n              \"itemKey\": \"Key1234\",\n              \"message\": \"New Year Promotion\",\n              \"unit\": \"%OFF\",\n              \"proratedQuantity\": 1,\n              \"proratedAmount\": 3.33\n            }\n          ],\n          \"discountAmount\": 20\n        },\n        \"sale\": 80\n      },\n      \"sku\": \"16B2GS8LD5FDS\",\n      \"priceListId\": \"100000\",\n      \"type\": \"WEB_SHIP\",\n      \"subType\": \"Border-free\",\n      \"extra\": {\n        \"productFamily\": \"Laptop computers\"\n      },\n      \"fulfillment\": {\n        \"type\": \"WEB_SHIP\",\n        \"networkCode\": \"ShipToCNC\",\n        \"channelId\": \"12\"\n      },\n      \"group\": [\n        \"61d38e117162b7dba69c3d6d\"\n      ]\n    }\n  ],\n  \"cartId\": \"d7e78a21-bee3-4448-bf1c-d5b5461dbda2\",\n  \"name\": \"cart_it\",\n  \"description\": \"cart for the IT department\",\n  \"networkCode\": \"ShipToHome\"\n}"

response = http.request(request)
puts response.read_body

200

400

404

500

{
  "items": [\
    {\
      "sku": "16B2GS8LD5FDS",\
      "items": [\
        {\
          "sku": "13B9CL6WT2SLW",\
          "quantity": 15,\
          "items": [\
            "<unknown>"\
          ],\
          "cartItemId": "12gved0f-7645-40cb-y7b0-167f8bggdb3z",\
          "itemId": "1730902008",\
          "title": "Light Cover",\
          "attributes": [\
            {\
              "attributeId": "60c2a358eb2ec30008ae70a1",\
              "name": "gift wrapping (small)",\
              "type": "GIFT",\
              "price": 10,\
              "description": "Gift wrapping for a small package",\
              "mapping": "ITEM",\
              "value": "true",\
              "level": "order",\
              "items": [\
                "1000000001"\
              ]\
            }\
          ],\
          "createdAt": "2022-02-18T15:12:40.974580",\
          "updatedAt": "2022-02-18T15:12:40.974580",\
          "type": "WEB_SHIP",\
          "subType": "Border-free",\
          "priceListId": "108674",\
          "lineItemId": 1,\
          "isActive": true,\
          "unitPrice": {\
            "currency": "USD",\
            "amount": 100,\
            "discount": {\
              "price": 80,\
              "promosApplied": [\
                {\
                  "promoId": "fza065tdr787",\
                  "promoCode": "coupon123",\
                  "value": "20",\
                  "unit": "%OFF"\
                }\
              ],\
              "discounts": [\
                {\
                  "promoId": "fza065tdr787",\
                  "promoCode": "coupon123",\
                  "promoTitle": "New Year discount",\
                  "quantity": 1,\
                  "amount": 20,\
                  "value": 20,\
                  "groupId": "new-items",\
                  "promotionType": "PROMOTION",\
                  "priority": 1,\
                  "stackable": false,\
                  "sku": "16B2GS8LD5FDS",\
                  "itemId": "1000000001",\
                  "itemKey": "Key1234",\
                  "message": "New Year Promotion",\
                  "unit": "%OFF",\
                  "proratedQuantity": 1,\
                  "proratedAmount": 3.33\
                }\
              ],\
              "discountAmount": 20\
            },\
            "sale": 80\
          },\
          "totalPrice": {\
            "currency": "USD",\
            "amount": 100,\
            "discount": {\
              "price": 80,\
              "promosApplied": [\
                {\
                  "promoId": "fza065tdr787",\
                  "promoCode": "coupon123",\
                  "value": "20",\
                  "unit": "%OFF"\
                }\
              ],\
              "discounts": [\
                {\
                  "promoId": "fza065tdr787",\
                  "promoCode": "coupon123",\
                  "promoTitle": "New Year discount",\
                  "quantity": 1,\
                  "amount": 20,\
                  "value": 20,\
                  "groupId": "new-items",\
                  "promotionType": "PROMOTION",\
                  "priority": 1,\
                  "stackable": false,\
                  "sku": "16B2GS8LD5FDS",\
                  "itemId": "1000000001",\
                  "itemKey": "Key1234",\
                  "message": "New Year Promotion",\
                  "unit": "%OFF",\
                  "proratedQuantity": 1,\
                  "proratedAmount": 3.33\
                }\
              ],\
              "discountAmount": 20\
            },\
            "sale": 80\
          },\
          "attributeTotalPrice": 10,\
          "group": [\
            "61d38e117162b7dba69c3d6d"\
          ],\
          "extra": {\
            "productFamily": "Laptop computers"\
          },\
          "channel": 12,\
          "isPickup": true,\
          "warehouseId": "XYZ-1234",\
          "shipToId": "fef78121-bee3-4448-bf1c-d5b5461dbda2",\
          "shipTo": {\
            "shipToId": "fef78121-bee3-4448-bf1c-d5b5461dbda2",\
            "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",\
            "createdAt": "2022-02-18T15:12:40.974580",\
            "updatedAt": "2022-02-18T15:12:40.974580",\
            "shipMethod": {\
              "cost": {\
                "amount": 10,\
                "currency": "USD",\
                "discount": 5\
              },\
              "shipMethodId": "1234",\
              "shipmentCarrier": "FedEx",\
              "shipmentMethod": "Next Day"\
            },\
            "address": {\
              "attention": "Billing manager",\
              "street1": "100 NE 100th St.",\
              "street2": "Suite 710",\
              "street3": "Seventh floor",\
              "street4": "Attention: Pat E. Kake",\
              "city": "Seattle",\
              "state": "Washington",\
              "country": "USA",\
              "zipCode": "98125",\
              "email": "test@mail.com",\
              "kind": "shipping",\
              "name": {\
                "first": "Pat",\
                "middle": "E",\
                "last": "Kake"\
              },\
              "phone": {\
                "number": "123-456-7899",\
                "kind": "MOBILE"\
              }\
            },\
            "shipToType": "SHIP_TO_ADDRESS",\
            "taxCode": "FR1000",\
            "isPickup": true,\
            "altPickupPerson": {\
              "name": {\
                "first": "Pat",\
                "middle": "E",\
                "last": "Kake"\
              },\
              "phone": {\
                "number": "123-456-7899",\
                "kind": "MOBILE"\
              },\
              "email": "test@mail.com"\
            },\
            "pickupPerson": {\
              "name": {\
                "first": "Pat",\
                "middle": "E",\
                "last": "Kake"\
              },\
              "phone": {\
                "number": "123-456-7899",\
                "kind": "MOBILE"\
              },\
              "email": "test@mail.com"\
            },\
            "warehouseId": "XYZ-1234",\
            "storeId": "ABC-123"\
          },\
          "fulfillment": {\
            "type": "WEB_SHIP",\
            "networkCode": "ShipToCNC",\
            "channelId": "12",\
            "inventoryType": "availablePreorder",\
            "inventory": {\
              "virtualCounters": {\
                "availableToPurchase": 10\
              },\
              "id": "62272e917b12209e68751d94",\
              "sku": "SKU00025",\
              "itemId": 4225678911,\
              "locationNum": 473746,\
              "channelId": 12,\
              "vendorId": "vendor123",\
              "leadTime": 1234,\
              "inventoryType": "Safety stock",\
              "infiniteInventory": true,\
              "counters": {\
                "on-hand": 10\
              },\
              "attributes": {\
                "buy online, pick up in-store (bopis)": true\
              },\
              "backOrderDate": "2022-08-08T00:00:00.000Z",\
              "preOrderDate": "2022-08-08T00:00:00.000Z",\
              "backOrderLimit": 100,\
              "preOrderLimit": 100,\
              "safetyStock": 10,\
              "lowStock": 10,\
              "segment": "Clothing",\
              "region": "US"\
            }\
          }\
        }\
      ],\
      "quantity": 1,\
      "isPickup": true,\
      "cartItemId": "88cded0f-1439-40eb-a7a0-167e8bffdb3b",\
      "itemId": "1000000001",\
      "title": "Varnet Garden Light Kit",\
      "attributeTotalPrice": 10,\
      "createdAt": "2022-02-18T15:12:40.974580",\
      "updatedAt": "2022-02-18T15:12:40.974580",\
      "priceListId": "100000",\
      "lineItemId": 1,\
      "isActive": true,\
      "unitPrice": {\
        "currency": "USD",\
        "amount": 100,\
        "discount": {\
          "price": 80,\
          "promosApplied": [\
            {\
              "promoId": "fza065tdr787",\
              "promoCode": "coupon123",\
              "value": "20",\
              "unit": "%OFF"\
            }\
          ],\
          "discounts": [\
            {\
              "promoId": "fza065tdr787",\
              "promoCode": "coupon123",\
              "promoTitle": "New Year discount",\
              "quantity": 1,\
              "amount": 20,\
              "value": 20,\
              "groupId": "new-items",\
              "promotionType": "PROMOTION",\
              "priority": 1,\
              "stackable": false,\
              "sku": "16B2GS8LD5FDS",\
              "itemId": "1000000001",\
              "itemKey": "Key1234",\
              "message": "New Year Promotion",\
              "unit": "%OFF",\
              "proratedQuantity": 1,\
              "proratedAmount": 3.33\
            }\
          ],\
          "discountAmount": 20\
        },\
        "sale": 80\
      },\
      "totalPrice": {\
        "currency": "USD",\
        "amount": 100,\
        "discount": {\
          "price": 80,\
          "promosApplied": [\
            {\
              "promoId": "fza065tdr787",\
              "promoCode": "coupon123",\
              "value": "20",\
              "unit": "%OFF"\
            }\
          ],\
          "discounts": [\
            {\
              "promoId": "fza065tdr787",\
              "promoCode": "coupon123",\
              "promoTitle": "New Year discount",\
              "quantity": 1,\
              "amount": 20,\
              "value": 20,\
              "groupId": "new-items",\
              "promotionType": "PROMOTION",\
              "priority": 1,\
              "stackable": false,\
              "sku": "16B2GS8LD5FDS",\
              "itemId": "1000000001",\
              "itemKey": "Key1234",\
              "message": "New Year Promotion",\
              "unit": "%OFF",\
              "proratedQuantity": 1,\
              "proratedAmount": 3.33\
            }\
          ],\
          "discountAmount": 20\
        },\
        "sale": 80\
      },\
      "attributes": [\
        {\
          "attributeId": "60c2a358eb2ec30008ae70a1",\
          "name": "gift wrapping (small)",\
          "type": "GIFT",\
          "price": 10,\
          "description": "Gift wrapping for a small package",\
          "mapping": "ITEM",\
          "value": "true",\
          "level": "order",\
          "items": [\
            "1000000001"\
          ]\
        }\
      ],\
      "priceAdjustments": [\
        {\
          "id": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",\
          "reason": "compensation for delay",\
          "amount": 20,\
          "attributes": {\
            "goldMember": [\
              false\
            ]\
          }\
        }\
      ],\
      "warehouseId": "XYZ-1234",\
      "shipTo": {\
        "shipToId": "fef78121-bee3-4448-bf1c-d5b5461dbda2",\
        "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",\
        "createdAt": "2022-02-18T15:12:40.974580",\
        "updatedAt": "2022-02-18T15:12:40.974580",\
        "shipMethod": {\
          "cost": {\
            "amount": 10,\
            "currency": "USD",\
            "discount": 5\
          },\
          "shipMethodId": "1234",\
          "shipmentCarrier": "FedEx",\
          "shipmentMethod": "Next Day"\
        },\
        "address": {\
          "attention": "Billing manager",\
          "street1": "100 NE 100th St.",\
          "street2": "Suite 710",\
          "street3": "Seventh floor",\
          "street4": "Attention: Pat E. Kake",\
          "city": "Seattle",\
          "state": "Washington",\
          "country": "USA",\
          "zipCode": "98125",\
          "email": "test@mail.com",\
          "kind": "shipping",\
          "name": {\
            "first": "Pat",\
            "middle": "E",\
            "last": "Kake"\
          },\
          "phone": {\
            "number": "123-456-7899",\
            "kind": "MOBILE"\
          }\
        },\
        "shipToType": "SHIP_TO_ADDRESS",\
        "taxCode": "FR1000",\
        "isPickup": true,\
        "altPickupPerson": {\
          "name": {\
            "first": "Pat",\
            "middle": "E",\
            "last": "Kake"\
          },\
          "phone": {\
            "number": "123-456-7899",\
            "kind": "MOBILE"\
          },\
          "email": "test@mail.com"\
        },\
        "pickupPerson": {\
          "name": {\
            "first": "Pat",\
            "middle": "E",\
            "last": "Kake"\
          },\
          "phone": {\
            "number": "123-456-7899",\
            "kind": "MOBILE"\
          },\
          "email": "test@mail.com"\
        },\
        "warehouseId": "XYZ-1234",\
        "storeId": "ABC-123"\
      },\
      "channel": 12,\
      "group": [\
        "61d38e117162b7dba69c3d6d"\
      ],\
      "fees": [\
        {\
          "feeId": "73bc09d0-874a-4c3d-84d0-df1670d03578",\
          "name": "gift",\
          "type": "gift_wrap",\
          "amount": 10.5,\
          "attributes": "{'from': 'sam', 'to': 'david' }"\
        }\
      ]\
    }\
  ],
  "currency": "USD",
  "metadata": {
    "approver": "620d8896058edb0009385311"
  },
  "allPromosApplied": [\
    {\
      "promoId": "fza065tdr787",\
      "promoCode": "coupon123",\
      "value": "20",\
      "unit": "%OFF"\
    }\
  ],
  "sharedUserIds": [\
    "[\"*\"] or [userId1,userId2]"\
  ],
  "error": {
    "price": [\
      {\
        "price": {\
          "base": 20,\
          "sale": 10,\
          "cost": 20,\
          "currency": "USD",\
          "finalPrice": 10,\
          "totalPrice": 20,\
          "kind": "Promotion",\
          "discount": 5.5\
        },\
        "channel": 12,\
        "kind": "PROMOTION",\
        "lineItemId": 1,\
        "discounts": [\
          {\
            "promoId": "fza065tdr787",\
            "promoCode": "coupon123",\
            "promoTitle": "New Year discount",\
            "quantity": 1,\
            "amount": 20,\
            "value": 20,\
            "groupId": "new-items",\
            "promotionType": "PROMOTION",\
            "priority": 1,\
            "stackable": false,\
            "sku": "16B2GS8LD5FDS",\
            "itemId": "1000000001",\
            "itemKey": "Key1234",\
            "message": "New Year Promotion",\
            "unit": "%OFF",\
            "proratedQuantity": 1,\
            "proratedAmount": 3.33\
          }\
        ]\
      }\
    ],
    "promo": [\
      {\
        "detail": "Item is out of stock",\
        "itemId": "1000000001",\
        "sku": "16B2GS8LD5FDS",\
        "lineItemId": 1\
      }\
    ],
    "inventory": [\
      {\
        "detail": "Item is out of stock",\
        "itemId": "1000000001",\
        "sku": "16B2GS8LD5FDS",\
        "lineItemId": 1\
      }\
    ]
  },
  "cartId": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
  "createdAt": "2022-02-11T14:09:40.836703",
  "updatedAt": "2022-02-22T22:36:40.194293",
  "totalItems": 3,
  "totalUniqueItems": 2,
  "cartState": "PENDING",
  "tenantId": "5f689caa4216e7000750d1ef",
  "accountId": "5f689caa4216e7000750d1ef",
  "userId": "61b8e921d0cf2e000882b09f",
  "configuration": {
    "allowAnonymousUser": true,
    "orderNumberSource": "CART_ID",
    "softReserve": true,
    "addItemBySkuEnabled": true
  },
  "customer": {
    "id": "d7e78a21-bee3-4448-bf1c-d5b5461dbda2",
    "type": "EMPLOYEE",
    "attributes": {
      "goldMember": [\
        false\
      ]
    },
    "segments": {
      "age": 23,
      "gender": "female"
    }
  },
  "totalAmount": 95,
  "subTotal": 120,
  "totalDiscount": 25,
  "totalFees": 25,
  "attributes": [\
    {\
      "attributeId": "60c2a358eb2ec30008ae70a1",\
      "name": "gift wrapping (small)",\
      "type": "GIFT",\
      "price": 10,\
      "description": "Gift wrapping for a small package",\
      "mapping": "ITEM",\
      "value": "true",\
      "level": "order",\
      "items": [\
        "1000000001"\
      ]\
    }\
  ],
  "fees": [\
    {\
      "feeId": "73bc09d0-874a-4c3d-84d0-df1670d03578",\
      "name": "gift",\
      "type": "gift_wrap",\
      "amount": 10.5,\
      "attributes": "{'from': 'sam', 'to': 'david' }"\
    }\
  ],
  "suggestedProducts": [\
    {\
      "promotionId": "fef78121-bee3-4448-bf1c-d5b5461dbda2",\
      "promotionTitle": "Buy one get one free",\
      "itemId": 19,\
      "itemIds": [\
        19\
      ],\
      "eligiblePriceLists": [\
        1000000001\
      ],\
      "quantity": 1,\
      "promotionQuantity": 1,\
      "free": true,\
      "discountType": "AMOUNT_OFF",\
      "amount": 10\
    }\
  ]
}
{
  "code": "Bad Request",
  "message": "User ID or Cart ID does not exist"
}
{
  "code": "Cart or item not found",
  "message": "If the issue persists please contact support@fabric.inc."
}
{
  "code": "Internal Server Error",
  "message": "An internal error occurred. If the issue persists please contact support@fabric.inc."
}

POST

/

v2

/

carts

/

items

Try it

Add items to cart

cURL

import requests

url = "https://prod.cart.fabric.inc/v2/carts/items"

response = requests.post(url, json=payload, headers=headers)

print(response.text)

fetch('https://prod.cart.fabric.inc/v2/carts/items', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err));


") req.Header.Add("Authorization", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(string(body)) } ``` ``` require 'uri' require 'net/http' url = URI("https://prod.cart.fabric.inc/v2/carts/items") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true response = http.request(request) puts response.read_body ``` 200 400 404 500 ``` { "code": "Bad Request", "message": "User ID or Cart ID does not exist" } ``` ``` { "code": "Cart or item not found", "message": "If the issue persists please contact support@fabric.inc." } ``` ``` { "code": "Internal Server Error", "message": "An internal error occurred. If the issue persists please contact support@fabric.inc." } ``` #### Headers [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#parameter-x-site-context) x-site-context string required The `x-site-context` header is a JSON object that contains information about the source you wish to pull from. The mandatory `account` is the 24 character identifier found in Copilot. The `channel` (Sales channel ID), `stage` (environment name), and `date` attributes can be used to further narrow the scope of your data source. Example: `"{\"date\": \"2023-01-01T00:00:00.000Z\", \"channel\": 12, \"account\": \"1234abcd5678efgh9ijklmno\",\"stage\":\"production\"}"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#parameter-x-api-key) x-api-key string API Key for Gateway Example: `"zaCELgL.0imfnc8mVLWwsAawjYr4Rx-Af50DDqtlx"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#parameter-authorization) Authorization string required Authorization token for the user Example: `"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZjIyMTU4..."` #### Body application/json Request body for adding items to, or updating items in the cart Items (with details) to add to cart [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#body-items) items object\[\] required Items to add to cart Minimum array length: `1` Showchild attributes [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#body-cart-id-one-of-0) cartId string \| null Existing cart ID, or NULL for new cart Example: `"d7e78a21-bee3-4448-bf1c-d5b5461dbda2"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#body-name-one-of-0) name string \| null Name for the cart Example: `"cart_it"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#body-description-one-of-0) description string \| null Description for the cart Example: `"cart for the IT department"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#body-network-code-one-of-0) networkCode string \| null networkCode for the cart. Required when using inventoryV2 with CartV2 Example: `"ShipToHome"` #### Response 200 application/json OK Cart details [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-items) items object\[\] required Items in cart Showchild attributes [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-currency) currency string default:USD required Currency type Example: `"USD"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-metadata) metadata object required Metadata for this cart Example: ``` { "approver": "620d8896058edb0009385311" } ``` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-all-promos-applied) allPromosApplied object\[\] required All promotions or coupons for items in this cart Showchild attributes [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-shared-user-ids-one-of-0) sharedUserIds string\[\] \| null required UserIds of the users who share the cart [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-error) error object required Errors in this cart Showchild attributes [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-cart-id-one-of-0) cartId string \| null Cart ID Example: `"d7e78a21-bee3-4448-bf1c-d5b5461dbda2"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-created-at-one-of-0) createdAt string \| null Cart creation time Example: `"2022-02-11T14:09:40.836703"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-updated-at-one-of-0) updatedAt string \| null Last time cart was updated Example: `"2022-02-22T22:36:40.194293"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-total-items-one-of-0) totalItems integer \| null Number of items in the cart Example: `3` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-total-unique-items-one-of-0) totalUniqueItems integer \| null Number of unique items in the cart based on line item ID Example: `2` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-cart-state) cartState enum Cart status Available options: `ACTIVE`, `PENDING`, `PENDING_APPROVAL`, `APPROVED`, `SUBMITTED`, `DELETED`, `REJECTED` Example: `"PENDING"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-tenant-id-one-of-0) tenantId string \| null Merchant ID Example: `"5f689caa4216e7000750d1ef"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-account-id-one-of-0) accountId string \| null Customer account ID Example: `"5f689caa4216e7000750d1ef"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-user-id-one-of-0) userId string \| null User ID Example: `"61b8e921d0cf2e000882b09f"` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-configuration-one-of-0) configuration object \| null Cart configurations Showchild attributes [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-customer-one-of-0) customer object \| null Customer context Showchild attributes [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-total-amount-one-of-0) totalAmount number \| null Total price of cart items after discount including Shipping and Shipping Discount Example: `95` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-sub-total-one-of-0) subTotal number \| null Total price of cart items including Shipping without any discount Example: `120` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-total-discount-one-of-0) totalDiscount number \| null Total discount applied to cart Example: `25` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-total-fees-one-of-0) totalFees number \| null Total fees applied to cart Example: `25` [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-attributes-one-of-0) attributes object\[\] \| null Additional item options Showchild attributes [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-fees-one-of-0) fees object\[\] \| null Fees associated with a specific cart or an individual line item of a cart Showchild attributes [​](https://developer.fabric.inc/v2/api-reference/cart-api/cart/add-items-to-cart#response-suggested-products-one-of-0) suggestedProducts object\[\] \| null List of recommended products that are available for purchase along with the item added to the cart Showchild attributes Was this page helpful? YesNo [Delete items from specific cart](https://developer.fabric.inc/v2/api-reference/cart-api/cart/delete-items-from-specific-cart) [Apply a specific promotion to all items in a specific cart](https://developer.fabric.inc/v2/api-reference/cart-api/cart/apply-a-specific-promotion-to-all-items-in-a-specific-cart) Ctrl+I Assistant Responses are generated using AI and may contain mistakes.