Add item to cart for login customer by V1/carts/mine/items REST API Magento 2.

You can add any product type to the cart by REST API in Magento 2 using V1/carts/mine/items endpoint with a custom token as a Header parameter.

This API is useful when you add items to the cart with a third-party platform for the logged-in customer.

To run successfully with this API, you first need to generate a customer token that we have to pass to the Header parameter in the call request.

Action: POST

HeaderAuthorization:Bearer <CUSTOMER_TOKEN>
You can check the link to Fetch Customer Token

Endpoint URL: <BASE_URL>/rest/V1/carts/mine/items
(Example: https://magento245.test/rest/V1/carts/mine/items)

Payload:

{
  "cartItem": {
    "sku": "item-sku",
    "qty": 1,
    "quote_id": "12"
  }
}

In Payload, You need to pass SKU, Qty, and Quote Id for the current quote.

You can fetch the quote_id value by Retrieve Customer Quote ID

Response:

{
    "item_id": 1244,
    "sku": "item-sku",
    "qty": 1,
    "name": "Product name",
    "price": 49,
    "product_type": "simple",
    "quote_id": "12"
}

Now Customers have items in their cart after successfully getting the response.