Developer portal

The APEX API,
for your engineers.

Everything on this site is available programmatically. Scoped keys, idempotent requests, signed webhooks, and a test environment that models the failure modes most providers can't demo.

The API is the product, not an afterthought - the console you see is built on the same endpoints you will call. API keys are scoped by role so a reporting worker never carries payment authority, and plaintext secrets are shown exactly once at creation. Every write accepts an idempotency key, so a retried request replays its original result instead of duplicating the operation - the difference between a safe retry and a double charge.

Webhook deliveries are signed so you can verify they came from us, retried on a schedule until your endpoint answers, and replayable through the console when your side has a bad day. The sandbox environment goes further than most: deterministic payment methods let you rehearse declines, timeouts, disputes and provider outages on demand, so your error handling is tested against the failures that actually cost money - not just the success path.

Authentication & API keys

Bearer API keys in the Authorization header. Keys are SHA-256 hashed at rest, prefixed for identification (ak_test_ / ak_live_), expirable, and revocable.

# every request Authorization: Bearer ak_test_xxxxxxxxxxxxxxxxxxxxxxxx # create a payment curl -X POST https://payments.codexlabsai.com/v1/payments \ -H "Authorization: Bearer ak_test_…" \ -H "Idempotency-Key: order-1042" \ -H "Content-Type: application/json" \ -d '{"amount":12500,"currency":"USD","payment_method":"sb_ok"}' → 201 {"id":"…","status":"authorized","amount":12500,"currency":"USD"}

Roles map to scope sets - mint keys with the least privilege the integration needs:

owner* - full account access
developerpayments:*, refunds:write, webhooks:*, billing:write, merchants:read
financepayments/payouts/billing/ledger reads + writes, merchants:read
supportpayments:read, merchants:read, refunds:read
read_onlypayments, merchants, payouts, wallets, billing, ledger - read
operatorops:*, payments:read, merchants:read, ledger:read

Cross-merchant access returns 404 - never 403 - so tenant boundaries aren't observable. POST /v1/auth/signup creates a merchant + first key; /v1/api_keys manages rotation and revocation.

Idempotency

Send Idempotency-Key on any POST. The semantics are Stripe-style and enforced at the storage layer:

Replay

Same key + same payload returns the original response verbatim - safe to retry over flaky networks.

Conflict

Same key + different payload returns 409 - the key can never silently alias two operations.

In-flight

A concurrent duplicate blocks rather than double-executing - the second caller sees the first result.

Webhooks

Events fan out over the transactional outbox - at-least-once delivery, signed, dead-lettered on exhaustion.

  • Subscriptions via GET|POST /v1/webhooks; secrets are platform-generated (whsec_…), shown once at creation.
  • Signature header: X-Apex-Signature: t=<unix>,v1=<hmac-sha256(secret, "t.body")> - verify before trusting, and use the timestamp against replay.
  • Delivery is idempotent on the wire - consumers must be idempotent too; dead-lettered events are inspectable and replayable via ops.
# verify (python) expected = hmac.new(secret, f"{t}.{body}".encode(), hashlib.sha256).hexdigest() assert hmac.compare_digest(expected, v1)

Test tokens

The deterministic test adapter scripts every outcome by payment-method token - including the uncertain paths.

sb_okClean authorization / capture / refund
sb_decline_*Provider decline family
sb_auth_timeout · sb_auth_lostUncertain authorization - drives the reconcile path
sb_capture_fail · sb_capture_timeoutCapture failure and uncertain capture
sb_refund_fail · sb_refund_timeoutRefund failure modes
sb_void_timeoutUncertain void
sb_outageProvider outage
sb_provider_errorGeneric provider error
sb_payout_fail · sb_payout_returned · sb_payout_timeoutPayout failure, return-after-settlement, uncertain send

Run the scripted end-to-end flow yourself: scripts/demo_e2e.py exercises merchant → auth → capture → refund → settle, and scripts/smoke_test.py probes a live deployment.

Endpoint index

The complete /v1 surface. Authenticated routes require a scoped key; ops routes require the operator role.

Identity

POST /v1/auth/signup · /v1/auth/loginMerchant onboarding & key minting
GET /v1/sessionCurrent principal: merchant_id + scopes
GET /v1/merchants/meOwn merchant profile
GET|POST /v1/api_keys · POST /v1/api_keys/{id}/revokeKey management

Payments

POST /v1/paymentsCreate a payment (idempotent)
GET /v1/payments · /v1/payments/{id}List / inspect
GET /v1/payments/{id}/eventsTransition history
POST /v1/payments/{id}/authorize|capture|refund|void|cancel|settle|retry_authorizeLifecycle transitions

Checkout

POST /v1/checkout_sessionsMint a hosted checkout link
GET /v1/checkout/{token}Payer-safe session details
POST /v1/checkout/{token}/completePayer completion (method token only)

Money out & billing

GET|POST /v1/payouts · GET /v1/payouts/{id}Payouts
GET|POST /v1/invoices · GET /v1/invoices/{id}Invoices
POST /v1/invoices/{id}/finalize|voidInvoice lifecycle

Risk

GET|POST /v1/disputes · GET /v1/disputes/{id}Dispute cases
POST /v1/disputes/{id}/evidence|decideEvidence & decisions
GET /v1/fraud/reviews · POST /v1/fraud/reviews/{id}/decideRisk review queue
POST /v1/fraud/rulesDeterministic fraud rules

Webhooks

GET|POST /v1/webhooksSubscriptions + shown-once secrets
POST /v1/webhooks/{id}/disableDisable a subscription

Operations (operator scope)

GET /v1/ops/health · /v1/ops/safety · /v1/ops/providersHealth & provider snapshots
GET /v1/ops/operations · /v1/ops/operations/{id}Coordinated operations journal
GET /v1/ops/outbox · POST /v1/ops/outbox/replayOutbox backlog & replay
GET /v1/ops/recon · /v1/ops/audit · /v1/ops/workersReconciliation, audit, workers
POST /v1/ops/workers/{w}/drain · /v1/ops/windows · /v1/ops/haltDrain, maintenance windows, kill switch
GET|POST /v1/ops/incidents · GET /v1/ops/incidents/{id}/timelineIncident management
POST /v1/ops/incidents/{id}/comment|transitionTimeline & state
POST /v1/ops/copilot/askRead-only ops copilot

Command Nexus (fleet)

POST /v1/command/enroll · /v1/command/enroll-tokensNode enrollment, per-node HMAC
GET /v1/command/nodes · /topology · /gateway/leaderFleet state
POST /v1/command/nodes/{id}/revoke|rotate-secret · /telemetryNode lifecycle
GET|POST /v1/command/tasks · /{id}/dispatch|approve|cancel|result|self-reviewSupervised task pipeline
GET /v1/command/deployments · /audit · /recovery · /repairs · /outbox/classifyFleet operations

System

GET /health · /ready · /metricsLiveness, readiness, counters
/console/* · /public/*Ops console & public pages