GET /v1/brands
Search purchasable brands by query, country, and category. Read-only, backed by a 15-minute cache.
The same semantics as the MCP server, over plain HTTP. Base URL is
https://agentrefills.com, every path is versioned under /v1.
Six operations let an agent search brands, buy a gift card, poll it, release the code once,
and check its own spend. Money is integer minor units, purchases are idempotent, and every
error comes from one closed taxonomy.
Learn these once and the whole API is predictable. They are enforced on the server, so an agent can lean on them instead of guessing.
Authorization: Bearer <API_KEY> on every request. Each key is scoped to one agent with its own daily and monthly caps and brand allowlist.amount_minor: 2500 means $25.00. There are no floats anywhere in the API.client_ref. Supply a client_ref on a purchase. Re-using it returns the existing task and never charges twice.POST /v1/purchases returns a task_id right away. Poll GET /v1/purchases/{task_id} or subscribe to the purchase.completed webhook, then release the code.
Every REST endpoint maps 1:1 to an MCP tool. Branch on the response, act on the hint.
GET /v1/brands
Search purchasable brands by query, country, and category. Read-only, backed by a 15-minute cache.
POST /v1/purchases
Start a gift-card purchase. Returns a task_id immediately; settles under the cap or parks for approval.
GET /v1/purchases/{task_id}
Poll the current state of a purchase. code_available: true means the code is ready to release.
POST /v1/purchases/{task_id}/code
Release the redemption code, link, or PIN exactly once. A second call returns ALREADY_RELEASED.
GET /v1/balance
The calling agent's remaining budget, daily and monthly caps, and kill-switch status.
POST /v1/approvals
Re-ping the human approver for a parked task. Rate-limited to one request per task per hour.
# 1. Start the purchase. Returns a task_id right away $ curl -sS https://agentrefills.com/v1/purchases \ -H "Authorization: Bearer $AGENTREFILLS_KEY" \ -H "Content-Type: application/json" \ -d '{"brand_id":"amazon_com-usa","amount_minor":2500,"currency":"USD","client_ref":"reward-9f3a"}' { "task_id": "3f1c...", "status": "accepted", "state": "paid", "estimated_seconds": 8 } # 2. Release the code exactly once (single-read; never logged) $ curl -sS -X POST https://agentrefills.com/v1/purchases/3f1c.../code \ -H "Authorization: Bearer $AGENTREFILLS_KEY" { "code": "GIFT-XXXX-9F2A", "face_minor": 2500, "remaining_minor": 2500 }
Agents branch on code and act on hint. Every error carries an
agent-actionable hint, and RETRYABLE always includes retry_after in seconds.
POLICY_DENIEDThe fail-closed policy engine denied the purchase (allowlist, rule, or unreachable policy).
BUDGET_EXCEEDEDThe purchase would exceed the agent's daily or monthly spend cap.
APPROVAL_REQUIREDParked for human approval above the threshold. Call request_approval or await the webhook.
APPROVAL_REJECTEDA human declined the purchase. The task will not settle.
OUT_OF_STOCKThe brand or requested denomination is not currently available.
PAYMENT_FAILEDThe payment could not settle against the pre-funded balance.
INVOICE_EXPIREDThe provider invoice lapsed before payment completed.
PROVIDER_HOLDThe provider is holding the order for review. Poll or retry later.
ALREADY_RELEASEDThe single-read code was already released once. Store it on first release.
NOT_FOUNDNo task, brand, or resource exists for the given id.
UNAUTHORIZEDMissing or invalid bearer token, or the key is out of scope.
RETRYABLETransient failure. Retry after retry_after seconds; safe to repeat.
Create a scoped key, drop it into your agent, and buy in sandbox for free. Prefer native tools? The MCP server exposes the same six operations.