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

# Buy usage balance

> How humans and agents add dollar-denominated Memex usage balance

Use this page when a Memex response indicates that the account needs more usage balance. Usage balance is represented in USD micros: `1,000,000` micros equals `$1.00`. Memex shows the balance as credits: one credit is `$0.01`, or `10,000` micros.

## Insufficient usage balance response

Memex search responses can include:

* `errorCode: "INSUFFICIENT_CREDITS"` (legacy-compatible error code)
* `meta.remainingUsageBalance`
* `upgradeOptions`

Example:

```json theme={null}
{
    "results": [],
    "extraEntities": [],
    "referencesByResultId": {},
    "referencedEntities": [],
    "referencedTags": [],
    "meta": {
        "offset": 0,
        "limit": 0,
        "returnedCount": 0,
        "rerankApplied": false,
        "usageMicrosCharged": 0,
        "remainingUsageBalance": {
            "usageBalancePaygMicros": 0,
            "usageBalanceSubscriptionMicros": 0,
            "total": 0
        }
    },
    "error": "Insufficient usage balance.",
    "errorCode": "INSUFFICIENT_CREDITS",
    "upgradeOptions": {
        "environment": "production",
        "isProduction": true,
        "defaultPlanId": "unlimited-subscription-yearly",
        "plans": []
    }
}
```

## Buy usage balance in the browser

Humans can add usage balance directly from the Memex website:

* Open `https://memex.garden/pricing`
* Pick a plan and complete checkout in the browser

## Buy usage balance from an agent

### Step 1: fetch the current pricing catalog

```bash theme={null}
curl -X POST "https://memex.garden/api/get-available-plans" \
  -H "Content-Type: application/json" \
  -d '{}'
```

Use `plans[].id` or `plans[].variantId` in the checkout request.

### Step 2: call checkout

Call `/checkout` with the user's Memex bearer token and a Stripe Shared Payment
Token.

```bash theme={null}
curl -X POST "https://memex.garden/api/checkout" \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: YOUR_MEMEX_API_KEY" \
  -H "Idempotency-Key: UNIQUE_AGENT_PAYMENT_KEY" \
  -d '{
    "planId": "credit-pack-1000",
    "payment": {
      "provider": "stripe",
      "sharedPaymentToken": "spt_..."
    }
  }'
```

Use `/checkout` for one-time plans such as the credit packs
(`credit-pack-1000`, `credit-pack-2000`, `credit-pack-5000`,
`credit-pack-10000`). For subscription plans, send the user to
`https://memex.garden/pricing`.

### Agent operating rule

When an agent sees `errorCode: "INSUFFICIENT_CREDITS"`:

1. Show the user the available upgrade options if the response already contains `upgradeOptions`.
2. If `upgradeOptions` is missing or stale, call `POST /get-available-plans`.
3. Ask the human which plan they want.
4. If the selected plan is a one-time plan, obtain a Stripe Shared Payment Token from the agent payment harness.
5. Call `POST /checkout` with the user's Memex bearer token and Shared Payment Token.
6. If the selected plan is a subscription plan, send the user to `https://memex.garden/pricing`.

## Which requests currently consume usage balance

* Search responses expose charges as `usageMicrosCharged` and balances as `remainingUsageBalance`.
* Search currently reports `usageMicrosCharged: 0`.
* Saving content costs one credit per new library item. PDFs cost one credit per five pages. Notes and highlights are free.
* Transcription costs 20 credits per hour, and 70 credits per hour for premium transcription.
* A save that the balance cannot cover fails with `errorCode: "SAVE_CONTENT_INSUFFICIENT_CREDITS"`.

## Related docs

* Auth for checkout requests: [Authentication](https://docs.memex.garden/general/authentication.md)
* Current plan and operation list: [Available endpoints](https://docs.memex.garden/general/available-endpoints.md)
* Response fields like `upgradeOptions`: [Response shape](https://docs.memex.garden/general/response-shape.md)


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