# Create cart

POST `/cart`

This endpoint lets you to create a cart with a unique identifier for each of your users.&#x20;

The unique identifier for all cart requests is the user's Object Id. Here's a [generator and helper function](https://observablehq.com/@hugodf/mongodb-objectid-generator) you can use. You do not need to register a user beforehand. When you do a request to /cart, just pass in the new user's Object Id. You'll then use the same Object Id for subsequent requests to add more items to the cart, get a cart, and create an order.

If the product you're adding to the Request Body has a variant, then pass in the Variant Id. If the product doesn't have any variants, you pass in the Product Id as the Variant Id.&#x20;

**Headers**

| Header          | Type   | Description                                                                   |
| --------------- | ------ | ----------------------------------------------------------------------------- |
| `Authorization` | string | Bearer token.                                                                 |
| `customuserid`  | string | This is a unique Object Id identifier that you create for each of your users. |

**Request body**

```json
{
    "items": [
        {"variantId": 123, "product": 123, "quantity": 1}
    ]
}
```

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "status": "Cart Created",
}
```

{% endtab %}

{% tab title="400" %}

```json
{
 "status": "Server Error",
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.searchagora.com/purchase/create-cart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
