Questions · Published 2026-11-10 · Updated 2026-11-10 · AgentiSend
Add spending limits to Resend
Add spending limits to Resend by sending through a local proxy that counts each message and refuses the send past the cap.
Add spending limits to Resend by sending through a local proxy that counts each message and refuses the send past the cap. The program is third-party and is not affiliated with Resend.
What the proxy checks
The cap lives in a file named agent-email-guard.json in the directory the proxy starts in. The number is a count of messages. It is not a currency amount. There is no cap until that file sets one.
POST /emails is one message. POST /emails/batch is one check for each object in the array. A request that passes is forwarded as the bytes that arrived, so the subject, the text and the HTML are not rewritten. A request that does not pass is not forwarded, and a batch that fails any one check is not forwarded either.
The refusal is an error object the SDK already parses. The name is the reason, and the message is the sentence that names the cap. The API key is copied to the upstream and is not written to the log. The message body is not written to the log either. The proxy counts sends. It does not scan a blocklist.
One environment variable
The Resend SDK already reads a base URL. Point it at the proxy:
RESEND_BASE_URL=http://localhost:8787The proxy listens on your own machine, on that port. Calls that are not sends, such as reading a message that was already accepted, are forwarded and are not counted.
The same SDK, pointed at AgentiSend
Leave the SDK import as it is and point the proxy's upstream at https://api.agentisend.com, or point the base URL there directly and drop the proxy. POST /emails stays the call. The cap the API enforces is set with PATCH /limits/keys/{id}, and GET /usage shows what the key has left. A send past that cap is refused with agent_budget_exceeded before it is accepted.
curl -sS -X POST https://api.agentisend.com/emails \
-H "Authorization: Bearer $AGENTISEND_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"from":"billing@yourdomain.com","to":"delivered@simulator.agentisend.com","subject":"Your receipt","text":"Thanks — the details are attached."}'201
{
"id": "9c8f8f0e-3d1a-4d3f-9a1e-2b7c1a0f5e42",
"simulated": true,
"warnings": []
}The page that lines the cap up against the calls is Email API with spending limits for AI agents. The import swap, for a codebase that should stop depending on the other SDK, is Resend-compatible email API.
FAQ
Is the proxy affiliated with Resend?
No. The proxy is a third-party program and is not affiliated with Resend.
Does an allowed send get rewritten?
No. The bytes that arrived are the bytes that are forwarded. A refused send is not forwarded at all.
What does the sender receive past the cap?
An error object whose name is the reason and whose message is the sentence the guard produced. The upstream is not called for that request.