aws/agent-toolkit-for-aws/agents-pay
Claude Code and agent skill by aws/agent-toolkit-for-aws
- community
Checking that the SKILL.md file is still in the repository.
Use when THIS agent needs to pay for x402-protected content at runtime: hitting a paywall mid-task, settling it via AgentCore Payments, and applying operator-defined spend limits. Covers payment setup, policy, session budgets, and troubleshooting. Triggers on: "my agent hit a 402 while calling an API", "a tool call returned 402 Payment Required", "my agent needs to pay for x402-protected content", "let the agent pay for content, capped at $5 per session", "set a spend limit for the agent", "ProcessPayment failed", or "why did my agent refuse to pay". Not for BUILDING payment capability for end users, including wallets and framework middleware; use agents-build and references/payments.md. For non-paid APIs via Gateway use agents-connect. For inbound auth use agents-harden. For project scaffolding use agents-get-started.
Install
npx vskill@latest install aws/agent-toolkit-for-aws/agents-paySKILL.md
The same SKILL.md was published earlier as aws/agent-toolkit-for-aws/agents-pay.
pay
Let an agent pay for x402-protected content without letting the agent — or anything it reads — decide who gets paid, how much, or how often.
The one idea that matters
A payment decision is made in code, from a policy file, before any signing. Nothing the model says, and nothing inside fetched content, can authorize a payment or raise a limit.
An instruction to a model is not an access control: it is a request that a confused or prompt-injected model may decline. Controls must be enforced in code at the point where payment is authorised.
So in this skill every control is executable, and the model's entire payment surface can only spend an already-approved, bounded session — it can pay, check remaining budget, and obtain an opaque handle for a browser navigation, and nothing more.
When to use
This skill is for an agent that needs to pay for something itself, right now — the coding agent you are talking to, or an agent host like OpenClaw, hitting a paywall mid-task and settling it.
- The agent you are running hits an x402 paywall (HTTP
402) and needs the content - You need hard spend limits on what that agent can pay, per payment and per session
- A payment was refused and you need to know which rule rejected it
Not this skill: building a payment-capable agent
If you are writing an agent that will take payments or pay on behalf of its own end users — provisioning a wallet per customer, wiring a payments plugin or middleware into a product you are shipping — that is the `agents-build` skill and its references/payments.md. It covers the framework-native integrations and the per-end-user data plane.
The distinction is who spends:
agents-build → references/payments.md | agents-pay (this skill) | ||
|---|---|---|---|
| Question | "How do I give the agent I'm building the ability to pay?" | "This agent needs to pay for this thing now" | |
| When | Build time, in a product you ship | Run time, in the session you are in | |
| Wallet | One per end user of your product | One for this installation | |
| Who approves spend | Your product's own flow | The operator, at a terminal |
Both are valid; they answer different questions. If you are shipping a payments feature to customers, start with agents-build.
Do NOT use for:
- Non-paid external APIs or tools →
agents-connect - Inbound auth, who may invoke your agent →
agents-harden - Project creation or framework choice →
agents-get-started - Building payment capability into an agent you are shipping →
agents-build - Wallet custody, fiat payouts, or chargeback handling — out of scope
Input
$ARGUMENTS can be:
- A task:
setup,wire,debug,session,budget,coinbase,stripe - A description: "pay for this API", "402 error", "why did it refuse to pay"
- Empty — the skill determines the workflow from context
Read this before deploying
<!-- markdownlint-disable MD036 -->
The agent must not have the ManagementRole, and must not be able to run the admin CLI.
The whole security model rests on that separation. Follow the official IAM roles for AgentCore payments guide:
- A human uses the ManagementRole to create payment instruments and
sessions. That role carries an explicit Deny on ProcessPayment.
- The agent runs with the ProcessPaymentRole, which can execute a payment
against an already-approved session but cannot create one.
If the agent gets both — or gets shell access to scripts/agents_pay_admin.py while holding the ManagementRole — it can mint itself a fresh budget whenever it exhausts one, and the per-session cap stops bounding anything. AWS says it plainly: "Do not include PaymentSession write permissions ... and ProcessPayment in the same role, or the caller can bypass payment limits by creating new sessions with elevated budgets."
Two mitigations, and you want both:
- IAM is the real boundary. The runtime role must exclude
CreatePaymentSession and every Create* setup action.
- The admin CLI refuses to run headless as defence in depth —
new-session requires a human typing approve at a TTY, and there is no --yes flag. Do not treat this as a substitute for IAM: an agent running as your user in an interactive terminal could still drive it.
Deploy the admin CLI outside the agent's reach where you can — a separate host, or a workstation rather than the runtime image.
Architecture: two paths that never touch
Payments split into an admin path (a human, at a terminal) and a runtime path (the agent). They share resource identifiers and nothing else.
The agent cannot create a session, cannot provision infrastructure, cannot read the policy file's meaning, and never holds a provider credential. When a session budget is spent, spending stops until a human runs new-session again.
Tool inventory
Match by role — your runtime may prefix or rename these.
| Role | Function | Who calls it | Model-visible? | |
|---|---|---|---|---|
| Pay and fetch content | x402_fetch(url) | Agent | Yes — the main tool | |
| Check session usability | payment_session_status() | Agent | Yes — read-only, cannot mint budget | |
| Pay for a browser navigation | prepare_browser_payment(url) | Agent | Yes — returns an opaque handle, never the proof | |
| Redeem a handle at navigation | attach_browser_payment(handle, url) | Trusted glue, not the model | No | |
| Create a payment session | agents_pay_admin.py new-session | Human at a TTY | No | |
| Provision infrastructure | agentcore CLI + admin script | Human | No |
The split is the design. An agent can spend an approved, bounded session and ask whether it still has budget. It cannot create budget, provision resources, or handle a credential.
Browser / header-only payments
When a paid resource must render in a real browser, the proof has to reach the navigation — but it must not reach the model. Use the handle flow:
Handles are single-use, expire in 90 seconds, and are bound to one origin and path. A handle copied out of a transcript cannot be redeemed for a different resource, cannot be redeemed twice, and is not a credential.
Register prepare_browser_payment as the model's tool. Keep attach_browser_payment in your own glue code — it returns the real header.
Files
| File | Role | |
|---|---|---|
| `scripts/x402_policy.py` | The trusted decision point: policy loading, destination vetting, challenge validation, idempotency derivation | |
| `scripts/x402_fetch_cli.py` | How the agent invokes this skill — argv in, JSON out, exit 2 on refusal. No framework needed | |
| `scripts/x402_fetch.py` | Hardened fetch + settle, session status, and the browser handle flow. See the tool inventory above for what to expose to the model | |
| `scripts/agents_pay_admin.py` | Human-run admin CLI: init-config, show-config, create-instrument, new-session, preflight | |
| `scripts/test_x402_policy.py` | Security regression tests for the enforced controls | |
| `references/operator-guide.md` | Operator setup, IAM role separation, and recipient allowlisting | |
| `references/security-model.md` | Threat model, security controls, and their enforcement | |
| `references/setup.md` | Full provisioning walkthrough and IAM policies | |
| `references/troubleshooting.md` | Refusal and failure diagnosis |
All paths are inside this skill directory. That is deliberate: some installers copy a single skill folder and flatten it, so a reference to a sibling skill's files (../other-skill/...) can silently break. Everything needed is here.
Process
Step 0: Prerequisites
bedrock_agentcore.payments must be importable. Verify: python -c "from bedrock_agentcore.payments import PaymentManager".
Step 1: Provision payment resources — human runs this outside the LLM loop
The agent must NOT run this step; it involves provider credentials. Tell the user to open a separate terminal and complete the commands there. Do not ask them to paste credentials, command output, deployed state, or generated IDs back into chat. Wait only for the user to confirm that setup completed.
Run both agentcore add commands with no flags to keep the complete setup flow in the human's terminal. In particular, connector secret flags put values in shell history and the process list. See `references/setup.md` for obtaining Coinbase CDP / Stripe Privy credentials and for the split IAM policies.
agentcore/.env.local holds provider secrets in plaintext until deploy uploads them to AgentCore Identity. Ensure .env.local is gitignored. The agent must never read that file.
Step 2: Write the payment policy — human runs this
Until this file exists, every payment is refused. There is no permissive default.
Use repeatable --recipient flags for the normal allowlist mode. To deliberately let publishers choose the beneficiary, use --allow-any-recipient instead. The two modes are mutually exclusive.
Add --origin https://<host> (repeatable) only to pin the agent to a known merchant set; omitted, it may fetch any public HTTPS site.
Written to ~/.agents-pay/config.json, mode 0600, via atomic replace. It pins these policy keys (use hyphens for the corresponding CLI flags, e.g. --allow-any-recipient):
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/aws-agents/skills/agents-pay/SKILL.md
Popularity
- Repository stars
- 2,779
- Repository forks
- 341
- 7-day trend score
- 40
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/aws/agent-toolkit-for-aws/agents-pay)