Skip to main content
POST
/
cart
Add item to cart
curl --request POST \
  --url https://store.salesive.com/api/v1/cart \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'x-shop-id: <api-key>' \
  --data '
{
  "productId": "<string>",
  "foodId": "<string>",
  "serviceId": "<string>",
  "variantId": "<string>",
  "quantity": 1,
  "selectedAddons": [
    {
      "addonId": "<string>",
      "quantity": 1
    }
  ]
}
'
{
  "status": 123,
  "success": true,
  "message": "<string>",
  "data": {
    "_id": "<string>",
    "items": [
      {
        "name": "<string>",
        "image": "<string>",
        "price": 123,
        "quantity": 2,
        "_id": "<string>",
        "product": {
          "_id": "<string>",
          "id": "<string>",
          "name": "<string>",
          "images": [
            "<string>"
          ],
          "price": 123,
          "promoPrice": 123,
          "sku": "<string>",
          "parentProductId": "<string>",
          "variantAttributes": {}
        },
        "food": {
          "_id": "<string>",
          "id": "<string>",
          "name": "<string>",
          "images": [
            "<string>"
          ],
          "price": 123,
          "promoPrice": 123
        },
        "foodId": "<string>",
        "variant": "<string>",
        "sku": "<string>",
        "variantAttributes": {},
        "selectedAddons": [
          {
            "addonId": "<string>",
            "name": "<string>",
            "price": 123,
            "quantity": 2,
            "description": "<string>"
          }
        ]
      }
    ],
    "totalPrice": 123,
    "user": "<string>",
    "shop": "<string>",
    "createdAt": "2023-11-07T05:31:56Z",
    "updatedAt": "2023-11-07T05:31:56Z"
  }
}

Request

POST /cart
Authorization: Bearer {{token}}
x-shop-id: {{shopId}}
Content-Type: application/json

{
  "productId": "692cd420b07303c9be5eafd7",
  "quantity": 2
}

Headers

HeaderTypeDescription
AuthorizationstringProvide the customer token as Bearer <jwt>.
x-shop-idstringIdentify the shop that owns the cart.
Content-TypestringAlways set to application/json.

Body parameters

FieldTypeRequiredDescription
productIdstringNoProduct identifier to add. Provide one of productId, foodId, or serviceId.
foodIdstringNoFood item identifier (restaurant stores).
serviceIdstringNoService identifier (business stores).
variantIdstringNoVariant identifier. Include it to add a specific product variant.
quantityintegerNoQuantity to add. Defaults to 1.
selectedAddonsarrayNoArray of add-on objects {addonId, quantity} for food or service items.
A storefront’s catalog type is determined by the shop type: product for ecommerce, food for restaurant, and service for business stores. Add the matching identifier (productId, foodId, or serviceId). Services behave like foods — they have no variants but can carry add-ons.

Food request example

POST /cart
Authorization: Bearer {{token}}
x-shop-id: {{shopId}}
Content-Type: application/json

{
  "foodId": "68e5bb463a1fc56a8ac150c0",
  "quantity": 1,
  "selectedAddons": [
    {
      "addonId": "68e5bb463a1fc56a8ac150d1",
      "quantity": 2
    }
  ]
}

Service request example

POST /cart
Authorization: Bearer {{token}}
x-shop-id: {{shopId}}
Content-Type: application/json

{
  "serviceId": "6a2f8a7ba6656ba8cddfc1f5",
  "quantity": 1,
  "selectedAddons": [
    {
      "addonId": "6a2f8a7ba6656ba8cddfc201",
      "quantity": 1
    }
  ]
}
A service cart item is returned with itemType: "service" and a populated service object (plus a serviceId convenience field), mirroring the food shape:
{
    "itemType": "service",
    "service": {
        "_id": "6a2f8a7ba6656ba8cddfc1f5",
        "name": "Home Cleaning"
    },
    "serviceId": "6a2f8a7ba6656ba8cddfc1f5",
    "name": "Home Cleaning",
    "image": "https://cdn.salesive.com/services/cleaning.webp",
    "price": 20000,
    "quantity": 1,
    "selectedAddons": []
}

Successful response

{
    "status": 200,
    "success": true,
    "message": "Item added to cart",
    "data": {
        "_id": "693606ada7a8f7dc8ae32d80",
        "items": [
            {
                "itemType": "food",
                "food": {
                    "_id": "68e5bb463a1fc56a8ac150c0",
                    "name": "Margherita Pizza"
                },
                "foodId": "68e5bb463a1fc56a8ac150c0",
                "name": "Margherita Pizza",
                "image": "https://cdn.salesive.com/foods/margherita.webp",
                "price": 7500,
                "quantity": 1,
                "selectedAddons": [
                    {
                        "addonId": "68e5bb463a1fc56a8ac150d1",
                        "name": "Extra Cheese",
                        "description": "A richer mozzarella finish baked on top.",
                        "price": 1500,
                        "quantity": 2
                    }
                ],
                "_id": "6937b6e9e455c711f1fc9064",
                "id": "6937b6e9e455c711f1fc9064"
            }
        ],
        "totalPrice": 10500,
        "id": "693606ada7a8f7dc8ae32d80"
    }
}

Error response

{
    "status": 404,
    "success": false,
    "message": "Product not found",
    "data": null
}

Authorizations

Authorization
string
header
required

JWT issued by the Salesive Store API for authenticated shoppers.

x-shop-id
string
header
required

Optional storefront identifier sent as a header to scope responses to a specific shop. Try It requests remember this value once provided.

Headers

x-shop-id
string

Optional identifier that scopes responses to a specific storefront when the referer cannot be inferred.

Body

application/json

Add a product/variant line item, a food line item, or a service line item, with optional add-ons. Use the identifier that matches the storefront catalog type: productId (ecommerce), foodId (restaurant), or serviceId (business).

productId
string
required

Identifier of the product to add to the cart (ecommerce stores).

foodId
string

Identifier of the food item to add to the cart (restaurant stores).

serviceId
string

Identifier of the service to add to the cart (business stores).

variantId
string

Optional identifier of the product variant to add.

quantity
integer
default:1

Quantity of the product, food, or service to add. Defaults to 1.

Required range: x >= 1
selectedAddons
object[]

Optional add-on selections for food or service items.

Response

Cart updated with the new item.

status
integer
required

HTTP status code returned by the API.

success
boolean
required

Indicates whether the request succeeded.

message
string
required

Human-readable response message.

data
object
required