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

# Wallet

> Smart savings wallet balance and checkout discount quotes

Wallet endpoints require a bearer token and `x-partner-id`. Use the integration ID issued by Keystone.

```http theme={null}
Authorization: Bearer <access_token>
x-partner-id: <integration_id>
```

## Quote wallet discount

Use this endpoint before checkout to show the wallet discount that can apply to the current cart.

| Method | Endpoint        | Auth         |
| ------ | --------------- | ------------ |
| `POST` | `/wallet/quote` | Bearer token |

Request:

```bash theme={null}
curl -X POST https://dev-api.keystonecommerce.in/api/v1/wallet/quote \
  -H "Authorization: Bearer <access_token>" \
  -H "x-partner-id: <integration_id>" \
  -H "Content-Type: application/json" \
  -d '{"cartValue":750}'
```

Response:

```json theme={null}
{
  "statusCode": 200,
  "message": "Success",
  "data": {
    "enabled": true,
    "balance": "0.00",
    "cartValue": "750.00",
    "eligibleDiscount": "50.00",
    "redeemableAmount": "0.00",
    "nextEligibleCartValue": "1000.00",
    "earliestExpiry": null
  }
}
```

Fields:

| Field                   | Meaning                                         |
| ----------------------- | ----------------------------------------------- |
| `balance`               | Customer's usable wallet balance                |
| `eligibleDiscount`      | Discount unlocked by the cart value             |
| `redeemableAmount`      | Amount that can actually be redeemed now        |
| `nextEligibleCartValue` | Next cart threshold, or `null` if there is none |
| `earliestExpiry`        | Earliest expiring wallet credit, or `null`      |

## Get wallet

Use this endpoint to show the wallet screen. It returns the quote, recent transactions, and active discount rules.

| Method | Endpoint                     | Auth         |
| ------ | ---------------------------- | ------------ |
| `GET`  | `/wallet?cartValue={amount}` | Bearer token |

Request:

```bash theme={null}
curl "https://dev-api.keystonecommerce.in/api/v1/wallet?cartValue=750" \
  -H "Authorization: Bearer <access_token>" \
  -H "x-partner-id: <integration_id>"
```

Response:

```json theme={null}
{
  "statusCode": 200,
  "message": "Success",
  "data": {
    "enabled": true,
    "balance": "0.00",
    "cartValue": "750.00",
    "eligibleDiscount": "50.00",
    "redeemableAmount": "0.00",
    "nextEligibleCartValue": "1000.00",
    "earliestExpiry": null,
    "transactions": [],
    "discountRules": [
      {
        "cartValue": "250.00",
        "discountAmount": "25.00"
      },
      {
        "cartValue": "500.00",
        "discountAmount": "50.00"
      }
    ]
  }
}
```

To apply wallet during checkout, send `useWallet: true` in `POST /orders`.
