Reference

API reference

Every endpoint this deployment serves, grouped by area. A test checks this list against the code, so an endpoint is listed here only if it exists, with the scope, idempotency and rate limit it really enforces.
Code samples in

Conventions#

TopicRule
Base URLhttps://cortexpay.vercel.app
AuthenticationSession cookie, or Authorization: Bearer cpk_…. See Authentication.
BodiesJSON in and out. Field names are camelCase; webhook payloads are snake_case.
MoneyStrings of integer base units (1 USDC = 1000000), named …Base or amount. Inputs that take dollars say so (for example initialBudget: "25").
TimesISO 8601 in UTC.
ListsNewest 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/guest

    Start a guest session with a seeded sandbox workspace, then redirect to ?next=.

    Public

  • POST/api/auth/nonce

    Single-use nonce for a Sign-In with Ethereum message (valid 10 minutes).

    Public

  • POST/api/auth/verify

    Verify a signed SIWE message { message, signature } and start a wallet session (cookie).

    Public

  • POST/api/auth/logout

    Revoke the current session and clear the cookie.

    Public

  • GET/api/me

    The caller, the active workspace and which platform features are configured.

    Any key

  • POST/api/orgs/switch

    Make 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/keys

    API keys in the active workspace (prefix only).

    Session

  • POST/api/keys

    Create a key { name, scopes, expiresInDays?, applicationId?, rateLimitPerMin? }. The secret is returned once.

    Session · owner/admin · 20/min

  • GET/api/keys/:id

    One key (prefix, scopes, last use).

    Session

  • PATCH/api/keys/:id

    Rename or change the per-minute limit. Scopes are fixed.

    Session · owner/admin · 60/min

  • DELETE/api/keys/:id

    Revoke now (audited). The next request with the key gets 401.

    Session · owner/admin · 60/min

  • GET/api/applications

    Registered applications with key and webhook counts.

    Session

  • POST/api/applications

    Register an application { name, description? }.

    Session · owner/admin · 20/min

  • GET/api/applications/:id

    One 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/:id

    Delete an application that never had a key.

    Session · owner/admin

Agents#

Guide: Agents.

  • GET/api/agents

    Agents in the workspace (status, category, q filters; cursor pagination).

    Key: agents:read · key's rate limit

  • POST/api/agents/registerIdempotency-Key

    Register an agent with its CortexID, delegated permission and spending policy. Costs 10 credits.

    Key: agents:write · session owner/admin · 20/min

  • GET/api/agents/:id

    Full agent profile: identity, policy, budget, permissions, services, ledger.

    Key: agents:read · key's rate limit

  • PATCH/api/agents/:id

    Rename, describe, re-avatar, set externalId or move to another policy.

    Key: agents:write · session owner/admin · 60/min

  • POST/api/agents/:id/pause

    Stop new payments now; unsettled authorizations are revoked. Body { reason? }.

    Key: agents:write · session owner/admin · 30/min

  • POST/api/agents/:id/resume

    Re-enable spending.

    Session · owner/admin · 30/min · Never an API key, so an agent cannot un-pause itself.

  • POST/api/agents/:id/revoke

    Permanent. Body { confirm: true, reason? }.

    Key: agents:write · session owner/admin · 30/min

  • PATCH/api/agents/:id/identity

    Public profile toggle, public fields, leaderboard opt-in, capability tags.

    Key: agents:write · session owner/admin · 60/min

  • POST/api/agents/:id/verify

    Raise the CortexID verification level.

    Key: agents:write · session owner/admin · 20/min

  • GET/api/agents/:id/account

    Account, balances, spend windows and available budget.

    Key: agents:read · key's rate limit

  • GET/api/agents/:id/transactions

    Payments made and received, newest first.

    Key: agents:read · key's rate limit

  • GET/api/agents/:id/analytics

    Daily spend (UTC), top services, rejection reasons, latency.

    Key: agents:read · key's rate limit

  • POST/api/agents/:id/fundIdempotency-Key

    Sandbox top-up in simulated sUSDC (capped).

    Session · owner/admin · 20/min

  • POST/api/agents/:id/withdrawIdempotency-Key

    Owner-authorized withdrawal (sandbox: simulated ledger transfer).

    Session · owner/admin · 20/min

Spending policies#

Guide: Spending policies.

  • GET/api/policies

    Spending policies with current rules and the agents using them.

    Key: policies:read · key's rate limit

  • POST/api/policiesIdempotency-Key

    Same as POST /api/policies/create.

    Key: policies:write · session owner/admin · 30/min

  • POST/api/policies/createIdempotency-Key

    Create a policy (version 1) { name, description?, templateKey?, rules, notes? }.

    Key: policies:write · session owner/admin · 30/min

  • GET/api/policies/:id

    Policy with current rules, version history (with diffs) and agents.

    Key: policies:read · key's rate limit

  • PATCH/api/policies/:id

    Rename, describe, archive or restore; new rules publish a new version.

    Key: policies:write · session owner/admin · 30/min

  • GET/api/policies/:id/versions

    Version history, newest first, with diffs.

    Key: policies:read · key's rate limit

  • POST/api/policies/:id/versions

    Publish new rules as version N+1 { rules, baseVersion, notes? }.

    Key: policies:write · session owner/admin · 30/min

  • POST/api/policies/evaluate

    Dry run of the ten checks for { agentId, serviceId, amount? }. Records nothing.

    Key: policies:read · 60/min

  • DELETE/api/agents/:id/services/:serviceId

    Emergency removal of an approved service (new policy version).

    Key: policies:write · session owner/admin · 30/min

Service discovery#

Guide: Service discovery.

  • GET/api/services

    Marketplace catalogue: q, category, price, network, asset, latency, verification, sort, cursor.

    Key: services:read · 120/min

  • GET/api/services/:id

    One service by id or slug: endpoints, pricing, payment methods, 30-day performance.

    Key: services:read · 240/min

  • POST/api/services/register

    List an x402 endpoint you operate (probed before it is listed).

    Key: services:write · session owner/admin

  • POST/api/services/:id/validate

    Re-run the unpaid-request probe against the stored terms.

    Key: services:write · session owner/admin

  • GET/api/provider

    Your own services with revenue and request statistics.

    Key: analytics:read · 120/min

  • GET/api/provider/requests

    Requests made to your services, with their payment.

    Key: analytics:read · 120/min

  • GET/api/leaderboard

    Public agent leaderboard (opt-in agents only).

    Public

Payments#

Guide: Payments.

  • POST/api/services/requestIdempotency-Key

    One call: x402 challenge → quote → ten checks → pay → deliver (or stop for approval).

    Key: payments:write · 60/min

  • GET/api/services/requests/:id

    Current state and timeline of one service request.

    Key: payments:read

  • POST/api/payments/quoteIdempotency-Key

    Read the x402 challenge, store a 5-minute quote and preview the decision. Nothing is charged.

    Key: payments:write · 120/min

  • POST/api/payments/authorizeIdempotency-Key

    Run the ten checks on a quote { quoteId, execute? } and pay when they pass.

    Key: payments:write · 60/min

  • POST/api/payments/verify

    Re-check settlement for { paymentId }.

    Key: payments:read · 60/min

  • GET/api/payments/:id

    One payment, its settlement record and the request timeline.

    Key: payments:read

  • POST/api/payments/:id/signature

    Live 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/freeze

    Workspace-wide emergency stop for new payment authorizations.

    Session · owner/admin · 20/min

  • GET/api/gateway/requests

    API Gateway request history (range, outcome, cursor).

    Key: payments:read · 120/min

  • GET/api/gateway/stats

    API Gateway dashboard numbers for a range.

    Key: analytics:read · 120/min

  • GET/api/gateway/playground

    Playground 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-Key

    Demonstration 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/inspect

    Verified 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/discover

    Agent-provided services a requester can hire (?requester=<agentId>; never its own), with escrow availability.

    Key: payments:read · 120/min

  • GET/api/tasks

    Tasks, newest first, with a summary (?status=all|open|completed|cancelled&limit=&cursor=).

    Key: payments:read · 120/min

  • POST/api/tasksIdempotency-Key

    Hire 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/:id

    The 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-Key

    A fresh quote after the last one expired or the last attempt ended unpaid.

    Key: payments:write · 30/min

  • POST/api/tasks/:id/payIdempotency-Key

    Run 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/complete

    Completion 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/cancel

    Close a task whose payment never moved { note? }. Settled payments cannot be cancelled.

    Key: payments:write · 30/min

  • POST/api/tasks/:id/approval

    Decide the task's pending approval { decision: approve|reject, note? }.

    Session · owner/admin · 30/min · Never an API key.

  • POST/api/escrow/:id/release

    Sandbox 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/refund

    Sandbox 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/dispute

    Sandbox 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/approvals

    Approval requests (status=pending|approved|rejected|expired|all; cursor).

    Key: payments:read

  • GET/api/approvals/:idNot available yet

    One approval request.

    Key: payments:read · Use GET /api/approvals?status=all and match the id.

  • POST/api/approvals/:id/approve

    Approve { 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/reject

    Reject { 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/transactions

    The transaction terminal: filters, sorting, cursor pagination.

    Key: payments:read · 120/min

  • GET/api/transactions/:id

    One payment with quote, fees, decision, authorization, timeline and delivery.

    Key: payments:read

  • GET/api/transactions/export

    The same filters as a CSV or JSON file (?format=csv|json).

    Key: payments:read · 12/min

  • POST/api/transactions/:id/receipt

    Publish a shareable receipt at /r/<slug> (settled, non-seeded payments).

    Key: payments:write · 30/min

  • DELETE/api/transactions/:id/receipt

    Take the public receipt down.

    Key: payments:write · 30/min

  • GET/api/notifications

    The 30 most recent notifications in the workspace.

    Any key

  • POST/api/notifications/read

    Mark notifications (or all) as read.

    Any key

Analytics & AI#

Guide: Analytics & AI.

  • GET/api/analytics/expenditure

    Expenditure figures (?range=1h|24h|7d|30d|all&agentId=).

    Key: analytics:read · 120/min

  • GET/api/overview

    Command-centre metrics for a range.

    Key: analytics:read

  • GET/api/analytics/reports

    Stored AI financial reports, newest first.

    Key: analytics:read · key's rate limit

  • POST/api/analytics/reports

    Build a report { range } from a fact sheet (AI; needs ai:use).

    Key: ai:use · 3/min

  • GET/api/analytics/reports/:id

    One stored report.

    Key: analytics:read · key's rate limit

  • GET/api/ai/chat

    Whether the assistant can answer now and what it costs.

    Key: ai:use · key's rate limit

  • POST/api/ai/chat

    Ask Cortex Intelligence { messages } (read-only tools).

    Key: ai:use · 10/min

  • GET/api/weekly

    The public Weekly Cortex Report (?week=YYYY-MM-DD).

    Public

Network activity#

Guide: Network activity.

  • GET/api/network/activity

    Workspace network events (kind, agent, service, network, asset, since, until, cursor, after).

    Key: payments:read

  • GET/api/network/activity/graph

    Agent and service nodes with payment edges for a range.

    Key: payments:read

  • GET/api/network/activity/requests

    Service requests between an agent and a service.

    Key: payments:read

  • GET/api/network/stream

    Server-Sent Events tail of network events (?after=<id>).

    Key: payments:read · 30/min

  • GET/api/network/status

    Public RPC health for HyperEVM and Elysium and whether live payments are on.

    Public

Webhooks#

Guide: Webhooks.

  • GET/api/webhooks/events

    Event types with example payloads, signature format and retry schedule.

    Public

  • GET/api/webhooks

    Endpoints with 7-day delivery stats.

    Key: webhooks:write

  • POST/api/webhooks/register

    Register { url, events[], description?, applicationId? }. Returns the whsec_ secret once.

    Key: webhooks:write · session owner/admin · 20/min

  • GET/api/webhooks/:id

    One endpoint.

    Key: webhooks:write

  • PATCH/api/webhooks/:id

    { url?, events?, description?, status?, applicationId? }.

    Key: webhooks:write · session owner/admin · 60/min

  • DELETE/api/webhooks/:id

    Remove the endpoint and its delivery history.

    Key: webhooks:write · session owner/admin

  • POST/api/webhooks/:id/test

    Queue and immediately attempt a signed webhook.test delivery.

    Key: webhooks:write · session owner/admin · 10/min

  • POST/api/webhooks/:id/rotate-secret

    Replace the signing secret now; the new whsec_ is returned once.

    Key: webhooks:write · session owner/admin · 10/min

  • GET/api/webhooks/deliveries

    Recent deliveries (?webhookId=&status=&limit=), with status codes.

    Key: webhooks:write

Infrastructure credits#

Guide: Infrastructure credits.

  • GET/api/credits/balance

    Credit balance, what each action costs and 30-day usage. Any key, no scope.

    Any key

  • GET/api/credits/transactions

    Credit ledger, newest first (?reason=&limit=&cursor=).

    Any key

  • POST/api/credits/topup

    Free sandbox allowance (+500, at most 5 per 24 h, capped at 5,000).

    Session · 10/min

Workspace & members#

  • GET/api/settings/workspace

    The active workspace: name, mode, your role, freeze state, guest expiry.

    Session

  • PATCH/api/settings/workspace

    Rename { name } (audited). The mode cannot change.

    Session · owner/admin · 20/min

  • GET/api/settings/preferences

    Your preferences (they follow you across workspaces).

    Session

  • PATCH/api/settings/preferences

    { timeRange?, notifications? }.

    Session · 60/min

  • GET/api/settings/sessions

    Your active sessions (device label only; no IPs stored).

    Session

  • DELETE/api/settings/sessions/:id

    Sign out one other session.

    Session · 20/min

  • POST/api/settings/sessions/revoke-others

    Sign out everywhere except this browser.

    Session · 20/min

  • GET/api/settings/wallets

    Wallets connected to your account (addresses only).

    Session

  • POST/api/settings/leave

    Leave the active workspace (never the last owner or your last workspace).

    Session · 10/min

  • GET/api/members

    Everyone in the workspace with their role.

    Session

  • POST/api/members

    Add an existing CortexPay wallet user { address, role }.

    Session · owner · 20/min

  • PATCH/api/members/:userId

    Change a role { role }. Never demotes the last owner.

    Session · owner · 30/min

  • DELETE/api/members/:userId

    Remove a member. Never the last owner.

    Session · owner · 30/min

x402 sandbox resources#

Guide: x402 sandbox resources.

  • GET/x402/sandbox/:slug

    A sandbox x402 resource: 402 with PAYMENT-REQUIRED, or the paid response with PAYMENT-RESPONSE.

    Public · 120/min per IP

  • POST/x402/sandbox/:slug

    Same resource with a JSON body (≤ 16 KB).

    Public · 120/min per IP

x402 facilitator (mainnet)#

Guide: x402 facilitator (mainnet).

  • GET/api/x402/facilitator/supported

    x402 v2 discovery: the exact-scheme networks this facilitator can settle right now (only those where it holds gas).

    Public

  • POST/api/x402/facilitator/verify

    x402 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/settle

    x402 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/health

    Liveness: database reachability and when the background worker last reported. 503 when the database is down.

    Public