How an AI agent can get its own API key and buy credits, with a human still in control
Let an AI agent sign itself up for an API, check its balance and request more credits without a person filling in forms, while a human approves every step that grants access or spends money. How SendGuard's agent self-serve works.
Short answer
An AI agent can get its own SendGuard API key and top up its own credits. A person still makes every decision that grants access or spends money. The agent asks for a key and shows you a short code. You sign in, choose what the key is allowed to do and set a monthly spending limit, then click Approve. The agent then picks up the key itself. When its credits run out, the API tells it exactly what to do next: use the auto-recharge you turned on, send you a payment link, or ask you to top up.
So the agent handles the setup and asks you for the decisions. Nobody copies keys out of a dashboard, and the agent can't spend money you didn't allow.
This post covers what changed, how the approval works, and the limits worth knowing before you rely on it.
Why agents need their own way in
Until now, connecting an agent to SendGuard went the way it does with most APIs. A person signed up, opened the dashboard, created a key, and pasted it into the agent's environment. That works, but it has three problems we kept running into while building agent integrations ourselves:
- The agent gets more power than it needs. A dashboard key can do everything the account can, including billing. An email-drafting agent only needs to run checks.
- There's no spending limit per agent. If one agent loops or gets prompt-injected into retrying purchases, nothing stops it at the key level.
- Running out of credits is a dead end. The agent gets an error it can't act on, the workflow stops, and someone finds out hours later.
Agent self-serve fixes all three without removing the human.
How does an AI agent sign up for an API key?
The agent uses the same sign-in pattern your TV uses for a streaming app. The device shows a code, you approve it on your phone, and the device is signed in. You never type a password into the TV. For agents this is the OAuth device authorization flow, standardized as RFC 8628. Agents and frameworks that already support it don't need anything SendGuard-specific.
What the agent does
- It calls the signup endpoint (or the
start_signuptool over MCP). It can say which permissions it wants and suggest a monthly spending limit. - It gets back a short code such as
ABCD-EFGHand a link, and shows both to you. - It checks back every few seconds until you approve or decline. The request expires after 15 minutes.
The agent also doesn't have to know any of this in advance. If it calls SendGuard without a key, the error says to start agent signup and points to the endpoint.
What you see when you approve
The link opens an approval page in the SendGuard dashboard. You sign in with Google or GitHub as usual. The page shows what the agent asked for, and you can change it before approving:
- Permissions (scopes). Untick anything the agent shouldn't have.
- Monthly spend cap. Raise it, lower it, or set one if the agent didn't suggest one.
Click Approve and the agent receives its key once, the next time it checks. Click Deny and it's told the request was declined. Only a signed-in dashboard session can approve. An API key can't, so an agent can't approve its own request or another agent's.
What can an agent's key do?
Each key carries a set of scopes. The agent can't do anything outside them.
| Scope | What it allows | Who usually needs it | |-------|----------------|----------------------| | preflight:read | Check an email before sending (allow, delay, requires approval, block) | Every sending agent | | verify:create | Verify that an address exists and accepts mail | List-cleaning and enrichment agents | | billing:topup | Create a payment link for more credits | Agents that run unattended for long periods | | billing:autorecharge | Trigger the auto-recharge the owner has already set up | Agents you trust to keep themselves running |
A new agent key gets the first two by default. Billing scopes are only added if the agent asks and you approve. If the agent later tries something outside its scopes, it gets an error that names the missing scope and says a human has to grant it. It doesn't get a vague "forbidden".
Keys you create yourself in the dashboard still have every scope, so existing integrations keep working.
What happens when an AI agent runs out of credits?
This is where most API integrations fail quietly. With SendGuard, an agent that runs out of credits gets a response that says which of three things to do, based on what you've allowed:
| What the agent is told | What happens | Your involvement | |------------------------|--------------|------------------| | Use auto-recharge | The agent triggers the recharge you configured | None at the time; you set it up beforehand | | Create a checkout link | The agent creates a payment link and sends it to you | You open it and pay | | Ask a human to top up | The agent sends you to the billing page | You buy credits yourself |
The response also recommends the cheapest package, the $1 pilot with 100 checks. Small, frequent purchases are easier to approve than one large one, and they keep the possible loss small if something goes wrong.
Over MCP, the agent can call get_account to check its balance and plan before starting a large batch, and create_topup_link to request more. That way it doesn't run out halfway through a campaign.
How do you stop an AI agent from overspending?
Three controls work together, and none of them depends on the agent behaving.
A monthly spend cap on each key
You set the cap when you approve the agent. Every payment link and auto-recharge created with that key counts toward it. A purchase that would go over the cap is refused. The agent is told it hit its spending limit and needs a human, so it doesn't just keep retrying.
The cap is optional, and a key without one is uncapped. For any agent with a billing scope, set one. For a typical agent, $10 to $25 a month covers 1,000 to 2,500 pilot-priced checks and still contains the damage from a runaway loop.
Billing permissions are opt-in
An agent can only create payment links if you granted billing:topup, and only trigger a charge if you granted billing:autorecharge and turned auto-recharge on in your account. An agent that only runs checks can't spend anything.
Retries don't charge twice
Agents retry. A request times out, the framework tries again, and a naive API charges twice. SendGuard's top-up calls accept an idempotency key. A retry with the same key returns the original result and is marked as a replay instead of creating a second purchase. If the agent reuses the key for a different purchase, the request is rejected.
Most "let your agent pay" write-ups skip this part, and in practice it causes more surprise charges than prompt injection does.
Can an AI agent pay with crypto?
We're testing it. SendGuard supports x402, an open protocol that lets software pay for an API call directly in USDC, with no checkout page and no card. An agent with the billing:topup scope can buy a credit package and have it credited after the payment settles. The same spend cap applies.
It is currently testnet only (Base Sepolia) and is switched off on the production API. We'll turn it on for real payments once we're confident in the settlement and refund handling. Until then, use payment links or auto-recharge.
How do agents find out SendGuard exists?
An agent can't sign up for a service it doesn't know about, or one whose documentation it can't read. Alongside the signup flow, SendGuard now publishes three machine-readable files:
- openapi.json: the full API description that agent frameworks and code generators load.
- /.well-known/sendguard.json: a short manifest listing the MCP endpoint, the signup flow, scopes, billing rules and the recommended first purchase.
- llms.txt: plain-language instructions for language models, including the self-serve steps above.
An agent pointed at sendguard.ai can work out how to sign up, what it costs and how to stay within its limits without a person explaining it.
What this does not do
- It doesn't remove the human. Every new key and every payment that isn't pre-authorized needs a person. That's deliberate.
- The key is shown once. If the agent loses it, start a new signup and revoke the old key in the dashboard.
- Spend caps cover purchases, not checks. The cap limits how much the agent can buy. How fast it uses the credits it has is governed by rate limits.
- Crypto payments aren't live. See above.
- SendGuard still never sends email. It checks an email before your agent sends it and returns a decision. Sending stays with your own provider.
Try it
Point your agent at https://api.sendguard.ai/mcp, or have it call POST /v1/agent/signup, then approve the code it shows you. Grant preflight:read and set a $10 cap. The $1 pilot gives it 100 production checks. It's a one-time purchase, not a subscription. Endpoints and error codes are in the API docs.
To decide which of the agent's emails should wait for a person, see How to require human approval before an AI agent sends email.
FAQ
Can an AI agent create an account without a human? It can start the process and finish the technical steps, but a person has to sign in and approve the request. The agent never sees a password and can't approve itself.
Is it safe to give an AI agent billing access? It's as safe as the limits you put on it. Grant billing scopes only to agents that need them, always set a monthly spend cap, and prefer payment links, which a person pays, over auto-recharge until you trust the agent's behavior.
What happens if the agent's key leaks? The damage is limited to that key's scopes and spend cap. Revoke it in the dashboard and have the agent sign up again. Other agents' keys and your own are unaffected.
Does the agent need special code to use this? No. The signup follows RFC 8628, which many OAuth libraries already support, and MCP clients get it as two tools, start_signup and poll_signup.
Which scopes should a new agent get? Start with preflight:read only. Add verify:create if it cleans lists and billing:topup if it runs unattended for long enough to run out of credits.
Put outbound policy in front of every AI-generated email.
Use one API to score risk, enforce approval, and protect sender reputation before delivery.