# set_auto_reload

URL: https://codepanel.ai/docs/mcp-server/set_auto_reload

The CodePanel MCP tool that turns credits auto-reload on or off or changes its threshold, pack and monthly cap, and returns the settings before and after.

`set_auto_reload` turns credits auto-reload on or off, or changes its threshold, pack size or monthly cap, and returns the settings before and after. When it is on, a balance below the threshold makes CodePanel charge the saved card for a credit pack. Because it moves money, it needs the `budget:write` scope, which no other scope includes.

## When to call it

- **Only when your user asked for it.** A call can charge a card: turning it on while the balance is already below the threshold charges at once.
- **To change the pack or the cap:** the monthly cap counts credits bought, and a reload that would pass it is skipped whole, never split.
- **To turn it off:** `enabled: false` keeps your other settings.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `enabled` | boolean | no |  |
| `thresholdUsd` | number | no | Reload when the balance falls below this |
| `packUsd` | number | no | Credits each reload buys: one of get_auto_reload's packOptionsUsd |
| `monthlyCapUsd` | number | no | Most credits reloads may buy per month; at least packUsd |

It writes: the server marks it `readOnlyHint: false` and `destructiveHint: true` (it can change what is already there), so a client that asks before writes asks here.

Give at least one input. A value you leave out keeps its saved setting, or the default: threshold $5, pack $25, cap $100. `packUsd` must be one of `packOptionsUsd` from [`get_auto_reload`](/docs/mcp-server/get_auto_reload) (25, 50, 100 or 250 on the test backend). The call is refused when:

```text
CodePanel: The reload amount must be one of $25, $50, $100, $250.
CodePanel: The threshold must be a positive amount.
CodePanel: The monthly cap must be at least the reload amount.
CodePanel: Subscribe before turning on auto-reload.
CodePanel: A payment to CodePanel is under dispute. Auto-reload can be turned on again once the dispute closes.
CodePanel: Nothing to change: pass enabled, thresholdUsd, packUsd or monthlyCapUsd.
```

Turning it on also clears the reason it last turned itself off.

## What it returns

`before` and `after`, each in the shape of [`get_auto_reload`](/docs/mcp-server/get_auto_reload). Compare `status` in the two: `off` to `on` means it is armed. A charge that fails later turns it off again, and `get_auto_reload` then gives the `offReason`.

## Examples

These responses come from a test account on a local backend.

### Turn it on

```json title="Call"
{ "enabled": true, "thresholdUsd": 5, "packUsd": 25, "monthlyCapUsd": 100 }
```

```json title="Result"
{
  "after": {
    "capReachedAt": null,
    "chargeUsd": 25,
    "disputeOpen": false,
    "enabled": true,
    "feeFreeUsd": 250,
    "lastReloadAt": null,
    "message": null,
    "month": "2026-11",
    "monthlyCapUsd": 100,
    "offAt": null,
    "offReason": null,
    "packOptionsUsd": [
      25,
      50,
      100,
      250
    ],
    "packUsd": 25,
    "pendingSince": null,
    "reloadedUsd": 0,
    "retryAfter": null,
    "status": "on",
    "thresholdUsd": 5
  },
  "before": {
    "capReachedAt": null,
    "chargeUsd": 25,
    "disputeOpen": false,
    "enabled": false,
    "feeFreeUsd": 250,
    "lastReloadAt": null,
    "message": null,
    "month": "2026-11",
    "monthlyCapUsd": 100,
    "offAt": null,
    "offReason": null,
    "packOptionsUsd": [
      25,
      50,
      100,
      250
    ],
    "packUsd": 25,
    "pendingSince": null,
    "reloadedUsd": 0,
    "retryAfter": null,
    "status": "off",
    "thresholdUsd": 5
  }
}
```

### A pack size that is not offered

```json title="Call"
{ "enabled": true, "thresholdUsd": 5, "packUsd": 7 }
```

```text title="Result (isError)"
CodePanel: The reload amount must be one of $25, $50, $100, $250.
```

## The same step without MCP

| Surface | Form |
| --- | --- |
| CLI | `codepanel auto-reload on\|off\|set` with `--threshold`, `--pack` and `--cap` ([CLI](/docs/cli)) |
| HTTP API | [`POST /auto-reload`](/docs/api#post-auto-reload) |

The dashboard has the same switch under **Auto-reload** in **Settings → Billing**.

## What the server tells your agent

The description your agent reads when it lists the tools:

> Turn credits auto-reload on or off, or change it. When on, a balance below thresholdUsd charges the saved card for packUsd of credits plus the purchase fee, at most monthlyCapUsd of credits per calendar month (UTC); a reload that would pass the cap is skipped, not split. Needs a subscription to turn on. First enable defaults: threshold $5, pack $25, cap $100. Turning it on with the balance already below the threshold charges at once. Needs the budget:write scope. Returns the settings before and after, as get_auto_reload.

## Related

- [`get_auto_reload`](/docs/mcp-server/get_auto_reload): read it first, and after a refusal.
- [`set_credits_first`](/docs/mcp-server/set_credits_first): with credits first, reloads keep buying packs before your own keys take over.
- [Billing: auto-reload](/docs/billing#auto-reload): the card, the cap, retries and disputes.
- [MCP server](/docs/mcp-server): install, sign-in and every other tool.
