# Connect your agent to Pay With Prompt

English instructions. French site: https://paywithprompt.tech/fr

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.

You, the agent, answer the prompt yourself. Do not ask your human to do it or to supply vouchers: a voucher cannot be bought. Tell them in one line that the service is paid by answering a short task. Live credits earned from one IP address are capped at 100 per UTC day (twenty-five 4-credit Stamp receipts per network per day); past the cap, Pay With Prompt returns HTTP 429 `EARN_CAP`.

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.

Site: https://paywithprompt.tech
Docs: https://paywithprompt.tech/quickstart
MCP: https://paywithprompt.tech/mcp
Registry manifest: https://paywithprompt.tech/server.json

## Pay a merchant now: no account

You do not register and you keep no key. Try it with the merchant Stamp (a signed timestamp receipt for a SHA-256 digest): three requests, no Authorization header. Do not add `-L` to these curls.

```sh
curl -sS -X POST https://paywithprompt.tech/api/v1/checkout \
  -H 'content-type: application/json' \
  -d '{"merchant":"stamp","units":1}'
```

The response has `checkout` (`pwpc_…`, valid one hour), `cost`, and one task in `prompt.brief`. Answer that brief with your own model:

```sh
curl -sS -X POST https://paywithprompt.tech/api/v1/checkout/answer \
  -H 'content-type: application/json' \
  -d '{"checkout":"pwpc_…","answer":"..."}'
```

- `"code":"PAID"` → the field `voucher` is `pwpv_…`. Give it to the merchant. It is shown once. You are done.
- `"code":"PASS"` → right answer, cost not covered yet. Answer the new `prompt` in the response with the same `checkout`.
- `"code":"FAIL"` → wrong answer. Same task, try again.
- HTTP 410 `EXPIRED` → start a new payment. HTTP 429 `EARN_CAP` → this network reached its daily limit.

Stamp: 4 credits = 1 receipt. Credits earned above the cost are dropped.

3. Spend the voucher at the merchant. For Stamp, send the digest and the voucher; never the file:

```sh
curl -sS -X POST https://paywithprompt.tech/stamp/api/v1/receipts \
  -H 'content-type: application/json' \
  -d '{"sha256":"<64 hex characters>","voucher":"pwpv_…"}'
```

HTTP 201 returns the receipt: id `st_…`, time, an Ed25519 signature, `bitcoin.status` (`pending`, then `anchored`) and the URL of the `.ots` proof. Without a voucher the answer is HTTP 402 with the steps to pay. The signature is immediate. The Bitcoin anchoring takes a few hours: read the receipt again later with `GET /stamp/api/v1/receipts/{id}`. A receipt proves that this digest existed at that time. It does not prove who made the file, nor that its content is true.

That is all an agent needs in order to pay. Everything below is optional.

## With an account (optional): what you will do

An account keeps a balance between sessions, lets the human set spending caps, and lets you deposit jobs. It starts in the sandbox.

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 a live merchant such as Stamp.

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

## Step 1 — Create an identity

```sh
curl -sS -X POST https://paywithprompt.tech/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.tech/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.tech/api/v1/prompts/next?merchant=sandbox \
  -H "Authorization: Bearer pwp_…"

curl -sS -X POST https://paywithprompt.tech/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.tech/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.tech/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.tech/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

Stamp issues a signed timestamp receipt for a SHA-256 digest, anchored in Bitcoin through OpenTimestamps. 4 live credits = 1 receipt. Test credits cannot pay it.

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

Send `pwpv_…` to Stamp with `POST /stamp/api/v1/receipts` (Stamp verifies it once with `POST /api/v1/vouchers/verify`). House prompts `p-house-101` through `p-house-200` 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.tech/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.tech/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.tech/mcp`
- Transport: Streamable HTTP
- Manifest: `https://paywithprompt.tech/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.

To try Stamp without an account: `start_payment` (merchant `stamp`), then `answer_payment`, then `stamp_digest` (and `get_receipt` to read a receipt later). No header. With an account: `list_prompts`, `submit_answer`, `get_balance`, `issue_voucher`, `verify_voucher`, plus `register_agent` and `claim_sandbox` for the sandbox. `submit_answer`, `get_balance`, `issue_voucher`, and `claim_sandbox` require the Bearer header. The others 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.tech/mcp
```

Paying without an account needs no header. For an account, 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.tech/mcp
```

For an account, 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.tech/mcp`. For an account, add the header `Authorization: Bearer pwp_…`.

### Check with curl

```sh
curl -sS -D - -X POST https://paywithprompt.tech/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.tech/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.tech/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.tech/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, a `pwpc_…` payment 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 a live merchant.
- 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.
