Core concepts

Agents

An agent is a software worker that can pay for services. Each one has a CortexID, its own account, a spend permission delegated by the workspace owner and exactly one spending policy.
Code samples in

Register an agent#

POST /api/agents/register creates the agent, its CortexID, its spend permission and, in a sandbox, its simulated sUSDC account, in one transaction. It costs 10 infrastructure credits and needs an Idempotency-Key. With an API key it needs agents:write, which the Agent runtime preset does not include.

import { CortexPay } from "@cortexpay/sdk";

const cortex = new CortexPay({ apiKey: process.env.CORTEXPAY_API_KEY!, baseUrl: "https://cortexpay.vercel.app" });

// An Idempotency-Key is generated for you; pass { idempotencyKey } to control it.
const agent = await cortex.agents.register({
  name: "Research Scout",
  category: "research",
  avatar: { shape: 2, color: "#9CE8D1" },
  capabilities: ["web-research", "summaries"],
  initialBudget: "25", // sandbox only: simulated sUSDC
  policy: { kind: "template", templateKey: "research" },
});
console.log(agent.id, agent.cortexId, agent.creditsCharged);
FieldRules
name2–60 characters.
categoryresearch, trading, data, coding, content, finance, automation, custom
avatar{ shape: 0–5, color } with a colour from the palette: #9CE8D1, #6AA8FF, #E7B65A, #C79BFF, #F08A6A, #5FD0E0, #46D6A0, #F4F6F7.
descriptionOptional, up to 500 characters.
externalIdOptional id from your own system, up to 120 characters of letters, digits and . _ : / @ # -.
capabilitiesUp to 8 short lowercase tags (a-z, 0-9, -).
initialBudgetSandbox only. Decimal dollars of simulated sUSDC, for example "25" or "0.50".
policyOne of the three kinds below.
approvedServiceIdsUp to 50 service ids added to a template or custom policy.

The response (201) is { id, slug, name, cortexId, policyId, accountAddress, initialBudgetBase, creditsCharged, mode }. Amounts ending in Base are integer base units: 1 USDC = 1,000,000.

Choosing its policy#

policy.kindWhat happens
templateA new policy is created from a template: research, api_consumer, coding, data_collection, content, enterprise. It allows the networks and assets of the workspace mode.
existingThe agent joins a policy you already have (policyId). Approved services come from that policy, so approvedServiceIds must be empty.
customA new policy from full rules (and an optional name). See the rules.

Sandbox budget#

  • An initial budget is at most $250 of simulated sUSDC; one top-up is at most $250; a sandbox agent never holds more than $1,000.
  • Owners top up or withdraw from the agent page, or with POST /api/agents/:id/fund and /withdraw { amount, memo? }. Both need a signed-in owner or admin and an Idempotency-Key; an API key cannot move funds.
  • In a live workspace CortexPay never holds funds and there is nothing to fund: live agents pay from the workspace owner's wallet, and the owner approves and signs each payment. A live registration with initialBudget or a top-up returns 422 live_funding_unavailable, and a withdrawal 422 live_withdrawal_unavailable.

Pause, resume, revoke#

ActionEffectWho
pauseNew payments are refused at once. Payments authorized but not yet settled are cancelled where CortexPay can still stop them. Body { reason? }.Owner/admin session, or a key with agents:write
resumeThe agent can pay again within its policy.Owner/admin session only, so an agent cannot un-pause itself
revokePermanent. Removes every delegated permission, freezes the agent's accounts (the owner can still withdraw), cancels unsettled authorizations and pending approvals, and takes the agent's own services offline. Body { confirm: true, reason? }.Owner/admin session, or a key with agents:write
import { CortexPay } from "@cortexpay/sdk";

const cortex = new CortexPay({ apiKey: process.env.CORTEXPAY_API_KEY!, baseUrl: "https://cortexpay.vercel.app" });

const paused = await cortex.agents.pause("AGENT_ID", { reason: "Investigating unexpected spend" });
console.log(paused.authorizationsRevoked, paused.stillSettleable);
Signed on-chain payments cannot be recalled
A live payment already signed and sent on-chain may still settle until its signature expires. Pause and revoke return stillSettleable and settleableUntil for exactly this case, and those payments keep counting against the budget.

Pausing a paused agent returns 409 already_paused; revoking twice returns 409 already_revoked; any change to a revoked agent returns 409 agent_revoked.

CortexID and verification#

Every agent gets a CortexID (cx_…) with a verification level that only goes up: registered → wallet_verified → service_verified. POST /api/agents/:id/verify with { "level": "wallet_verified" } has the agent's own account sign a binding message, checked on the server. service_verified needs at least one delivered paid request through CortexPay (seeded history does not count). The attested level is not self-service.

Public profile

PATCH /api/agents/:id/identity turns the public profile on or off, chooses which fields are public and opts the agent into the public leaderboard. Profiles are private by default.

Reading an agent#

import { CortexPay } from "@cortexpay/sdk";

const cortex = new CortexPay({ apiKey: process.env.CORTEXPAY_API_KEY!, baseUrl: "https://cortexpay.vercel.app" });

const { data, nextCursor } = await cortex.agents.list({ status: "active", limit: 20 });
for (const a of data) console.log(a.id, a.name, a.status);

Lists are newest first, 50 per page by default (up to 200). Pass the returned nextCursor as cursor for the next page; it is null on the last page.

Endpoints#

  • 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