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

# Validate Cart

> Re-check eligibility for every item in a user's cart and issue a cart redemption token

> [!NOTE]
>
> This endpoint requires both your **partner API key** in the `x-api-key` header and a Bearer token in the `Authorization` header. The Bearer token is the user access token obtained after a successful [Benji Connect SDK](https://docs.withbenji.com/connect/methods.md#onsuccess) `onSuccess` callback. See [Exchange Token](https://docs.withbenji.com/connect/exchange_token.md) and [API Authentication](https://docs.withbenji.com/api-reference/authentication.md). Partner API keys can be generated through the dashboard.

**x-api-key** `string` *required*

Your partner API key, generated through the dashboard. Required together with `Authorization`.

**Authorization** `string` *required*

A `Bearer` user access token obtained after the [Benji Connect SDK](https://docs.withbenji.com/connect/methods.md#onsuccess) `onSuccess` callback. Required together with `x-api-key`. See [Exchange Token](https://docs.withbenji.com/connect/exchange_token.md).

**X-Fingerprint-Visitor-Id** `string`

The Fingerprint visitor ID of the device the cart owner is using. Send it together with `X-Fingerprint-Event-Id` to register the device against the cart owner. Blank values are ignored.

**X-Fingerprint-Event-Id** `string`

The Fingerprint event ID of the request that identified the device. Send it together with `X-Fingerprint-Visitor-Id`. Blank values are ignored.

**user\_id** `integer` *required*

The Benji Platform identifier of the user who owns the cart.

**partner\_id** `integer` *required*

The Benji Platform identifier of the partner the cart belongs to. A user has one active cart per partner.

**coupon\_code** `string`

Optional coupon code to apply while refreshing cart eligibility. If you omit this field, Benji uses the coupon already stored on the cart.

**campaign\_flow\_ids** `array`

Optional list of campaign flow IDs the cart lines were priced against. When set, eligibility is restricted to these flows. Use this when more than one active flow could match the same offer.

### Response

**cart** `object` *required*

The user's active cart after eligibility, prices, and item-level `redemption_token` values have been refreshed. The object has the same shape as the `cart` returned by [Add Item to Cart](https://docs.withbenji.com/api-reference/endpoint/users/add-cart-item.md).

**cart\_redemption\_token** `string` *required*

A single-use token that authorizes redemption of every item currently in the cart. It lasts 600 seconds (10 minutes), the same as the perk `redemption_token` returned by [Campaign Eligibility](https://docs.withbenji.com/api-reference/endpoint/campaigns/eligibility.md). Pass this token to [Redeem Cart by Token](https://docs.withbenji.com/api-reference/endpoint/transactions/redeem-cart-by-token.md). It is not the perk `redemption_token` used by [Add Item to Cart](https://docs.withbenji.com/api-reference/endpoint/users/add-cart-item.md) or [Redeem by Token](https://docs.withbenji.com/api-reference/endpoint/transactions/redeem.md).

```bash cURL theme={null}
curl --request POST \
  --url https://api-staging.withbenji.com/users/155/partners/61/cart/validate \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <your-partner-api-key>' \
  --header 'Authorization: Bearer <user-access-token>' \
  --header 'X-Fingerprint-Visitor-Id: <fingerprint-visitor-id>' \
  --header 'X-Fingerprint-Event-Id: <fingerprint-event-id>' \
  --data '{}'
```

```json 200 theme={null}
{
    "code": "ok",
    "data": {
        "cart": {
            "id": "b1c0f3a8-6c1e-4d52-9f7e-2a4d7b9e5c10",
            "user_id": 155,
            "partner_id": 61,
            "status": 1,
            "coupon_code": null,
            "created_date": "2026-12-02T15:04:11.482913+00:00",
            "last_item_activity_at": "2026-12-02T15:04:11.601227+00:00",
            "items": [
                {
                    "id": "0e8d1f7b-3a55-4c0a-8d3b-5f0c6a1e9d42",
                    "partnership_id": 42,
                    "offer_id": "sku-1",
                    "merchant_id": 93,
                    "eligible_price_cents": 450,
                    "currency": "USD",
                    "redemption_token": "3f6c0a52-8d1e-4f0b-9a57-0b6f2f7a7c11",
                    "eligibility_campaign_id": 118,
                    "coupon_id": null,
                    "eligibility_checked_at": "2026-12-02T15:04:11.590118+00:00",
                    "is_gift": 0,
                    "is_giftable": 1,
                    "gift_recipient_name": "Test User",
                    "gift_recipient_email": "test@test.com",
                    "created_date": "2026-12-02T15:04:11.598402+00:00"
                }
            ]
        },
        "cart_redemption_token": "8c2d7a14-5e0b-4b7f-a1d9-3e6f0c9b2a58"
    }
}
```

```json 404 theme={null}
{
  "code": "cart_not_found_error",
  "message": "cart user_id=155, partner_id=61 does not exist."
}
```

```json 409 theme={null}
{
  "code": "out_of_stock",
  "message": "This cart item is out of stock.",
  "offer_id": "sku-1"
}
```

```json 422 theme={null}
{
  "code": "cart_gift_validation_error",
  "message": "This offer is not giftable."
}
```

```json 500 theme={null}
{
  "code": "cart_validation_eligibility_service_error",
  "message": "Failed to validate cart eligibility for partnership_id=42"
}
```

> [!WARNING]
>
> Validation fails the whole request if any cart item is ineligible, out of stock, over a purchase or gift limit, or is marked as a gift for an offer that is not giftable. No `cart_redemption_token` is issued in that case.

> [!TIP]
>
> Build the cart first with [Add Item to Cart](https://docs.withbenji.com/api-reference/endpoint/users/add-cart-item.md), using the perk `redemption_token` from [Campaign Eligibility](https://docs.withbenji.com/api-reference/endpoint/campaigns/eligibility.md). Then call this endpoint to issue a `cart_redemption_token`, and pass that token to [Redeem Cart by Token](https://docs.withbenji.com/api-reference/endpoint/transactions/redeem-cart-by-token.md). The cart token lasts 600 seconds (10 minutes).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.