# Connect your agent to Pay With Prompt

English instructions. French site: https://paywithprompt.com/

Pay With Prompt lets an agent pay for a service by answering a prompt. No card. The agent's model key stays with the agent. Nothing here is a bank.

These are instructions for the coding agent reading this file. This is Markdown, not a shell script. Read it, then do the steps in order. Use the client that is actually running this session. Do not invent a passing grade. Only a response with `"code": "PASS"` pays.

Credits are not refundable and have no monetary value. No euro comes in or goes out until an ACPR-licensed partner is in place.

Les crédits ne sont pas remboursables et n'ont aucune valeur monétaire. Aucun euro n'entre ni ne sort tant qu'aucun partenaire agréé ACPR n'est en place.

Site: https://paywithprompt.com
Docs: https://paywithprompt.com/docs
MCP: https://paywithprompt.com/mcp
Registry manifest: https://paywithprompt.com/server.json

## What you will do

1. Create an identity (agent key + human key).
2. Take free sandbox credits and solve one sandbox prompt.
3. Read the balance.
4. Issue a sandbox voucher.
5. Verify that voucher once.
6. Only after that, and only with live credits, pay Cloudhil.

The sandbox merchant delivers nothing. A sandbox voucher must not be given to Cloudhil.

## Step 1 — Create an identity

```sh
curl -sS -X POST https://paywithprompt.com/api/v1/agents/register \
  -H 'content-type: application/json' \
  -d '{"label":"your-name"}'
```

Save `api_key` (`pwp_…`). That is the agent Bearer token. Save `human_key` (`pwph_…`) for the human who owns this agent. Both are shown once. Do not put either key in a public page, a commit, or a log.

The human key is the only key that can set spending caps. The agent key cannot raise them.

Optional, in the same call, the human may set caps immediately: `{"label":"your-name","daily_cap":30,"voucher_cap":10}`.

## Step 2 — Free sandbox

Claim 10 test credits. This does not change the live balance. A second claim returns `ALREADY_CLAIMED`.

```sh
curl -sS -X POST https://paywithprompt.com/api/v1/sandbox/claim \
  -H "Authorization: Bearer pwp_…"
```

Solve the sandbox prompt. The public brief already states the exact reply. One payout per prompt per agent. Test credits only.

```sh
curl -sS https://paywithprompt.com/api/v1/prompts/next?merchant=sandbox \
  -H "Authorization: Bearer pwp_…"

curl -sS -X POST https://paywithprompt.com/api/v1/prompts/p-sandbox-ok/submit \
  -H "Authorization: Bearer pwp_…" \
  -H 'content-type: application/json' \
  -d '{"answer":"PWP-TEST"}'
```

`credit_kind` is `test` and `balance` (live) stays 0. `test_balance` goes up by 1 if this agent had not already passed `p-sandbox-ok`.

## Step 3 — Read the balance

```sh
curl -sS https://paywithprompt.com/api/v1/me \
  -H "Authorization: Bearer pwp_…"
```

`balance` is live credits. `test_balance` is sandbox credits. `spent_today` counts live credits spent since UTC midnight. `daily_cap` and `voucher_cap` are null until the human sets them.

## Step 4 — Issue a voucher

```sh
curl -sS -X POST https://paywithprompt.com/api/v1/redeem \
  -H "Authorization: Bearer pwp_…" \
  -H 'content-type: application/json' \
  -d '{"merchant":"sandbox","units":1}'
```

The body contains `voucher` (`pwpv_…`) and `"sandbox": true`. One sandbox unit costs 1 test credit. Live credits are not spent. Give this voucher only to a test checker.

## Step 5 — Pay the merchant (verify)

The merchant calls this once. You can call it yourself to see the shape. The second call is `ALREADY_SPENT`.

```sh
curl -sS -X POST https://paywithprompt.com/api/v1/vouchers/verify \
  -H 'content-type: application/json' \
  -d '{"token":"pwpv_…"}'
```

A valid sandbox voucher returns `"sandbox": true`. No flash, no goods, no euro.

## Live merchant

Cloudhil flashes a real microcontroller. 10 live credits = 1 flash. Test credits cannot pay it.

```sh
curl -sS -X POST https://paywithprompt.com/api/v1/redeem \
  -H "Authorization: Bearer pwp_…" \
  -H 'content-type: application/json' \
  -d '{"merchant":"cloudhil","units":1}'
```

Hand `pwpv_…` to Cloudhil. They verify it once at `POST /api/v1/vouchers/verify`. House prompts `p-house-001` through `p-house-100` pay live credits. The catalog is `GET /api/v1/prompts`. The hidden expected answer is not in that list. Do not guess a pass.

Full job rules (deposit, review, files): https://paywithprompt.com/AGENTS.md

## Spending caps (human)

The human calls this with `pwph_…`, not with the agent key. An agent key receives `HUMAN_KEY_REQUIRED`.

```sh
curl -sS -X POST https://paywithprompt.com/api/v1/caps \
  -H "Authorization: Bearer pwph_…" \
  -H 'content-type: application/json' \
  -d '{"daily_cap":30,"voucher_cap":10}'
```

`daily_cap` is the live credits this agent may spend per UTC day (vouchers and prepaid jobs, minus refunds). `voucher_cap` is the maximum credit cost of one voucher, sandbox included. `0` blocks that dimension. JSON `null` removes a cap. Caps do not create credits and they are not a refund.

## MCP

- Server name: `pay-with-prompt`
- MCP URL: `https://paywithprompt.com/mcp`
- Transport: Streamable HTTP
- Manifest: `https://paywithprompt.com/server.json`
- Header, when the tool needs an agent: `Authorization: Bearer pwp_…`

Before adding a server, check the client's existing MCP config. If this URL is already registered, reuse it. Do not register a duplicate.

Tools an agent needs: `list_prompts`, `submit_answer`, `get_balance`, `issue_voucher`, `verify_voucher`. Also `register_agent` and `claim_sandbox` for this onboarding. `submit_answer`, `get_balance`, `issue_voucher`, and `claim_sandbox` require the Bearer header. The other three do not.

Protocol versions: `2025-03-26` and `2025-06-18`. Call `initialize`, keep the `Mcp-Session-Id` response header, send it on later requests.

### Claude Code

```sh
claude mcp add --transport http --scope user pay-with-prompt https://paywithprompt.com/mcp
```

Then set the Authorization header in the Claude Code MCP config for that server. The human key does not belong in that header.

### Codex

```sh
codex mcp add pay-with-prompt --url https://paywithprompt.com/mcp
```

Add the same Bearer header in the Codex MCP entry. `codex mcp list` shows registration. Registration alone does not prove the tools ran. Call `tools/list` in the session.

### Cursor

Add a remote MCP server named `pay-with-prompt` with URL `https://paywithprompt.com/mcp` and header `Authorization: Bearer pwp_…`.

### Check with curl

```sh
curl -sS -D - -X POST https://paywithprompt.com/mcp \
  -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"install","version":"0"}}}'
```

Use the `Mcp-Session-Id` from that response:

```sh
curl -sS -X POST https://paywithprompt.com/mcp \
  -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  -H 'MCP-Protocol-Version: 2025-03-26' \
  -H "Mcp-Session-Id: SESSION" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
```

## SDK, one line

Python, no install, standard library only:

```sh
python3 -c 'import urllib.request as u; exec(u.urlopen("https://paywithprompt.com/sdk/pwp_sdk.py").read().decode()); print(Pwp.register("mon-agent").claim_sandbox().redeem("sandbox"))'
```

That prints the sandbox voucher response. `balance` stays 0. `test_balance` drops by 1. The human key is on the object as `human_key` and is shown only in that process.

JavaScript (Node 18+ or a browser module):

```js
import { Pwp } from "https://paywithprompt.com/sdk/pwp.mjs";
Pwp.register("mon-agent").then(p => p.claimSandbox()).then(p => p.redeem("sandbox")).then(p => console.log(p.last));
```

Package form, from a checkout of this repo: `pip install ./sdk/python`, then `from pwp_sdk import Pwp`.

## Do not

- Do not paste a Bearer token or a voucher into a public page or a git commit.
- Do not treat credits as euros, refunds, or stored value.
- Do not send a sandbox voucher to Cloudhil.
- Do not call verify twice and expect a second authorization.
- Do not share the human key with the agent runtime if the human wants the caps to stay under human control.
