I am trying like this,

Step 1: Post(empty) baseurl/rest/V1/guest-carts

get: guest customerid =02ccea0d67a4be667fa6ebf7905tia21

Step 2: I want add items to cart,so am using this api, POST /V1/guest-carts/{cartId}/items

Post: {
"cartItem": {
"itemId": 2,
"sku": "RJ0111",
"qty": 1,
"name": "Normal Kit",
"quoteId": "02ccea0d67a4be667fa6ebf7905tia21",



it gives response as 400 Bad Request,how can i get this and please tell me process step by step.

and what is "quoteId" here,

3 Answers 3


Please follow the below steps as shown in the screenshots so that it will help you

enter image description here

enter image description here

enter image description here

enter image description here


1) Mask Key we can trace out from the table called 'quote_id_mask' enter image description here

2) quote_id (or) cart id as well you can check it in the same table

3) cart item info saved in the table called quote_item

  • This works as expected. a cart is created in the database, i am able to add items to this cart. but: it creates a new guest cart. and the cart is not linked to the current guest customer session. is there a rest api endpoint to use the existing guest customer session cart? Commented Jul 1, 2022 at 8:50

The API is very tricky here.

  1. You need to create a cart first: [POST] /V1/carts/

This will return an ID.

  1. Now add the item to your cart: [POST] /V1/guest-carts/{cartId}/items


    "cart_item": {
        "quote_id": "{{use_your_cart_id}}",
        "sku": "YOUR_PRODUCT_SKU",
        "qty": 1
  • 1
    Do you guys know of a way to get items thumbnails when requesting the cart?
    – Mackelito
    Commented Aug 19, 2016 at 9:48
  • So {cartId} and the value of "quote_id" should be the same value? What if they are not? Commented Mar 19, 2018 at 20:03
  • @awavi when i run the POST http:/test.com/rest/V1/carts/mine/items Response: The consumer isn't authorized to access %resources Commented Aug 13, 2019 at 6:58

For guest you need to follow these steps:

Step-1: Create empty guest-cart

POST http://yourhost.com/rest/V1/guest-carts

The response of above request will give you "cartKey"

[Note: remove double quotes from the response]. And store it in some area, it will be needed in Step-2.

Step-2: Get cart details at any time after Step-1 above,

GET http://yourhost.com/rest/V1/guest-carts/{cartKey from step-1}

Step-3: Add product to the cart

POST http://yourhost.com/rest/V1/guest-carts/{cartKey from step-1}/items

Submit the JSON Payload

{ "cartItem" : { "sku" : productSKU, "qty" : 1, "quoteId" : quoteId } }


  1. productSKU = The product you want to add to cart

  2. qty=1 means you want to add one product to cart

  3. quoteId=quoteId you received in step-2

how can i get this and please tell me process step by step. and what is "quoteId" here,

quoteId is the actual cart id in quote table. From the response of Step-2 you can find it in JSON response with key id.

Here are the list of magento 2 APIs listing with modules.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.