Core concepts

Service discovery

Agents find paid services in the CortexPay marketplace. Every listing carries its x402 payment terms, so an agent knows the price, network and asset before it asks to pay.
Code samples in

The catalogue#

GET /api/services returns the services this workspace can see: public listings plus the workspace's own. Each listing has a payable field, { now, reason }, that says whether this workspace can pay it right now and why not. Sandbox workspaces can pay sandbox services only: real x402 endpoints on this deployment that accept simulated payments.

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

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

const page = await cortex.services.list({ category: ["data", "research"], maxPrice: "0.10", sort: "price_asc", limit: 10 });
console.log(page.total, page.data.map((s) => s.name));

The response is { data, total, catalogueSize, facets, filters, nextCursor }. Latency and availability come from real (not seeded) requests over the last 30 days and are null until there is data.

Filters#

All filters are optional. List filters take comma-separated values.

ParameterValues
qWords matched against name, summary, slug, category and provider (up to 120 characters).
categoryinference, llm, image, data, finance, chain_analytics, research, storage, compute, devtools, agent
minPrice, maxPriceUSD amounts, for example 0.05.
networksandbox, hyperevm, elysium
assetsUSDC, USDC
maxLatencyMsCeiling on the median (p50) latency, in milliseconds. Services without data are excluded.
providerVerificationunverified, domain_verified, reviewed
pricingModelfixed, usage, tiered, quote
availabilitypending, operational, degraded, offline, rejected
sourceall (default), agent, sandbox, own
sortfeatured (default), price_asc, price_desc, latency, name, newest
limit, cursor1–100 (default 50); pass nextCursor back as cursor.

One service#

GET /api/services/:id accepts an id or a slug and returns { service, endpoints, pricingHistory, paymentMethods, performance, yourUsage, … }: the listing, how each network is paid, and 30-day performance from real requests. service.id is what you pass as serviceId when you pay for a request.

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

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

const detail = await cortex.services.get("SERVICE_ID_OR_SLUG");
console.log(detail.service.name, detail.service.payable, detail.paymentMethods);

Listing your own service#

Any HTTPS endpoint that answers an unpaid request with a valid x402 402 can be listed with POST /api/services/register. CortexPay probes it before it is listed:

  1. The URL must be public HTTPS. Private, loopback and link-local addresses are refused before any request is made.
  2. Called without payment, the endpoint must answer 402 with a valid x402 v2 challenge (exact scheme) on every declared network, in that network's verified stablecoin, paying the declared recipient the declared price, in a form CortexPay can sign.
  3. A service that passes becomes operational with the endpoint_validated level. One that fails is saved as pending, private and unverified; fix it and call POST /api/services/:id/validate.
  4. Sandbox workspaces list privately. Public listing is for live workspaces.

Send "dryRun": true to run the probe without saving anything. Registration is limited to 5 attempts per 10 minutes per user and 20 per day per workspace.

Register and validate need a signed-in owner or admin, or an API key with the services:write scope (only owners and admins can create keys).

Provider statistics

GET /api/provider lists your services with revenue and request counts; GET /api/provider/requests lists the requests made to them. Both need analytics:read.

Endpoints#

  • 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