AgentPay API Documentation

BASE_URL: https://agentpay.metaltorque.dev
All responses are JSON unless otherwise stated.

Authentication

Auth Types
Supported
X-Gateway-Key, X-Developer-Key, X-Admin-Key, x402 USDC
Example
Authorization: x402 usdc <signed-intent>
curl -H "X-Gateway-Key: $GATEWAY_KEY" \
  https://agentpay.metaltorque.dev/gateway/balance

SDK Install

# Node.js
npm i @agentpay/sdk
# Python
pip install agentpay

Error Codes

{
  "error": {
    "code": "AUTH_FAILED",
    "message": "Invalid or expired API key",
    "request_id": "req_9j2k..."
  }
}

Rate Limits

{
  "limit_per_minute": 1200,
  "burst": 200,
  "headers": {
    "x-ratelimit-limit": "1200",
    "x-ratelimit-remaining": "1194",
    "x-ratelimit-reset": "1700000000"
  }
}

Webhooks HMAC

Sign payloads with your webhook secret using HMAC-SHA256. Header: X-AgentPay-Signature
signature = hex(hmac_sha256(secret, raw_body))
{
  "id": "evt_123",
  "type": "invoice.paid",
  "created": "2026-02-26T20:10:00Z",
  "data": { "object": { "invoice_id": "inv_001" } }
}

Gateway

POST /gateway/register
Auth
X-Gateway-Key
{"name":"Acme Gateway","callback_url":"https://example.com/webhook"}
{"gateway_id":"gw_123","status":"active"}
curl -X POST https://agentpay.metaltorque.dev/gateway/register \
  -H "X-Gateway-Key: $GATEWAY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Acme Gateway","callback_url":"https://example.com/webhook"}'
GET/gateway/balance
Auth
X-Gateway-Key
{}
{"available_usdc":"1024.55","pending_usdc":"40.00"}
curl https://agentpay.metaltorque.dev/gateway/balance \
  -H "X-Gateway-Key: $GATEWAY_KEY"
POST/gateway/fund
Auth
X-Gateway-Key
{"amount_usdc":"100.00","source":"stripe"}
{"funding_id":"fund_001","status":"processing"}
curl -X POST https://agentpay.metaltorque.dev/gateway/fund \
  -H "X-Gateway-Key: $GATEWAY_KEY" -H "Content-Type: application/json" \
  -d '{"amount_usdc":"100.00","source":"stripe"}'
POST/gateway/fund/x402
Auth
x402 USDC
{"amount_usdc":"100.00"}
{"funding_id":"fund_402","status":"settled"}
curl -X POST https://agentpay.metaltorque.dev/gateway/fund/x402 \
  -H "Authorization: x402 usdc $SIGNED_INTENT" \
  -H "Content-Type: application/json" \
  -d '{"amount_usdc":"100.00"}'
POST/gateway/provision
Auth
X-Gateway-Key
{"agent_id":"agt_123","quota_usdc":"50.00"}
{"provision_id":"prov_001","status":"active"}
curl -X POST https://agentpay.metaltorque.dev/gateway/provision \
  -H "X-Gateway-Key: $GATEWAY_KEY" -H "Content-Type: application/json" \
  -d '{"agent_id":"agt_123","quota_usdc":"50.00"}'
POST/gateway/call
Auth
X-Gateway-Key
{"agent_id":"agt_123","input":{"task":"summarize"}} 
{"call_id":"call_001","status":"queued"}
curl -X POST https://agentpay.metaltorque.dev/gateway/call \
  -H "X-Gateway-Key: $GATEWAY_KEY" -H "Content-Type: application/json" \
  -d '{"agent_id":"agt_123","input":{"task":"summarize"}}'
GET/gateway/usage
Auth
X-Gateway-Key
{}
{"month":"2026-02","total_usdc":"321.55"}
curl https://agentpay.metaltorque.dev/gateway/usage \
  -H "X-Gateway-Key: $GATEWAY_KEY"
POST/gateway/keys/rotate
Auth
X-Gateway-Key
{"reason":"exposure"}
{"new_key":"gw_live_***"}
curl -X POST https://agentpay.metaltorque.dev/gateway/keys/rotate \
  -H "X-Gateway-Key: $GATEWAY_KEY" -H "Content-Type: application/json" \
  -d '{"reason":"exposure"}'
GET/gateway/discover
Auth
X-Gateway-Key
{}
{"agents":[{"id":"agt_1","name":"DataBot"}]}
curl https://agentpay.metaltorque.dev/gateway/discover \
  -H "X-Gateway-Key: $GATEWAY_KEY"
GET/gateway/tools
Auth
X-Gateway-Key
{}
{"tools":[{"id":"tool_1","name":"summarize"}]}
curl https://agentpay.metaltorque.dev/gateway/tools \
  -H "X-Gateway-Key: $GATEWAY_KEY"

Subscriptions

POST/subscriptions
Auth
X-Developer-Key
{"plan":"pro","seat_count":5}
{"subscription_id":"sub_001","status":"active"}
curl -X POST https://agentpay.metaltorque.dev/subscriptions \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"plan":"pro","seat_count":5}'
GET/subscriptions
Auth
X-Developer-Key
{}
{"subscriptions":[{"id":"sub_001","status":"active"}]}
curl https://agentpay.metaltorque.dev/subscriptions \
  -H "X-Developer-Key: $DEV_KEY"
DELETE/subscriptions/{subscription_id}
Auth
X-Developer-Key
{}
{"status":"canceled"}
curl -X DELETE https://agentpay.metaltorque.dev/subscriptions/sub_001 \
  -H "X-Developer-Key: $DEV_KEY"

Invoices

GET/invoices
Auth
X-Developer-Key
{}
{"invoices":[{"id":"inv_1","status":"open"}]}
curl https://agentpay.metaltorque.dev/invoices \
  -H "X-Developer-Key: $DEV_KEY"
POST/invoices/{invoice_id}/mark-paid
Auth
X-Admin-Key
{"note":"paid via ACH"}
{"status":"paid"}
curl -X POST https://agentpay.metaltorque.dev/invoices/inv_1/mark-paid \
  -H "X-Admin-Key: $ADMIN_KEY" -H "Content-Type: application/json" \
  -d '{"note":"paid via ACH"}'

Organizations

POST/orgs
Auth
X-Developer-Key
{"name":"Acme Labs"}
{"org_id":"org_1"}
curl -X POST https://agentpay.metaltorque.dev/orgs \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Acme Labs"}'
GET/orgs
Auth
X-Developer-Key
{}
{"orgs":[{"id":"org_1","name":"Acme Labs"}]}
curl https://agentpay.metaltorque.dev/orgs -H "X-Developer-Key: $DEV_KEY"
GET/orgs/{org_id}
Auth
X-Developer-Key
{}
{"id":"org_1","members":3}
curl https://agentpay.metaltorque.dev/orgs/org_1 -H "X-Developer-Key: $DEV_KEY"
POST/orgs/{org_id}/members
Auth
X-Developer-Key
{"email":"[email protected]","role":"admin"}
{"status":"invited"}
curl -X POST https://agentpay.metaltorque.dev/orgs/org_1/members \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","role":"admin"}'
DELETE/orgs/{org_id}/members/{member_id}
Auth
X-Developer-Key
{}
{"status":"removed"}
curl -X DELETE https://agentpay.metaltorque.dev/orgs/org_1/members/mem_1 \
  -H "X-Developer-Key: $DEV_KEY"

Contracts

POST/orgs/{org_id}/contracts
Auth
X-Developer-Key
{"title":"SLA 99.9%","terms":"..."} 
{"contract_id":"ct_1","status":"draft"}
curl -X POST https://agentpay.metaltorque.dev/orgs/org_1/contracts \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"title":"SLA 99.9%","terms":"..."}'
GET/orgs/{org_id}/contracts
Auth
X-Developer-Key
{}
{"contracts":[{"id":"ct_1","status":"draft"}]}
curl https://agentpay.metaltorque.dev/orgs/org_1/contracts \
  -H "X-Developer-Key: $DEV_KEY"

Purchase Orders

POST/orgs/{org_id}/purchase-orders
Auth
X-Developer-Key
{"amount_usdc":"1000.00","memo":"Q2 credits"}
{"po_id":"po_1","status":"open"}
curl -X POST https://agentpay.metaltorque.dev/orgs/org_1/purchase-orders \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"amount_usdc":"1000.00","memo":"Q2 credits"}'
GET/orgs/{org_id}/purchase-orders
Auth
X-Developer-Key
{}
{"purchase_orders":[{"id":"po_1","status":"open"}]}
curl https://agentpay.metaltorque.dev/orgs/org_1/purchase-orders \
  -H "X-Developer-Key: $DEV_KEY"

Usage Forecast

GET/usage/forecast
Auth
X-Developer-Key
{}
{"next_30_days_usdc":"420.00"}
curl https://agentpay.metaltorque.dev/usage/forecast \
  -H "X-Developer-Key: $DEV_KEY"

Alerts

POST/alerts
Auth
X-Developer-Key
{"type":"budget","threshold_usdc":"100.00"}
{"alert_id":"al_1","status":"active"}
curl -X POST https://agentpay.metaltorque.dev/alerts \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"type":"budget","threshold_usdc":"100.00"}'
GET/alerts
Auth
X-Developer-Key
{}
{"alerts":[{"id":"al_1","type":"budget"}]}
curl https://agentpay.metaltorque.dev/alerts -H "X-Developer-Key: $DEV_KEY"
DELETE/alerts/{alert_id}
Auth
X-Developer-Key
{}
{"status":"deleted"}
curl -X DELETE https://agentpay.metaltorque.dev/alerts/al_1 \
  -H "X-Developer-Key: $DEV_KEY"

Private Marketplaces

POST/orgs/{org_id}/private-marketplaces
Auth
X-Developer-Key
{"name":"Acme Internal"}
{"marketplace_id":"pm_1"}
curl -X POST https://agentpay.metaltorque.dev/orgs/org_1/private-marketplaces \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Acme Internal"}'
GET/orgs/{org_id}/private-marketplaces
Auth
X-Developer-Key
{}
{"private_marketplaces":[{"id":"pm_1"}]}
curl https://agentpay.metaltorque.dev/orgs/org_1/private-marketplaces \
  -H "X-Developer-Key: $DEV_KEY"
POST/orgs/{org_id}/private-marketplaces/{pm_id}/agents
Auth
X-Developer-Key
{"agent_id":"agt_123"}
{"status":"added"}
curl -X POST https://agentpay.metaltorque.dev/orgs/org_1/private-marketplaces/pm_1/agents \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"agent_id":"agt_123"}'
GET/orgs/{org_id}/private-marketplaces/{pm_id}/agents
Auth
X-Developer-Key
{}
{"agents":[{"id":"agt_123","name":"DataBot"}]}
curl https://agentpay.metaltorque.dev/orgs/org_1/private-marketplaces/pm_1/agents \
  -H "X-Developer-Key: $DEV_KEY"

Policies

POST/orgs/{org_id}/policies
Auth
X-Developer-Key
{"name":"Budget Cap","rules":{"monthly_usdc":"500"}} 
{"policy_id":"pol_1","status":"active"}
curl -X POST https://agentpay.metaltorque.dev/orgs/org_1/policies \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Budget Cap","rules":{"monthly_usdc":"500"}}'
GET/orgs/{org_id}/policies
Auth
X-Developer-Key
{}
{"policies":[{"id":"pol_1","name":"Budget Cap"}]}
curl https://agentpay.metaltorque.dev/orgs/org_1/policies \
  -H "X-Developer-Key: $DEV_KEY"
GET/orgs/{org_id}/policies/logs
Auth
X-Developer-Key
{}
{"logs":[{"policy_id":"pol_1","action":"enforced"}]}
curl https://agentpay.metaltorque.dev/orgs/org_1/policies/logs \
  -H "X-Developer-Key: $DEV_KEY"

Disputes

POST/disputes
Auth
X-Developer-Key
{"invoice_id":"inv_1","reason":"overcharge"}
{"dispute_id":"dp_1","status":"open"}
curl -X POST https://agentpay.metaltorque.dev/disputes \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"invoice_id":"inv_1","reason":"overcharge"}'
GET/disputes
Auth
X-Developer-Key
{}
{"disputes":[{"id":"dp_1","status":"open"}]}
curl https://agentpay.metaltorque.dev/disputes -H "X-Developer-Key: $DEV_KEY"
POST/disputes/{dispute_id}/resolve
Auth
X-Admin-Key
{"resolution":"approved"} 
{"status":"resolved"}
curl -X POST https://agentpay.metaltorque.dev/disputes/dp_1/resolve \
  -H "X-Admin-Key: $ADMIN_KEY" -H "Content-Type: application/json" \
  -d '{"resolution":"approved"}'

Webhooks

POST/webhooks
Auth
X-Developer-Key
{"url":"https://example.com/hook","events":["invoice.paid"]}
{"webhook_id":"wh_1","status":"active"}
curl -X POST https://agentpay.metaltorque.dev/webhooks \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/hook","events":["invoice.paid"]}'
GET/webhooks
Auth
X-Developer-Key
{}
{"webhooks":[{"id":"wh_1","url":"https://example.com/hook"}]}
curl https://agentpay.metaltorque.dev/webhooks -H "X-Developer-Key: $DEV_KEY"
DELETE/webhooks/{webhook_id}
Auth
X-Developer-Key
{}
{"status":"deleted"}
curl -X DELETE https://agentpay.metaltorque.dev/webhooks/wh_1 \
  -H "X-Developer-Key: $DEV_KEY"

Receipts

GET/receipts
Auth
X-Developer-Key
{}
{"receipts":[{"id":"rcpt_1","amount_usdc":"12.00"}]}
curl https://agentpay.metaltorque.dev/receipts -H "X-Developer-Key: $DEV_KEY"
GET/receipts/{receipt_id}
Auth
X-Developer-Key
{}
{"id":"rcpt_1","line_items":[{"desc":"agent call","amount":"12.00"}]}
curl https://agentpay.metaltorque.dev/receipts/rcpt_1 -H "X-Developer-Key: $DEV_KEY"

Marketplace

GET/marketplace/agents
Auth
Public
{}
{"agents":[{"id":"agt_1","name":"DataBot"}]}
curl https://agentpay.metaltorque.dev/marketplace/agents
POST/marketplace/agents
Auth
X-Developer-Key
{"name":"DataBot","category":"analytics"}
{"agent_id":"agt_1","status":"pending"}
curl -X POST https://agentpay.metaltorque.dev/marketplace/agents \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"name":"DataBot","category":"analytics"}'
GET/marketplace/agents/{agent_id}
Auth
Public
{}
{"id":"agt_1","name":"DataBot","versions":3}
curl https://agentpay.metaltorque.dev/marketplace/agents/agt_1
PATCH/marketplace/agents/{agent_id}
Auth
X-Developer-Key
{"description":"New release notes"}
{"status":"updated"}
curl -X PATCH https://agentpay.metaltorque.dev/marketplace/agents/agt_1 \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"description":"New release notes"}'
GET/marketplace/agents/{agent_id}/versions
Auth
Public
{}
{"versions":[{"id":"v1.0.0"}]}
curl https://agentpay.metaltorque.dev/marketplace/agents/agt_1/versions
GET/marketplace/agents/{agent_id}/method-pricing
Auth
Public
{}
{"methods":[{"name":"summarize","price_usdc":"0.01"}]}
curl https://agentpay.metaltorque.dev/marketplace/agents/agt_1/method-pricing
GET/marketplace/agents/{agent_id}/sla
Auth
Public
{}
{"uptime":"99.9%","p95_ms":850}
curl https://agentpay.metaltorque.dev/marketplace/agents/agt_1/sla
POST/marketplace/agents/{agent_id}/sla-contract
Auth
X-Developer-Key
{"org_id":"org_1","terms":"standard"} 
{"contract_id":"sla_1","status":"draft"}
curl -X POST https://agentpay.metaltorque.dev/marketplace/agents/agt_1/sla-contract \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"org_id":"org_1","terms":"standard"}'
GET/marketplace/agents/{agent_id}/sla-report
Auth
Public
{}
{"month":"2026-02","uptime":"99.95%"}
curl https://agentpay.metaltorque.dev/marketplace/agents/agt_1/sla-report
GET/marketplace/regions
Auth
Public
{}
{"regions":["us-east","eu-west"]}
curl https://agentpay.metaltorque.dev/marketplace/regions
GET/marketplace/revenue-rules
Auth
Public
{}
{"platform_fee_pct":5,"payout_schedule":"monthly"}
curl https://agentpay.metaltorque.dev/marketplace/revenue-rules
GET/marketplace/certifications
Auth
Public
{}
{"certifications":["SOC2","ISO27001"]}
curl https://agentpay.metaltorque.dev/marketplace/certifications

Bundles

POST/bundles
Auth
X-Developer-Key
{"name":"Starter","agent_ids":["agt_1","agt_2"]}
{"bundle_id":"bndl_1","status":"active"}
curl -X POST https://agentpay.metaltorque.dev/bundles \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"name":"Starter","agent_ids":["agt_1","agt_2"]}'
GET/bundles
Auth
Public
{}
{"bundles":[{"id":"bndl_1","name":"Starter"}]}
curl https://agentpay.metaltorque.dev/bundles
GET/bundles/{bundle_id}
Auth
Public
{}
{"id":"bndl_1","agents":["agt_1","agt_2"]}
curl https://agentpay.metaltorque.dev/bundles/bndl_1
POST/bundles/{bundle_id}/subscribe
Auth
X-Developer-Key
{"org_id":"org_1","plan":"monthly"}
{"subscription_id":"sub_bndl_1","status":"active"}
curl -X POST https://agentpay.metaltorque.dev/bundles/bndl_1/subscribe \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"org_id":"org_1","plan":"monthly"}'

Billing

POST/billing/authorize
Auth
x402 USDC
{"amount_usdc":"12.00","memo":"agent call"} 
{"authorization_id":"auth_1","status":"authorized"}
curl -X POST https://agentpay.metaltorque.dev/billing/authorize \
  -H "Authorization: x402 usdc $SIGNED_INTENT" \
  -H "Content-Type: application/json" \
  -d '{"amount_usdc":"12.00","memo":"agent call"}'
POST/billing/complete
Auth
X-Gateway-Key
{"authorization_id":"auth_1","usage":{"tokens":1234}} 
{"receipt_id":"rcpt_1","status":"settled"}
curl -X POST https://agentpay.metaltorque.dev/billing/complete \
  -H "X-Gateway-Key: $GATEWAY_KEY" -H "Content-Type: application/json" \
  -d '{"authorization_id":"auth_1","usage":{"tokens":1234}}'

Developers

POST/developers/register
Auth
Public
{"email":"[email protected]","name":"Dev Co"} 
{"developer_id":"dev_1","status":"pending"}
curl -X POST https://agentpay.metaltorque.dev/developers/register \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","name":"Dev Co"}'
GET/developers/profile
Auth
X-Developer-Key
{}
{"id":"dev_1","name":"Dev Co"}
curl https://agentpay.metaltorque.dev/developers/profile \
  -H "X-Developer-Key: $DEV_KEY"
GET/developers/earnings
Auth
X-Developer-Key
{}
{"month":"2026-02","total_usdc":"540.00"}
curl https://agentpay.metaltorque.dev/developers/earnings \
  -H "X-Developer-Key: $DEV_KEY"
POST/developers/payout
Auth
X-Developer-Key
{"amount_usdc":"200.00","destination":"bank"} 
{"payout_id":"po_1","status":"processing"}
curl -X POST https://agentpay.metaltorque.dev/developers/payout \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"amount_usdc":"200.00","destination":"bank"}'
POST/developers/rotate-key
Auth
X-Developer-Key
{"reason":"rotation"} 
{"new_key":"dev_live_***"}
curl -X POST https://agentpay.metaltorque.dev/developers/rotate-key \
  -H "X-Developer-Key: $DEV_KEY" -H "Content-Type: application/json" \
  -d '{"reason":"rotation"}'
GET/developers/dashboard
Auth
X-Developer-Key
{}
{"url":"https://agentpay.metaltorque.dev/dev/dashboard"}
curl https://agentpay.metaltorque.dev/developers/dashboard \
  -H "X-Developer-Key: $DEV_KEY"

Admin

GET/admin/tools
Auth
X-Admin-Key
{}
{"tools":["reconcile","replay"]}
curl https://agentpay.metaltorque.dev/admin/tools -H "X-Admin-Key: $ADMIN_KEY"
GET/admin/wallets
Auth
X-Admin-Key
{}
{"wallets":[{"id":"wal_1","balance_usdc":"10000"}]}
curl https://agentpay.metaltorque.dev/admin/wallets -H "X-Admin-Key: $ADMIN_KEY"
GET/admin/stats
Auth
X-Admin-Key
{}
{"active_orgs":120,"monthly_usdc":"54000"} 
curl https://agentpay.metaltorque.dev/admin/stats -H "X-Admin-Key: $ADMIN_KEY"
POST/admin/grants
Auth
X-Admin-Key
{"org_id":"org_1","amount_usdc":"500.00"} 
{"grant_id":"gr_1","status":"issued"}
curl -X POST https://agentpay.metaltorque.dev/admin/grants \
  -H "X-Admin-Key: $ADMIN_KEY" -H "Content-Type: application/json" \
  -d '{"org_id":"org_1","amount_usdc":"500.00"}'
GET/admin/disputes
Auth
X-Admin-Key
{}
{"disputes":[{"id":"dp_1","status":"open"}]}
curl https://agentpay.metaltorque.dev/admin/disputes -H "X-Admin-Key: $ADMIN_KEY"
GET/admin/certifications
Auth
X-Admin-Key
{}
{"pending":["SOC2","ISO27001"]}
curl https://agentpay.metaltorque.dev/admin/certifications \
  -H "X-Admin-Key: $ADMIN_KEY"
GET/admin/reliability
Auth
X-Admin-Key
{}
{"uptime":"99.98%","p95_ms":740}
curl https://agentpay.metaltorque.dev/admin/reliability \
  -H "X-Admin-Key: $ADMIN_KEY"

Other

GET/health
Auth
Public
{}
{"status":"ok"}
curl https://agentpay.metaltorque.dev/health
GET/storefront
Auth
Public
{}
{"html":"<!doctype html>..."}
curl https://agentpay.metaltorque.dev/storefront
GET/dashboard.html
Auth
X-Developer-Key
{}
{"html":"<!doctype html>..."}
curl https://agentpay.metaltorque.dev/dashboard.html \
  -H "X-Developer-Key: $DEV_KEY"
GET/docs
Auth
Public
{}
{"html":"<!doctype html>..."}
curl https://agentpay.metaltorque.dev/docs
POST/stripe/webhook
Auth
Stripe-Signature
{"id":"evt_123","type":"charge.succeeded"} 
{"received":true}
curl -X POST https://agentpay.metaltorque.dev/stripe/webhook \
  -H "Stripe-Signature: t=...,v1=..." \
  -d @payload.json