> ## Documentation Index
> Fetch the complete documentation index at: https://docs-alpha.pepay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Merchant carts

> Create and manage merchant carts (server-to-server).

## Overview

Merchant carts are server-scoped carts used in merchant operations (for example: creating carts on behalf of customers).

## Authentication

Requires `x-commerce-api-key`.

## Request

### List merchant carts

```ts theme={null}
const cart = await pepay.commerce.merchantCart.get({ customer_id: 'cust_123' });
```

### Create a merchant cart

```ts theme={null}
const created = await pepay.commerce.merchantCart.create({ customer_id: 'cust_123' });
```

### Add an item

```ts theme={null}
await pepay.commerce.merchantCart.addItem({
  customer_id: 'cust_123',
  productId: 'B08N5WRWNW',
  retailer: 'amazon',
  title: 'Echo (4th Gen)',
  price: 99.99,
  quantity: 1
});
```

### Validate merchant cart

```ts theme={null}
await pepay.commerce.merchantCart.validate({ customer_id: 'cust_123' });
```

### Totals

```ts theme={null}
await pepay.commerce.merchantCart.totals({ customer_id: 'cust_123', zip_code: '94105' });
```

## Response

Example response (truncated):

```json theme={null}
{
  "success": true,
  "data": {
    "merchantId": 123,
    "customerId": "cust_123",
    "items": [
      { "productId": "B08N5WRWNW", "quantity": 1 }
    ]
  }
}
```

## Errors

* `401` missing/invalid commerce API key
* `400` invalid cart id or payload

## Examples

* Prefer merchant carts when you need server-side cart control and auditing.
  Next: [Products](/sdk/commerce/products)
