v1.6.0 — Production

AgentLayer API

The financial governance layer for AI agents. Create delegated wallets with spend policies, enforce limits, verify agent identity, manage multi-agent delegation, and receive real-time webhooks — all via a single REST API.

💳
Delegated Wallets
Per-agent wallets with granular spend policies
🔐
KYA Identity
Cryptographic identity & trust scoring per agent
🔗
Multi-Agent Delegation
Hierarchical budget delegation between agents
x402 Protocol
Machine-to-machine USDC payments over HTTP
🪝
Webhooks
Real-time notifications for every event
🤖
Agent Tokens
Secure tokens for autonomous agent payments
Base URL
https://agentlayer-production-98fa.up.railway.app
Beta access — AgentLayer is currently in private beta. Contact hello@agentlayer.io to request an API key.

Authentication

AgentLayer supports two authentication methods depending on your use case.

API Key (server-to-server)

For server-side integrations. Include your API key in every request header.

x-api-key: al_live_xxxxxxxxxxxxxxxxxxxxxxxx

Agent Token (autonomous agent)

For AI agents operating autonomously. Generate a token per agent from your dashboard.

x-agent-token: agt_live_xxxxxxxxxxxxxxxxxxxxxxxx

Errors

AgentLayer uses standard HTTP status codes. All errors return a JSON object with an error field.

CodeDescription
200OKRequest succeeded
400Bad RequestMissing or invalid parameters
401UnauthorizedInvalid or missing API key / agent token
402Payment Requiredx402 payment required
403ForbiddenPayment blocked by spend policy
404Not FoundAgent wallet not found

Wallets

Each AI agent gets a delegated wallet with configurable spend limits. Limits reset automatically every day.

POST /api/wallets/create Create agent wallet
ParameterTypeDescription
agent_namestringHuman-readable name required
max_per_transactionnumberMax spend per transaction (USD) required
max_dailynumberMax total spend per day (USD) required
Response
{
  "success": true,
  "wallet": {
    "agent_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
    "agent_name": "Procurement Agent 01",
    "balance": 1000,
    "status": "active",
    "kya": {
      "did": "did:agentlayer:bd18c2df55727050e5fb3034c641ae50",
      "trust_level": "new",
      "trust_score": 0
    }
  }
}
GET /api/wallets List all wallets
curl .../api/wallets -H "x-api-key: al_live_xxx"

Payments

Execute a payment from an agent wallet. AgentLayer automatically enforces spend limits and returns a transaction ID.

POST /api/pay Execute payment (API key)
ParameterTypeDescription
agent_idstringThe agent's unique ID required
amountnumberAmount in USD required
descriptionstringPayment description
Response — success
{
  "success": true,
  "transaction": {
    "tx_id": "a1b2c3d4-...",
    "amount": 25,
    "description": "Market data purchase",
    "timestamp": "2026-05-24T12:00:00.000Z",
    "balance_after": 975
  }
}
Response — blocked (403)
{"error": "Dépasse la limite par transaction (max $100)"}

Recharge

Recharge an agent wallet via Stripe. The client deposits funds in USD and the wallet is credited automatically.

POST /client/topup Create Stripe checkout session
ParameterTypeDescription
wallet_idstringAgent wallet ID required
amountnumberAmount to deposit in USD required
Response
{"url": "https://checkout.stripe.com/pay/cs_test_..."}

KYA — Know Your Agent

Every agent has a cryptographic identity (DID) and a trust score that evolves based on transaction history.

New
Score 0–19
Verified
Score 20–49
Trusted
Score 50–69
Premium
Score 70+
GET /kya/:agent_id Get agent KYA report
Response
{
  "agent_id": "f47ac10b-...",
  "agent_name": "Procurement Agent 01",
  "did": "did:agentlayer:bd18c2df55727050e5fb3034c641ae50",
  "trust_level": "verified",
  "trust_score": 30,
  "certificate_valid": { "valid": true, "expired": false },
  "stats": {
    "total_transactions": 15,
    "total_volume": 250,
    "average_transaction": 16.67
  },
  "spend_policy": {
    "max_per_transaction": 100,
    "max_daily": 500,
    "allowed_protocols": ["x402", "ap2", "mpp"]
  }
}
GET /kya/:agent_id/verify Verify agent certificate
Response
{
  "verified": true,
  "did": "did:agentlayer:bd18c2df...",
  "trust_level": "verified",
  "certificate_valid": true,
  "expired": false,
  "spend_policy": { "max_per_transaction": 100, "max_daily": 500 }
}

Multi-Agent Delegation

Agent A can delegate a budget to Agent B, which can delegate to Agent C. Each level has its own limits.

POST /api/delegate Create delegation
ParameterTypeDescription
parent_agent_idstringParent agent ID required
child_agent_namestringName for child agent required
delegated_budgetnumberBudget to delegate in USD required
max_per_transactionnumberMax per transaction for child
Response
{
  "success": true,
  "child_wallet": { "agent_id": "...", "balance": 100 },
  "parent_balance_remaining": 900,
  "delegation_chain": [
    { "agent_name": "Agent A", "balance": 900, "is_delegated": false },
    { "agent_name": "Agent B", "balance": 100, "is_delegated": true }
  ]
}
GET /api/delegate/:agent_id/chain Get delegation chain
curl .../api/delegate/AGENT_ID/chain -H "x-api-key: al_live_xxx"

Webhooks

Receive real-time HTTP notifications when events occur. All webhooks are signed with HMAC-SHA256.

Signature verification — Every webhook includes a X-AgentLayer-Signature header. Verify it with your webhook secret.

Available Events

EventDescription
paymentA payment was executed successfully
blockedA payment was blocked by spend policy
wallet_createdA new agent wallet was created
topupA wallet was recharged via Stripe
POST /client/webhooks Create webhook
Response
{
  "success": true,
  "webhook": {
    "webhook_id": "bbcf554e-...",
    "url": "https://your-server.com/webhook",
    "secret": "whsec_2f28f3cfcc6bc21916a986dcb8d4ef4efd958394dfa655bb",
    "events": ["payment", "blocked", "wallet_created", "topup"]
  }
}

Verify Signature (Node.js)

const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  return `sha256=${expected}` === signature;
}

app.post('/webhook', (req, res) => {
  const sig = req.headers['x-agentlayer-signature'];
  const valid = verifyWebhook(JSON.stringify(req.body), sig, 'whsec_xxx');
  if (!valid) return res.status(400).json({ error: 'Invalid signature' });
  const { event, data } = req.body;
  console.log(`Event: ${event}`, data);
  res.json({ received: true });
});

x402 Protocol

AgentLayer implements the x402 payment protocol — any AI agent can pay for resources automatically over HTTP.

GET /x402/task x402 protected endpoint
Without payment (402)
{
  "error": "Payment Required",
  "price": "$0.001",
  "network": "base-sepolia",
  "protocol": "x402",
  "accepts": [{ "scheme": "exact", "price": "$0.001", "network": "eip155:84532" }]
}
With x-payment header (200)
{
  "status": "success",
  "message": "Task executed via x402",
  "amount_paid": "$0.001 USDC"
}

Agent Integration

Once you've created a wallet and generated an agent token from your dashboard, your AI agent can pay autonomously using a single HTTP call — no browser, no session, no human required.

How it works — Create a wallet in the dashboard → generate an agent token → embed the token in your agent code. Your agent can now pay, check its balance, and verify its identity autonomously.

Step 1 — Create a wallet

From your dashboard, click "Créer un agent" and set spend limits. Copy the agent_id.

Step 2 — Generate an agent token

POST /client/tokens/create
{ "agent_id": "your-agent-id", "name": "Production Token" }

→ { "token": "agt_live_xxxxx" }

Step 3 — Pay from your agent

Python
import requests

AGENT_TOKEN = "agt_live_xxxxxxxxxxxxxxxxxxxxxxxx"
BASE_URL = "https://agentlayer-production-98fa.up.railway.app"

def pay(amount, description):
    response = requests.post(
        f"{BASE_URL}/agent/pay",
        headers={
            "x-agent-token": AGENT_TOKEN,
            "Content-Type": "application/json"
        },
        json={"amount": amount, "description": description}
    )
    return response.json()

result = pay(10, "Market data purchase")
print(f"TX: {result['transaction']['tx_id']}")
print(f"Balance: ${result['agent']['balance_after']}")
Node.js
const AGENT_TOKEN = "agt_live_xxxxxxxxxxxxxxxxxxxxxxxx";
const BASE_URL = "https://agentlayer-production-98fa.up.railway.app";

async function pay(amount, description) {
  const res = await fetch(`${BASE_URL}/agent/pay`, {
    method: "POST",
    headers: {
      "x-agent-token": AGENT_TOKEN,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({ amount, description })
  });
  return res.json();
}

const result = await pay(10, "Market data purchase");
console.log(`TX: ${result.transaction.tx_id}`);
console.log(`Balance: $${result.agent.balance_after}`);
cURL
curl -X POST .../agent/pay \
  -H "x-agent-token: agt_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{"amount": 10, "description": "Market data purchase"}'

Step 4 — Check balance

Python
response = requests.get(
    f"{BASE_URL}/agent/balance",
    headers={"x-agent-token": AGENT_TOKEN}
)
balance = response.json()
print(f"Balance: ${balance['balance']}")
print(f"Spent today: ${balance['spent_today']} / ${balance['max_daily']}")
print(f"Trust level: {balance['trust_level']}")

Step 5 — Verify identity

Python
response = requests.get(
    f"{BASE_URL}/agent/identity",
    headers={"x-agent-token": AGENT_TOKEN}
)
identity = response.json()
print(f"DID: {identity['did']}")
print(f"Trust: {identity['trust_level']} (score: {identity['trust_score']})")

Payment response format

{
  "success": true,
  "transaction": {
    "tx_id": "a2552304-5b04-49a1-9231-aa146f4d26b0",
    "amount": 10,
    "description": "Market data purchase",
    "timestamp": "2026-05-24T14:28:24.207Z",
    "balance_after": 990
  },
  "agent": {
    "agent_id": "107e9623-...",
    "agent_name": "My Agent",
    "balance_after": 990,
    "trust_level": "new"
  }
}
Payment blocked? — If your agent exceeds its spend limit, AgentLayer returns a 403 with the reason. Handle this gracefully in your code.
Python — handle blocked payment
result = pay(500, "Large purchase")
if result.get("error"):
    print(f"Blocked: {result['error']}")
    # Handle: notify, retry later, request limit increase
elif result.get("success"):
    print(f"Paid! TX: {result['transaction']['tx_id']}")

Agent Tokens

Agent tokens authenticate individual AI agents. Each token is tied to a specific wallet and client account.

POST /client/tokens/create Create agent token
ParameterTypeDescription
agent_idstringAgent wallet ID required
namestringToken label (e.g. "Production")
Response
{
  "success": true,
  "token": "agt_live_38e683ca961443629e2981ff53aea562",
  "agent_id": "107e9623-...",
  "name": "Production Token"
}
POST /agent/pay Pay via agent token
Header
x-agent-token: agt_live_xxx
ParameterTypeDescription
amountnumberAmount in USD required
descriptionstringPayment description
GET /agent/balance Check balance via agent token
curl .../agent/balance -H "x-agent-token: agt_live_xxx"
GET /agent/identity Get KYA identity via agent token
curl .../agent/identity -H "x-agent-token: agt_live_xxx"

Quickstart

Get an agent making payments in under 5 minutes.

1. Sign up and create a wallet

→ https://agentlayer-production-98fa.up.railway.app/signup.html
→ Create an agent with spend limits from the dashboard
→ Copy the agent_id

2. Generate an agent token

POST /client/tokens/create
{ "agent_id": "your-agent-id", "name": "My First Token" }
→ Copy the token: agt_live_xxx

3. Your agent pays autonomously

import requests

result = requests.post(
    "https://agentlayer-production-98fa.up.railway.app/agent/pay",
    headers={"x-agent-token": "agt_live_xxx"},
    json={"amount": 10, "description": "First autonomous payment"}
).json()

print(result["transaction"]["tx_id"])  # Done!

4. Set up webhooks

POST /client/webhooks
{ "url": "https://your-server.com/webhook", "events": ["payment", "blocked"] }
→ You're notified instantly on every event