Developer Documentation

Integrate LetAgentPay with your AI agents in minutes.

Quick Start

  1. Sign up with your email (magic link, no password)
  2. Create an agent in the dashboard and get your Bearer token (agt_...)
  3. Choose your integration method below and start sending requests

Authentication

All Agent API endpoints use Bearer token authentication:

Authorization: Bearer agt_your_token_here

Integration

pip install letagentpay
from letagentpay import LetAgentPay

client = LetAgentPay(token="agt_your_token")

# Submit a purchase request
result = client.purchase(
    amount=49.99,
    category="groceries",
    merchant_name="Whole Foods",
    description="Weekly groceries",
)

if result.status == "auto_approved":
    client.confirm(result.request_id, success=True, actual_amount=47.50)
elif result.status == "pending":
    final = client.wait_for_decision(result.request_id, timeout=300)
    if final.status == "approved":
        client.confirm(result.request_id, success=True)
elif result.status == "rejected":
    print(f"Rejected: {result.policy_check}")

Decorator Pattern

from letagentpay import LetAgentPay, guard

client = LetAgentPay(token="agt_your_token")

@guard(client, category="groceries")
def buy_groceries(items: list[str]) -> dict:
    total = calculate_total(items)
    return {"items": items, "total": total}

Framework Integrations

LetAgentPay works with popular AI agent frameworks. Each integration wraps the Python SDK as a native tool for the framework.

LangChain

Custom BaseTool for any LangChain agent.

from letagentpay_langchain import LetAgentPayTool

tool = LetAgentPayTool()
agent = create_tool_calling_agent(llm, [tool], prompt)
Full example

OpenAI Agents SDK

Function tool with @function_tool.

@function_tool
def request_purchase(amount, category, ...):
    return client.request_purchase(...)
Full example

CrewAI

CrewAI tool with @tool decorator.

@tool("Request Purchase")
def request_purchase(amount, category, ...):
    return client.request_purchase(...)
Full example

Claude MCP

Zero-code integration via MCP server.

"letagentpay": {
  "command": "npx",
  "args": ["letagentpay-mcp"],
  "env": {"LETAGENTPAY_TOKEN": "agt_..."}
}
Full guide

API Reference

OpenAPI spec

Base URL: https://letagentpay.com/api/v1/agent-api

Request Lifecycle

  1. Agent sends POST /requests with amount, category, description
  2. Policy engine runs checks: status, category, per-request limit, schedule, daily/weekly/monthly limits, budget, account budget rules
  3. All checks pass + auto-approve criteria met → auto_approved
  4. All checks pass, no auto-approve → pending (human reviews)
  5. Any check fails → rejected (with detailed explanation)
  6. Pending requests expire after 30 minutes if not reviewed
  7. After approval, agent confirms with POST /requests/{id}/confirm

Machine-Readable Resources