AgentRefills for LangChain

Let your LangChain agent buy gift cards.

Add one @tool and your LangChain or LangGraph agent can buy gift cards on the same rails, with per-agent budgets and a full audit trail.

Integration

Add a gift-card tool in a few lines

pip install langchain requests
agentrefills — langchain.py
from langchain_core.tools import tool
import requests

BASE = "https://api.agentrefills.com"
H = {"Authorization": "Bearer sk_live_..."}

@tool
def buy_giftcard(brand_id: str, amount_minor: int) -> dict:
    """Buy a gift card for `brand_id`; `amount_minor` is the value in cents."""
    r = requests.post(f"{BASE}/v1/purchases", headers=H, json={
        "brand_id": brand_id, "amount_minor": amount_minor, "currency": "USD",
    })
    r.raise_for_status()
    return r.json()

# bind [buy_giftcard] to any LangChain agent or LangGraph node
Why AgentRefills

Safe enough to hand an autonomous LangChain agent

Per-agent spend caps

Daily and monthly limits plus a brand allowlist, enforced on every purchase.

Human-in-the-loop

Purchases above your threshold are approved by a human in Slack before money moves.

Fail-closed policy

If the policy engine is unreachable or undecided, the purchase is denied, never allowed.

Encrypted single-read codes

Codes are encrypted at rest, released once, access-logged, and never written to logs or traces.

Zero duplicate payments

An idempotency key plus a unique payment-per-task constraint make a double charge structurally impossible.

Full audit trail

Every order is reconstructable from an OpenTelemetry trace plus a double-entry ledger, with webhooks on completion.

Use cases

What LangChain agents use it for

Rewards & incentives

Send a gift card for a survey, referral or milestone.

Automated refunds

Resolve a ticket with a gift card instead of a slow reversal.

Gifting bots

Send a scheduled thank-you or birthday gift, within a budget.

Procurement agents

Buy stored-value for a team, capped and reconciled.

FAQ

LangChain + AgentRefills

How do I add gift-card purchasing to a LangChain agent?

Define a LangChain @tool that calls the AgentRefills /v1/purchases endpoint and bind it to your agent or LangGraph node. The tool returns a task id; the code is released separately through get_code so raw codes never sit in the model context.

How do I cap what the agent can spend?

Every agent gets its own API key scoped to per-agent daily and monthly spend caps and a brand allowlist. The policy engine enforces the caps on every purchase and fails closed, so the agent can never exceed its budget even if the policy service is unreachable.

How do I require human approval for a purchase?

Set an approval threshold. Any purchase above it is parked as APPROVAL_REQUIRED and a human is pinged in Slack to approve or reject before money moves. The task resumes automatically once approved.

Give your LangChain agent a wallet it can't misuse.

Start in the sandbox with zero real spend, then flip to production.

Get API keys
Also for