> ## 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.

# Redeem Cart by Token

> Redeem every item in a validated cart using a single 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 redeeming from. Send it together with `X-Fingerprint-Event-Id` to register the device against the cart owner and attach it to the redemption transactions. 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.

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

The single-use `cart_redemption_token` returned by [Validate Cart](https://docs.withbenji.com/api-reference/endpoint/users/validate-cart.md). It lasts 600 seconds (10 minutes), the same as the perk `redemption_token` from [Campaign Eligibility](https://docs.withbenji.com/api-reference/endpoint/campaigns/eligibility.md), and cannot be empty. 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).

### Response

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

The cart redemption token that was redeemed.

**status** `string` *required*

The overall result of the cart redemption:

**possible status values**

* **SUCCESS** : Every item in the cart was redeemed \\

* **PARTIAL\_SUCCESS** : At least one item was redeemed and at least one item failed \\

* **FAILED** : No item was redeemed \\

**results** `array` *required*

One result per cart item, in cart order.

**properties**

**item\_id** `string` *required*

UUID identifier of the cart item.

**offer\_id** `string` *required*

The identifier of the offer that was redeemed.

**partnership\_id** `integer`

The identifier of the partnership the offer belongs to.

**status** `string` *required*

The result for this item. Either `SUCCESS` or `FAILED`.

**reward\_transaction\_id** `string`

UUID of the reward transaction created for the item. `null` when the item failed.

**error\_code** `string`

A code identifying why the item failed. `null` when the item succeeded.

**error\_message** `string`

A human-readable description of why the item failed. `null` when the item succeeded.

```bash cURL theme={null}
curl --request POST \
  --url https://api-staging.withbenji.com/transactions/redeem_cart_by_token \
  --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 '{
    "cart_redemption_token": "8c2d7a14-5e0b-4b7f-a1d9-3e6f0c9b2a58"
  }'
```

```json 200 theme={null}
{
    "code": "ok",
    "data": {
        "cart_redemption_token": "8c2d7a14-5e0b-4b7f-a1d9-3e6f0c9b2a58",
        "status": "PARTIAL_SUCCESS",
        "results": [
            {
                "item_id": "0e8d1f7b-3a55-4c0a-8d3b-5f0c6a1e9d42",
                "offer_id": "sku-1",
                "partnership_id": 42,
                "status": "SUCCESS",
                "reward_transaction_id": "6a1f3d0c-92b4-4c5e-8f0d-1b7e4a9c2d35",
                "error_code": null,
                "error_message": null
            },
            {
                "item_id": "5d2b9c60-1f47-4a3e-b8c2-7e0a4d6f1b93",
                "offer_id": "sku-2",
                "partnership_id": 42,
                "status": "FAILED",
                "reward_transaction_id": null,
                "error_code": "external_transaction_error",
                "error_message": "Failed to claim product sku-2 for user 155"
            }
        ]
    }
}
```

```json 401 theme={null}
{
  "code": "unauthorized_error",
  "message": "Unauthorized."
}
```

```json 403 theme={null}
{
  "code": "forbidden_error",
  "message": "Access forbidden. Insufficient permissions."
}
```

```json 404 theme={null}
{
  "code": "cart_redemption_token_not_found_error",
  "message": "Cart redemption token 8c2d7a14-5e0b-4b7f-a1d9-3e6f0c9b2a58 does not exist."
}
```

```json 410 theme={null}
{
  "code": "cart_redemption_token_invalid_error",
  "message": "Cart redemption token is invalid, expired, or already consumed."
}
```

```json 422 theme={null}
{
  "code": "cart_redemption_token_payload_invalid_error",
  "message": "Cart token payload must include at least one cart item."
}
```

```json 502 theme={null}
{
  "code": "cart_redemption_token_service_error",
  "message": "Unable to retrieve cart redemption token payload from userservice."
}
```

> [!WARNING]
>
> Item-level failures do not change the HTTP status. A request returns `200` even when `status` is `FAILED`, so always check `status` and each item's `status` in the response. The cart redemption token lasts 600 seconds (10 minutes) and is consumed as soon as the request is accepted. It cannot be reused.

> [!TIP]
>
> The cart is marked as checked out when at least one item is redeemed. If every item fails, the cart stays active. Items in the cart that share a perk `redemption_token` are redeemed as separate units of the same offer. To get a new `cart_redemption_token`, call [Validate Cart](https://docs.withbenji.com/api-reference/endpoint/users/validate-cart.md) again.


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