Core concepts
Agents
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);| Field | Rules |
|---|---|
name | 2–60 characters. |
category | research, 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. |
description | Optional, up to 500 characters. |
externalId | Optional id from your own system, up to 120 characters of letters, digits and . _ : / @ # -. |
capabilities | Up to 8 short lowercase tags (a-z, 0-9, -). |
initialBudget | Sandbox only. Decimal dollars of simulated sUSDC, for example "25" or "0.50". |
policy | One of the three kinds below. |
approvedServiceIds | Up 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.kind | What happens |
|---|---|
template | A 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. |
existing | The agent joins a policy you already have (policyId). Approved services come from that policy, so approvedServiceIds must be empty. |
custom | A 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/fundand/withdraw{ amount, memo? }. Both need a signed-in owner or admin and anIdempotency-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
initialBudgetor a top-up returns422 live_funding_unavailable, and a withdrawal422 live_withdrawal_unavailable.
Pause, resume, revoke#
| Action | Effect | Who |
|---|---|---|
pause | New 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 |
resume | The agent can pay again within its policy. | Owner/admin session only, so an agent cannot un-pause itself |
revoke | Permanent. 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);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/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