402 as a contract, not just an error
In LetsPing, a 402 response tells the agent exactly why it is blocked and where to go next. The body includes a machine readable billing block and a funding_url the agent can use to buy more usage.
HTTP/1.1 402 Payment Required
Content-Type: application/json
{
"error": "signed_calls_limit_per_month_exceeded",
"billing": {
"metric": "signed_calls",
"funding_url": "https://letsping.co/api/agents/billing/fund"
}
}Your agent can treat that as a branch point: back off, ask a human, or call the funding endpoint.
Funding without exposing Stripe
To add credits, the agent calls POST /api/agents/billing/fund with the metric and units it wants. LetsPing charges the organization's Stripe customer and only after a successful charge adds credits in its own ledger.
curl -X POST "https://letsping.co/api/agents/billing/fund" \
-H "Authorization: Bearer PROJECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "metric": "signed_calls", "units": 500 }'The agent never holds Stripe keys. It only sees the metric and how many units were added.
Why this matters for autonomous agents
This pattern lets you keep pricing and settlement on the human side while agents take on more responsibility. They can keep work flowing when they hit a limit, but every extra unit still flows through your Stripe account on your terms.
To implement this in your own stack, start with Agent Billing and 402s and the pricing page.