Reference
API reference
Conventions#
| Topic | Rule |
|---|---|
| Base URL | https://cortexpay.vercel.app |
| Authentication | Session cookie, or Authorization: Bearer cpk_…. See Authentication. |
| Bodies | JSON in and out. Field names are camelCase; webhook payloads are snake_case. |
| Money | Strings of integer base units (1 USDC = 1000000), named …Base or amount. Inputs that take dollars say so (for example initialBudget: "25"). |
| Times | ISO 8601 in UTC. |
| Lists | Newest first. Pass nextCursor as cursor for the next page. |
| Errors | { error: { code, message, details? } }. See Errors. |
Access labels: Public needs no credentials; Session needs a signed-in browser session and refuses API keys; Key: scope accepts a session or an API key with that scope. Where a role is shown, a session needs that role.
Not available yet in this deployment: GET /api/approvals/:id.
Sessions & identity#
Guide: Sessions & identity.
- GET
/api/session/guestStart a guest session with a seeded sandbox workspace, then redirect to ?next=.
Public
- POST
/api/auth/nonceSingle-use nonce for a Sign-In with Ethereum message (valid 10 minutes).
Public
- POST
/api/auth/verifyVerify a signed SIWE message { message, signature } and start a wallet session (cookie).
Public
- POST
/api/auth/logoutRevoke the current session and clear the cookie.
Public
- GET
/api/meThe caller, the active workspace and which platform features are configured.
Any key
- POST
/api/orgs/switchMake another of your workspaces active for this session.
Any key · Only meaningful for sessions; a key is bound to one workspace.
API keys & applications#
Guide: API keys & applications.
- GET
/api/keysAPI keys in the active workspace (prefix only).
Session
- POST
/api/keysCreate a key { name, scopes, expiresInDays?, applicationId?, rateLimitPerMin? }. The secret is returned once.
Session · owner/admin · 20/min
- GET
/api/keys/:idOne key (prefix, scopes, last use).
Session
- PATCH
/api/keys/:idRename or change the per-minute limit. Scopes are fixed.
Session · owner/admin · 60/min
- DELETE
/api/keys/:idRevoke now (audited). The next request with the key gets 401.
Session · owner/admin · 60/min
- GET
/api/applicationsRegistered applications with key and webhook counts.
Session
- POST
/api/applicationsRegister an application { name, description? }.
Session · owner/admin · 20/min
- GET
/api/applications/:idOne application.
Session
- PATCH
/api/applications/:id{ name?, description?, status? }. Disabling revokes its keys and disables its webhooks.
Session · owner/admin · 60/min
- DELETE
/api/applications/:idDelete an application that never had a key.
Session · owner/admin
Agents#
Guide: Agents.
- GET
/api/agentsAgents in the workspace (status, category, q filters; cursor pagination).
Key: agents:read · key's rate limit
- POST
/api/agents/registerIdempotency-KeyRegister an agent with its CortexID, delegated permission and spending policy. Costs 10 credits.
Key: agents:write · session owner/admin · 20/min
- GET
/api/agents/:idFull agent profile: identity, policy, budget, permissions, services, ledger.
Key: agents:read · key's rate limit
- PATCH
/api/agents/:idRename, describe, re-avatar, set externalId or move to another policy.
Key: agents:write · session owner/admin · 60/min
- POST
/api/agents/:id/pauseStop new payments now; unsettled authorizations are revoked. Body { reason? }.
Key: agents:write · session owner/admin · 30/min
- POST
/api/agents/:id/resumeRe-enable spending.
Session · owner/admin · 30/min · Never an API key, so an agent cannot un-pause itself.
- POST
/api/agents/:id/revokePermanent. Body { confirm: true, reason? }.
Key: agents:write · session owner/admin · 30/min
- PATCH
/api/agents/:id/identityPublic profile toggle, public fields, leaderboard opt-in, capability tags.
Key: agents:write · session owner/admin · 60/min
- POST
/api/agents/:id/verifyRaise the CortexID verification level.
Key: agents:write · session owner/admin · 20/min
- GET
/api/agents/:id/accountAccount, balances, spend windows and available budget.
Key: agents:read · key's rate limit
- GET
/api/agents/:id/transactionsPayments made and received, newest first.
Key: agents:read · key's rate limit
- GET
/api/agents/:id/analyticsDaily spend (UTC), top services, rejection reasons, latency.
Key: agents:read · key's rate limit
- POST
/api/agents/:id/fundIdempotency-KeySandbox top-up in simulated sUSDC (capped).
Session · owner/admin · 20/min
- POST
/api/agents/:id/withdrawIdempotency-KeyOwner-authorized withdrawal (sandbox: simulated ledger transfer).
Session · owner/admin · 20/min
Spending policies#
Guide: Spending policies.
- GET
/api/policiesSpending policies with current rules and the agents using them.
Key: policies:read · key's rate limit
- POST
/api/policiesIdempotency-KeySame as POST /api/policies/create.
Key: policies:write · session owner/admin · 30/min
- POST
/api/policies/createIdempotency-KeyCreate a policy (version 1) { name, description?, templateKey?, rules, notes? }.
Key: policies:write · session owner/admin · 30/min
- GET
/api/policies/:idPolicy with current rules, version history (with diffs) and agents.
Key: policies:read · key's rate limit
- PATCH
/api/policies/:idRename, describe, archive or restore; new rules publish a new version.
Key: policies:write · session owner/admin · 30/min
- GET
/api/policies/:id/versionsVersion history, newest first, with diffs.
Key: policies:read · key's rate limit
- POST
/api/policies/:id/versionsPublish new rules as version N+1 { rules, baseVersion, notes? }.
Key: policies:write · session owner/admin · 30/min
- POST
/api/policies/evaluateDry run of the ten checks for { agentId, serviceId, amount? }. Records nothing.
Key: policies:read · 60/min
- DELETE
/api/agents/:id/services/:serviceIdEmergency removal of an approved service (new policy version).
Key: policies:write · session owner/admin · 30/min
Service discovery#
Guide: Service discovery.
- GET
/api/servicesMarketplace catalogue: q, category, price, network, asset, latency, verification, sort, cursor.
Key: services:read · 120/min
- GET
/api/services/:idOne service by id or slug: endpoints, pricing, payment methods, 30-day performance.
Key: services:read · 240/min
- POST
/api/services/registerList an x402 endpoint you operate (probed before it is listed).
Key: services:write · session owner/admin
- POST
/api/services/:id/validateRe-run the unpaid-request probe against the stored terms.
Key: services:write · session owner/admin
- GET
/api/providerYour own services with revenue and request statistics.
Key: analytics:read · 120/min
- GET
/api/provider/requestsRequests made to your services, with their payment.
Key: analytics:read · 120/min
- GET
/api/leaderboardPublic agent leaderboard (opt-in agents only).
Public
Payments#
Guide: Payments.
- POST
/api/services/requestIdempotency-KeyOne call: x402 challenge → quote → ten checks → pay → deliver (or stop for approval).
Key: payments:write · 60/min
- GET
/api/services/requests/:idCurrent state and timeline of one service request.
Key: payments:read
- POST
/api/payments/quoteIdempotency-KeyRead the x402 challenge, store a 5-minute quote and preview the decision. Nothing is charged.
Key: payments:write · 120/min
- POST
/api/payments/verifyRe-check settlement for { paymentId }.
Key: payments:read · 60/min
- GET
/api/payments/:idOne payment, its settlement record and the request timeline.
Key: payments:read
- POST
/api/payments/:id/signatureLive payments: the paying wallet's EIP-712 signature { signature } for an approved payment. CortexPay verifies it, sends it to the provider and checks the settlement on chain.
Session · owner/admin · 30/min · Only the signed-in wallet that pays may submit; an API key never can.
- POST
/api/orgs/freezeWorkspace-wide emergency stop for new payment authorizations.
Session · owner/admin · 20/min
- GET
/api/gateway/requestsAPI Gateway request history (range, outcome, cursor).
Key: payments:read · 120/min
- GET
/api/gateway/statsAPI Gateway dashboard numbers for a range.
Key: analytics:read · 120/min
- GET
/api/gateway/playgroundPlayground setup: sandbox services, the workspace's agents with their policy, and whether this caller can run a request.
Key: payments:read · 120/min
- POST
/api/gateway/playgroundIdempotency-KeyDemonstration mode { agentId, serviceId, input? }: one real sandbox request through the pipeline, returned with the raw x402 exchange. Sandbox workspaces and sandbox services only.
Key: payments:write · 20/min
- POST
/api/gateway/inspectVerified live mode { url, method? }: one unpaid request to a public https URL; its x402 challenge is decoded and judged. Nothing is signed or paid.
Key: payments:read · 20/min
Agent tasks & escrow#
Guide: Agent tasks & escrow.
- GET
/api/tasks/discoverAgent-provided services a requester can hire (?requester=<agentId>; never its own), with escrow availability.
Key: payments:read · 120/min
- GET
/api/tasksTasks, newest first, with a summary (?status=all|open|completed|cancelled&limit=&cursor=).
Key: payments:read · 120/min
- POST
/api/tasksIdempotency-KeyHire an agent-provided service { requesterAgentId, serviceId, description, input?, escrow? }: records the task and quotes it. Nothing is paid.
Key: payments:write · 30/min
- GET
/api/tasks/:idThe task with its request, quote, policy decision, approval, payment, delivery, escrow and the actions allowed now.
Key: payments:read · 240/min
- POST
/api/tasks/:id/quoteIdempotency-KeyA fresh quote after the last one expired or the last attempt ended unpaid.
Key: payments:write · 30/min
- POST
/api/tasks/:id/payIdempotency-KeyRun the ten checks on the open quote and pay (202 when an owner must approve). Escrow tasks get their hold first.
Key: payments:write · 30/min
- POST
/api/tasks/:id/completeCompletion record { note? } after delivery. With held escrow it also releases the funds, which needs an owner or admin session.
Key: payments:write · 30/min
- POST
/api/tasks/:id/cancelClose a task whose payment never moved { note? }. Settled payments cannot be cancelled.
Key: payments:write · 30/min
- POST
/api/tasks/:id/approvalDecide the task's pending approval { decision: approve|reject, note? }.
Session · owner/admin · 30/min · Never an API key.
- POST
/api/escrow/:id/releaseSandbox escrow (simulated): credit the provider with a held or disputed amount { note? }.
Session · owner/admin · 30/min · Never an API key.
- POST
/api/escrow/:id/refundSandbox escrow (simulated): return a held or disputed amount to the requester { note? }; closes the task.
Session · owner/admin · 30/min · Never an API key.
- POST
/api/escrow/:id/disputeSandbox escrow (simulated): contest a held payment { note } (required). Completion can no longer release it.
Session · owner/admin · 30/min · Never an API key.
Approvals#
Guide: Approvals.
- GET
/api/approvalsApproval requests (status=pending|approved|rejected|expired|all; cursor).
Key: payments:read
- GET
/api/approvals/:idNot available yetOne approval request.
Key: payments:read · Use GET /api/approvals?status=all and match the id.
- POST
/api/approvals/:id/approveApprove { note? }: re-quotes, re-runs the checks and pays.
Session · owner/admin · Owners and admins in a signed-in session only; never an API key.
- POST
/api/approvals/:id/rejectReject { note? }. No funds move.
Session · owner/admin · Owners and admins in a signed-in session only; never an API key.
Transactions#
Guide: Transactions.
- GET
/api/transactionsThe transaction terminal: filters, sorting, cursor pagination.
Key: payments:read · 120/min
- GET
/api/transactions/:idOne payment with quote, fees, decision, authorization, timeline and delivery.
Key: payments:read
- GET
/api/transactions/exportThe same filters as a CSV or JSON file (?format=csv|json).
Key: payments:read · 12/min
- POST
/api/transactions/:id/receiptPublish a shareable receipt at /r/<slug> (settled, non-seeded payments).
Key: payments:write · 30/min
- DELETE
/api/transactions/:id/receiptTake the public receipt down.
Key: payments:write · 30/min
- GET
/api/searchSearch agents, services, policies and payments in the workspace.
Any key
- GET
/api/notificationsThe 30 most recent notifications in the workspace.
Any key
- POST
/api/notifications/readMark notifications (or all) as read.
Any key
Analytics & AI#
Guide: Analytics & AI.
- GET
/api/analytics/expenditureExpenditure figures (?range=1h|24h|7d|30d|all&agentId=).
Key: analytics:read · 120/min
- GET
/api/overviewCommand-centre metrics for a range.
Key: analytics:read
- GET
/api/analytics/reportsStored AI financial reports, newest first.
Key: analytics:read · key's rate limit
- POST
/api/analytics/reportsBuild a report { range } from a fact sheet (AI; needs ai:use).
Key: ai:use · 3/min
- GET
/api/analytics/reports/:idOne stored report.
Key: analytics:read · key's rate limit
- GET
/api/ai/chatWhether the assistant can answer now and what it costs.
Key: ai:use · key's rate limit
- POST
/api/ai/chatAsk Cortex Intelligence { messages } (read-only tools).
Key: ai:use · 10/min
- GET
/api/weeklyThe public Weekly Cortex Report (?week=YYYY-MM-DD).
Public
Network activity#
Guide: Network activity.
- GET
/api/network/activityWorkspace network events (kind, agent, service, network, asset, since, until, cursor, after).
Key: payments:read
- GET
/api/network/activity/graphAgent and service nodes with payment edges for a range.
Key: payments:read
- GET
/api/network/activity/requestsService requests between an agent and a service.
Key: payments:read
- GET
/api/network/streamServer-Sent Events tail of network events (?after=<id>).
Key: payments:read · 30/min
- GET
/api/network/statusPublic RPC health for HyperEVM and Elysium and whether live payments are on.
Public
Webhooks#
Guide: Webhooks.
- GET
/api/webhooks/eventsEvent types with example payloads, signature format and retry schedule.
Public
- GET
/api/webhooksEndpoints with 7-day delivery stats.
Key: webhooks:write
- POST
/api/webhooks/registerRegister { url, events[], description?, applicationId? }. Returns the whsec_ secret once.
Key: webhooks:write · session owner/admin · 20/min
- GET
/api/webhooks/:idOne endpoint.
Key: webhooks:write
- PATCH
/api/webhooks/:id{ url?, events?, description?, status?, applicationId? }.
Key: webhooks:write · session owner/admin · 60/min
- DELETE
/api/webhooks/:idRemove the endpoint and its delivery history.
Key: webhooks:write · session owner/admin
- POST
/api/webhooks/:id/testQueue and immediately attempt a signed webhook.test delivery.
Key: webhooks:write · session owner/admin · 10/min
- POST
/api/webhooks/:id/rotate-secretReplace the signing secret now; the new whsec_ is returned once.
Key: webhooks:write · session owner/admin · 10/min
- GET
/api/webhooks/deliveriesRecent deliveries (?webhookId=&status=&limit=), with status codes.
Key: webhooks:write
Infrastructure credits#
Guide: Infrastructure credits.
- GET
/api/credits/balanceCredit balance, what each action costs and 30-day usage. Any key, no scope.
Any key
- GET
/api/credits/transactionsCredit ledger, newest first (?reason=&limit=&cursor=).
Any key
- POST
/api/credits/topupFree sandbox allowance (+500, at most 5 per 24 h, capped at 5,000).
Session · 10/min
Workspace & members#
- GET
/api/settings/workspaceThe active workspace: name, mode, your role, freeze state, guest expiry.
Session
- PATCH
/api/settings/workspaceRename { name } (audited). The mode cannot change.
Session · owner/admin · 20/min
- GET
/api/settings/preferencesYour preferences (they follow you across workspaces).
Session
- PATCH
/api/settings/preferences{ timeRange?, notifications? }.
Session · 60/min
- GET
/api/settings/sessionsYour active sessions (device label only; no IPs stored).
Session
- DELETE
/api/settings/sessions/:idSign out one other session.
Session · 20/min
- POST
/api/settings/sessions/revoke-othersSign out everywhere except this browser.
Session · 20/min
- GET
/api/settings/walletsWallets connected to your account (addresses only).
Session
- POST
/api/settings/leaveLeave the active workspace (never the last owner or your last workspace).
Session · 10/min
- GET
/api/membersEveryone in the workspace with their role.
Session
- POST
/api/membersAdd an existing CortexPay wallet user { address, role }.
Session · owner · 20/min
- PATCH
/api/members/:userIdChange a role { role }. Never demotes the last owner.
Session · owner · 30/min
- DELETE
/api/members/:userIdRemove a member. Never the last owner.
Session · owner · 30/min
x402 sandbox resources#
Guide: x402 sandbox resources.
- GET
/x402/sandbox/:slugA sandbox x402 resource: 402 with PAYMENT-REQUIRED, or the paid response with PAYMENT-RESPONSE.
Public · 120/min per IP
- POST
/x402/sandbox/:slugSame resource with a JSON body (≤ 16 KB).
Public · 120/min per IP
x402 facilitator (mainnet)#
Guide: x402 facilitator (mainnet).
- GET
/api/x402/facilitator/supportedx402 v2 discovery: the exact-scheme networks this facilitator can settle right now (only those where it holds gas).
Public
- POST
/api/x402/facilitator/verifyx402 v2 verify { x402Version, paymentPayload, paymentRequirements } → { isValid, invalidReason?, payer? }. Nothing is broadcast.
Key: services:write · 240/min · API key from a live workspace only (sessions and sandbox keys are refused).
- POST
/api/x402/facilitator/settlex402 v2 settle: re-verifies, simulates, broadcasts and waits for the receipt → { success, transaction, network, payer }. CortexPay pays gas; the tokens move from the payer to payTo.
Key: services:write · 120/min · API key from a live workspace only. Daily settlement caps apply per deployment and per workspace.
Status#
- GET
/api/healthLiveness: database reachability and when the background worker last reported. 503 when the database is down.
Public