## Documentation Index

Fetch the complete documentation index at: [/llms.txt](https://developer.fabric.inc/llms.txt)

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

This feature in Carts API allows the user to search the cart by the following parameters:

- Cart Status
- Order Number
- Customer Information
- Promotion Codes
- Created/Updated Date Range
- Channel ID

## Prerequisites

- A cart that needs to be searched is created with the required parameters using the [create a cart](https://developer.fabric.inc/v3/cart-and-checkout/api-reference/carts-v3/carts/carts) endpoint.

## Search Cart Initialization

The search endpoint returns a paginated response, displaying the first 10 search results by default. The `total` field in the response indicates the number of results found for the search query, capped at 10,000 results.
For queries that exceed this `limit`, use an `offset`. Querying many carts through this endpoint isn’t recommended, as it’s intended for basic use cases to retrieve a limited number of carts rather than for analytics purposes. The following code sample provides the structure of `limit`, `offset`, and `total` in the response when searching for a cart:

```json
{
    "query": {
        "limit": 20,
        "offset": 0,
        "total": 3
    },
    "data": [
        {
        ...
        }
    ]
}
```

## Examples

### Retrieving a cart with an order number

Use the [search for multiple carts](https://developer.fabric.inc/v3/cart-and-checkout/api-reference/carts-v3/carts/search) endpoint and include the order number in the request body as in the following example:

```bash
curl --location '{{modular_cart_domain}}/carts/search' \
--header 'x-fabric-tenant-id:  {tenantId}' \
--header 'Content-Type: application/json' \
--header 'Authorization: {authToken}' \
--data '{
    "offset": 0,
    "limit": 20,
    "filter": {
        "orderNumber": "O1232",
        "updatedAt": {
            "start": "2024-03-27T06:06:53.709Z",
            "end": "2024-06-29T06:06:53.709Z"
        }
    }
}'
```

### Retrieving a cart with the date range and the customerId

Use the [search for multiple carts](https://developer.fabric.inc/v3/cart-and-checkout/api-reference/carts-v3/carts/search) endpoint and include the date range and the `customerId` in the request body as in the following example:

```bash
curl --location '{{modular_cart_domain}}/carts/search' \
--header 'x-fabric-tenant-id:  {tenantId}' \
--header 'Content-Type: application/json' \
--header 'Authorization: {authToken}' \
--data '{
    "offset": 0,
    "limit": 20,
    "filter": {
    "customer": {
            "id": "testCustomerId",
            "sessionId": "testSessionId"
        },
        "createdAt": {
            "start": "2024-03-27T06:06:53.709Z",
            "end": "2024-06-29T06:06:53.709Z"
        }
    }
}'
```

### Retrieving a cart with the customerId and promotionTitles

Use the [search for multiple carts](https://developer.fabric.inc/v3/cart-and-checkout/api-reference/carts-v3/carts/search) endpoint and include `customerId` and promotionTitles in the request body as in the following example:

```bash
curl --location '{{modular_cart_domain}}/carts/search' \
--header 'x-fabric-tenant-id:  {tenantId}' \
--header 'Content-Type: application/json' \
--header 'Authorization: {authToken}' \
--data '{
    "offset": 0,
    "limit": 20,
    "filter": {
        "promotionTitles": [
            "FREE_SHIPPING"
        ],
        "customer": {
            "id": "testCustomerId",
            "sessionId": "testSessionId"
        }
    }
}'
```
