# OK to spend?

*Your agent needs to pay for something to keep going. It asks first, with the exact amount.*

**Type: [Decide](types/decide.md).** Your agent asks before it acts. Approve or decline with one tap. This is one good use of it; the same widget serves deploy or merge, spend money, send what your agent wrote, delete or archive and more. Switch the subject when something else matters more.

Template id `spend-ok` · Asks you · uses nothing on the phone · for: Any agent that can spend: API credits, tools, ads, purchases.

## Goal

Agents can keep working on paid things without ever spending behind the user's back.

## When to offer it

You're about to pay for something, or a paid service you rely on runs out.

## What the user gets

- Stops before any purchase, top-up or paid API
- Says what it costs and what happens if you say no
- Carries on when you approve

## What each size shows

- **Small**: metric: Top-up = $20.
- **Medium**: metric: Top-up = $20; text (body): "API credit is out. Tonight's run stops at 2:00."; buttons: Pay $20 (`pay`), Not now (`no`).
- **Large**: metric: Top-up = $20; text (body): "API credit is out. Tonight's run stops at 2:00."; buttons: Pay $20 (`pay`), Not now (`no`); list: This month (3 rows).
- **Lock Screen**: inline "OK to spend $20?".

## Make it theirs

**Look.** Send `look` instead of `theme` and `accent`; every combination is designed to read well:

- `style`: `glass` (default: see-through, adapts to dark mode), `soft` (a calm pale tint) or `bold` (a vivid gradient with dark buttons).
- `accent`: blue, indigo, purple, pink, red, orange, green, teal, graphite, or a hex.
- `font`: default, rounded, serif or mono.

This template's own accent is **green**. To restyle a widget you already saved, send only the look:

```json
{"slug": "spend-ok", "look": {"style": "bold", "accent": "green", "font": "rounded"}}
```

Preview a look without saving: `droplet_preview_widget` with the slug and `look`. When the user says "make it greener", "calmer" or "bolder", change the look; keep the content.

**Their choices.** Ask once (droplet_ask) or use what you know:

- Monthly limit
- Which sellers are fine

**Search words:** money, spend, purchase, pay, approve, credit, top up, budget, buy.


## Before you build

- You need: Any agent that can spend: API credits, tools, ads, purchases.
- Ask once: Always two steps for money: this button, then droplet_ask with risk high.

## Fill it with real data

Start from the template (`droplet_library` with `id: "spend-ok"`), keep the design, and replace each sample value:

| Block | Real value |
|---|---|
| 0 · metric | The exact amount. |
| 1 · text | What runs out, and what stops if the answer is no. |
| 2 · buttons | Pay names the amount. |
| 3 · list | What's been spent this month. |

Sources:
- The exact amount, the seller and what it's for.
- What stops if the answer is no.
- What you've spent so far, if you've kept track.

## The widget

Sample values; send it with `droplet_set_widget` on your widget's slug (or a new slug with `new_widget: true` if the user asked for a separate widget). Preview it and fix every warning first.

```json
{
  "slug": "spend-ok",
  "title": "OK to spend $20?",
  "symbol": "creditcard.fill",
  "accent": "#30D158",
  "blocks": [
    {"type": "metric", "label": "Top-up", "value": "$20"},
    {"type": "text", "text": "API credit is out. Tonight's run stops at 2:00.", "style": "body"},
    {"type": "buttons", "items": [{"id": "pay", "label": "Pay $20", "symbol": "creditcard.fill"}, {"id": "no", "label": "Not now", "symbol": "xmark"}]},
    {"type": "list", "title": "This month", "items": [{"title": "API credit", "detail": "$40"}, {"title": "Hosting", "detail": "$20"}, {"title": "Left of your $100 limit", "detail": "$40"}]}
  ],
  "sizes": {"medium": [0, 1, 2], "large": [0, 1, 2, 3]},
  "lock": {"inline": "OK to spend $20?", "circular": 0}
}
```

## Keep it fresh

When you reach the point of paying. Show the receipt after.

## Handle the taps

Each tap reaches you once on `droplet_get_events` (keep a waker running, SKILL.md Process C). Answer within seconds by updating the widget.

**Pay $20** (`pay`)

```json
{"widget": "spend-ok", "kind": "button", "target": "pay", "value": {"label": "Pay $20"}}
```

Ask droplet_ask with risk high naming the amount and seller. On yes, pay exactly that, then show the receipt.

**Not now** (`no`)

```json
{"widget": "spend-ok", "kind": "button", "target": "no", "value": {"label": "Not now"}}
```

Don't pay. Say what you'll do instead, and carry on without it.

## Ask first

Always two steps for money: this button, then droplet_ask with risk high.

For example:

```json
{"question": "Pay OpenAI $20 from the saved card?", "kind": "decision", "options": ["Pay $20", "Don't"], "risk": "high"}
```

## Phone actions

None.

## Edge cases

- Payment needs a card they haven't saved: turn this into Only you can do.
- The price changed: ask again with the new amount.

## Never

Never spend more than the amount shown, and never enter card details the user hasn't already saved.

## Done when

- [ ] Every sample value is replaced with real data (no "Dr. Lee" on a real widget).
- [ ] `droplet_preview_widget` shows no warnings at the sizes the user placed (`placed` in `droplet_whoami`).
- [ ] Every button has a handler and a waker is running.
- [ ] Refresh is set up as above.
- [ ] You told the user in one line what it does on its own and what it asks first.

## Same widget, other uses

- [Approvals](approvals.md): Your agent asks before it ships. You approve from the Home Screen.
- [Renewal coming](bill-guard.md): Something renews soon that you barely use. Your agent caught it in time.
- [Reply drafted](mention-reply.md): Someone asked you something in public. Your agent wrote the reply. You tap post.
