LimitLayer/Developer Docs
โ† Back to LimitLayer
API v2

LimitLayer API โ€” Developer Reference

Financial guardrails for AI agents. Control budgets, enforce merchant rules, require approvals, and get real-time spend decisions.

Base URL: https://api.limitlayer.ioSwagger: /docsReDoc: /redoc

1. Authentication

LimitLayer supports two authentication methods. Both can be used on every endpoint.

1a. API Key (recommended for machines)

Send the raw API key in either header:

http
X-API-Key: ll_aBcDeFgH...          โ† preferred
Authorization: Bearer ll_aBcDeFgH... โ† also accepted

1b. JWT Token (recommended for dashboard users)

External (tenant) login:

http
POST /auth/v2/login
Content-Type: application/json

{
  "email": "user@yourcompany.com",
  "password": "your-password"
}

Internal / admin login:

http
POST /auth/v2/admin/login
Content-Type: application/json

{
  "email": "admin@limitlayer.com",
  "password": "your-password"
}

Both return:

json
{
  "access_token": "eyJ...",
  "token_type": "bearer",
  "expires_in": 3600
}

Use the token in subsequent requests:

http
Authorization: Bearer eyJ...

Verify your identity

โš ๏ธ Never expose your API key in client-side code or public repositories. All calls to LimitLayer should be made from your server.

2. Roles & Permissions

Tenant Roles (per-organisation)

RoleDescriptionCan Do
ownerOrganisation ownerEverything
adminOrg adminEverything except ownership transfer
editorPower userCreate/edit wallets, agents, policies, transactions
viewerRead-only dashboardView all resources
report_onlyReporting onlyView transactions and audit log
api_userMachine identityTransact via API

Platform Roles (internal staff only)

RoleDescription
platform_adminFull platform access
support_adminSupport access
billing_adminBilling access
auditorRead-only audit access

Endpoint Permission Matrix

Endpoint Groupowneradmineditorviewerreport_onlyapi_user
Create walletโœ“โœ“โœ“โ€”โ€”โ€”
Read walletsโœ“โœ“โœ“โœ“โ€”โœ“
Freeze walletโœ“โœ“โ€”โ€”โ€”โ€”
Create/edit agentโœ“โœ“โœ“โ€”โ€”โ€”
Read agentsโœ“โœ“โœ“โœ“โ€”โœ“
Deactivate agentโœ“โœ“โ€”โ€”โ€”โ€”
Create/edit policyโœ“โœ“โœ“โ€”โ€”โ€”
Delete policyโœ“โœ“โ€”โ€”โ€”โ€”
Request transactionโœ“โœ“โœ“โ€”โ€”โœ“
View transactionsโœ“โœ“โœ“โœ“โ€”โœ“
Resolve approvalsโœ“โœ“โ€”โ€”โ€”โ€”
Confirm paymentโœ“โœ“โœ“โ€”โ€”โœ“
Audit logโœ“โœ“โ€”โœ“โœ“โ€”
Webhooksโœ“โœ“โœ“โ€”โ€”โ€”
Manage API keysโœ“โœ“โ€”โ€”โ€”โ€”

3. Organisation & API Keys

Register your organisation to get started. The API key returned is shown once only โ€” store it securely immediately.

4. Wallets

Wallets hold budget allocations. Every agent is attached to one wallet.

Budget field glossary

FieldDescription
budgetTotal allocated limit
total_approvedAmount reserved by approved transactions
total_confirmedAmount of payments actually confirmed
in_flighttotal_approved โˆ’ total_confirmed (approved but not yet paid)
remainingbudget โˆ’ total_approved (still available to spend)

5. Agents

Agents are AI identities that make spending requests. Each agent belongs to one wallet.

6. Policies

Policies define rules the transaction engine enforces before approving any spend request. Set agent_id to scope to one agent, wallet_id for all agents in a wallet, or both.

Policy types

policy_typeWhat it doesconfig keys
spending_limitCaps total spend per periodlimit, period (daily/weekly/monthly)
transaction_limitMax amount per single transactionmax_amount
merchant_allowlistOnly allow listed merchantsmerchants (array)
merchant_blocklistBlock listed merchantsmerchants (array)
time_restrictionOnly allow transactions in a time windowstart_hour, end_hour, timezone
approval_requiredRequire human approval above thresholdmin_amount
velocityLimit number of transactions per periodmax_count, period

7. Transactions

The core flow: an agent requests a transaction โ†’ policies are evaluated โ†’ decision is returned.

Transaction Lifecycle

CREATED โ†’ [REQUIRES_APPROVAL] โ†’ APPROVED โ†’ PAYMENT_CONFIRMED
                                          โ†’ PAYMENT_FAILED (wallet reversed)
         โ†’ DENIED
         โ†’ EXPIRED  (approval window elapsed)

List transactions โ€” query parameters

ParameterTypeDescription
pageint โ‰ฅ 1Page number (default 1)
per_pageint 1โ€“100Results per page (default 20)
statusstringPENDING ยท APPROVED ยท DENIED ยท REQUIRES_APPROVAL ยท EXPIRED
agent_iduuidFilter by agent
wallet_iduuidFilter by wallet
merchantstringPartial match
min_amountfloatMinimum amount
max_amountfloatMaximum amount
from_dateISO datetimeStart of date range
to_dateISO datetimeEnd of date range

8. Approvals

When a transaction requires human approval it enters a 24-hour approval window. If not resolved it transitions to EXPIRED.

If the approval has expired, this returns 410 Gone.

9. Audit Log

Read-only transaction history for compliance and reporting.

Query parameters

ParameterTypeDescription
agent_iduuidFilter by agent
wallet_iduuidFilter by wallet
statusstringEvaluation status filter
from_dateISO datetimeStart of range
to_dateISO datetimeEnd of range
limitint โ‰ค 1000Results per page (default 50)
offsetintPagination offset

10. Webhooks

Webhooks deliver real-time event notifications to your HTTP endpoint via signed POST requests.

Verifying webhook signatures

Every webhook POST includes an X-LimitLayer-Signature header. Verify it to ensure the payload is genuine.

python
import hmac, hashlib

def verify_signature(payload_bytes: bytes, header: str, secret: str) -> bool:
    expected = hmac.new(secret.encode(), payload_bytes, hashlib.sha256).hexdigest()
    return hmac.compare_digest(f"sha256={expected}", header)
javascript
const crypto = require('crypto');

function verifySignature(rawBody, signatureHeader, secret) {
  const expected = 'sha256=' + crypto
    .createHmac('sha256', secret)
    .update(rawBody)
    .digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(expected),
    Buffer.from(signatureHeader)
  );
}

11. Webhook Event Payloads

All webhook POST bodies share this envelope:

json
{
  "event": "transaction.approved",
  "timestamp": "2026-03-28T10:00:00Z",
  "organisation_id": "uuid",
  "data": { }
}

Headers on every delivery:

http
X-LimitLayer-Signature: sha256=<hmac>
X-LimitLayer-Event: transaction.approved
Content-Type: application/json
transaction.approved
json
{
  "transaction_id": "uuid",
  "agent_id": "uuid",
  "amount": 249.99,
  "currency": "USD",
  "merchant": "AWS",
  "wallet_remaining": 4750.01
}
transaction.denied
json
{
  "transaction_id": "uuid",
  "agent_id": "uuid",
  "amount": 249.99,
  "currency": "USD",
  "merchant": "ShopXYZ",
  "denial_reason": "Merchant not in allowlist"
}
transaction.requires_approval
json
{
  "transaction_id": "uuid",
  "approval_id": "uuid",
  "agent_id": "uuid",
  "amount": 1500.00,
  "currency": "USD",
  "merchant": "Salesforce",
  "expires_at": "2026-03-29T10:00:00"
}
transaction.payment_confirmed
json
{
  "transaction_id": "uuid",
  "amount": 249.99,
  "currency": "USD",
  "merchant": "AWS",
  "payment_reference": "stripe_ch_abc123",
  "wallet_remaining": 4750.01
}
transaction.payment_failed
json
{
  "transaction_id": "uuid",
  "amount": 249.99,
  "currency": "USD",
  "merchant": "AWS",
  "payment_failure_reason": "Insufficient funds",
  "wallet_remaining": 5000.0
}
wallet.budget_warningFired when utilisation โ‰ฅ 70%
json
{
  "wallet_id": "uuid",
  "wallet_name": "GPT-4 Operations Budget",
  "budget": 5000.0,
  "total_approved": 3600.0,
  "remaining": 1400.0,
  "usage_pct": 72.0
}
wallet.budget_criticalFired when utilisation โ‰ฅ 90%
json
{
  "wallet_id": "uuid",
  "wallet_name": "GPT-4 Operations Budget",
  "budget": 5000.0,
  "total_approved": 4600.0,
  "remaining": 400.0,
  "usage_pct": 92.0
}

12. Error Reference

All errors follow this shape: { "detail": "Human-readable error message" }

StatusMeaning
400Bad request โ€” validation failed or invalid input
401Unauthenticated โ€” missing or invalid credentials
403Forbidden โ€” authenticated but insufficient role/access
404Resource not found or doesn't belong to your org
409Conflict โ€” e.g. duplicate wallet name
410Gone โ€” approval request has expired
422Unprocessable entity โ€” request body schema violation
423Locked โ€” wallet is frozen, transactions blocked
429Rate limit exceeded
500Internal server error

Common 401 causes

  • API key not in X-API-Key header or Authorization: Bearer header
  • API key is_active = false or status = revoked
  • API key expires_at in the past
  • JWT token expired or signature invalid

Common 403 causes

  • Tenant role insufficient for this operation (see permission matrix)
  • Cross-tenant request blocked (path org_id โ‰  caller's org_id)
  • Organisation inactive or soft-deleted

Last updated: March 2026