swiftapplications

Agent approvals & safety

Let an AI agent issue Stripe refunds safely

A developer’s pattern for agent-issued Stripe refunds: no secret key for the agent, a read-only restricted key, refunds as approved proposals, caps and idempotency.

Updated 8 October 2026 3 min read

The short answer

Don’t give the agent a key that can refund. Give it read access to look up charges, and let it propose the refund: amount, charge and reason. A person approves the proposal after seeing it checked against the charge and what’s already refunded; only then does a trusted component send it, with an idempotency key so it can’t happen twice.

Split reading from refunding

  • The agent reads charges, customers and disputes, and drafts the refund.
  • The checker compares the amount with the charge and earlier refunds, and enforces a cap.
  • The person approves the specific refund.
  • The sender holds the key that can refund and calls Stripe once.

Make it happen exactly once

Send refunds with an Idempotency-Key derived from the proposal, so a retry after a timeout returns the original result instead of refunding again:

bash
curl https://api.stripe.com/v1/refunds \
  -u "$STRIPE_KEY:" \
  -H "Idempotency-Key: proposal-8f3a2c" \
  -d charge=ch_123 -d amount=4900

Sensible limits

  • A cap per refund (MoltenRock Connect caps any proposal at 1,000.00 in two-decimal currencies).
  • Proposals expire if nobody decides (72 hours in Connect).
  • Full refunds and refunds to a new destination are highlighted on the card.

The safe way to do this

The Human Queue for Stripe

Your agent proposes, you approve with Touch ID

In MoltenRock Connect, an agent can propose 34 kinds of Stripe change, from refunds to invoices. Nothing is sent until you approve the card.

See it working

Questions developers ask

Can Claude Code issue Stripe refunds?

It can if you give it a key that can refund. Safer: give it read access and let it propose refunds that you approve.

How do I stop an agent refunding twice?

Send each approved refund with an idempotency key tied to the proposal; Stripe returns the first result for retries.

Should an AI agent have my Stripe secret key?

No. Use a restricted key with read permissions for the agent, and keep any key that can write out of its reach.