API Reference
Complete documentation of all TransX402 REST API endpoints — authentication, merchant management, payment facilitation, sandbox, and more.
Base URL
All hosted requests go to https://api.transx402.com. Local development uses http://localhost:3402.
The chain is determined from your API key prefix (secret or publishable):
| Key Prefix | Type | Chain |
|---|---|---|
ipk_sandbox_ | Secret (server) | Sandbox (CAMP Testnet) |
ipk_live_ | Secret (server) | Production (Base mainnet) |
ipk_pub_sandbox_ | Publishable (browser / CDN) | Sandbox (CAMP Testnet) |
ipk_pub_live_ | Publishable (browser / CDN) | Production (Base mainnet) |
IDRX uses 2 decimals. On-chain and payment-record amount strings are base units (Rp 5,000 → "500000"). Human prices in SDKs are whole IDR ("5000").
Authentication
| Endpoint Group | Auth | Method |
|---|---|---|
/config | None (public) | — |
/facilitate | API Key (X-API-Key) | Secret key, or publishable key with a registered Origin |
/payments/* | Secret API Key | X-API-Key header |
/tokens/* | None (public) | — |
/health | None (public) | — |
/auth/* | Wallet signature | SIWE |
/merchant/* | Session cookie | Set after /auth/login |
/sandbox/* | Secret sandbox API Key | X-API-Key header |
Secret vs publishable: POST /facilitate from a browser (Origin present) must use ipk_pub_* and an Allowed Origin from the dashboard. Secret keys (ipk_sandbox_, ipk_live_) are for merchant backends (@transx402/server, WordPress PHP) with no browser Origin.
Authentication and Registration
POST /auth/register
Register a new merchant account. Requires a SIWE signature to prove wallet ownership.
Request:
Response:
On registration, a sandbox API key is automatically created. Production keys are created separately from the dashboard.
POST /auth/login
Login with wallet signature. Sets a session cookie for dashboard access.
POST /auth/logout
Clear session.
Facilitator config
GET /config
Public chain, token, and x402 capability snapshot. No API key. Clients and @transx402/server load RPC, chainId, IDRX address, decimals, and Permit2 from here — do not hardcode them in app code.
Browsers in server settlement should call this via a same-origin merchant proxy (GET /api/transx402/config), not the facilitator origin (CORS).
Response (shape):
ipk_sandbox_ / ipk_pub_sandbox_ use the sandbox section; ipk_live_ / ipk_pub_live_ use production. Exact rpcUrl / chainId / addresses come from the live facilitator.
Payment Facilitation
POST /facilitate
Process a signed payment authorization. This is the core endpoint called by x402 clients (@transx402/server in canonical mode, or the browser client in settlement: "direct").
Auth: API Key (X-API-Key header). Browser callers must use a publishable key plus Allowed Origins.
Processing pipeline:
- Parse and validate request schema
- Authenticate API key, resolve merchant and environment
- Route to correct chain (sandbox CAMP Testnet or production Base)
- Verify token is in the registry
- Verify Permit2 signature
- Check deadline has not passed
- Check nonce has not been used
- Check payer's IDRX balance
- Check payer's Permit2 allowance
- Simulate transaction
- Submit transaction on-chain
- Wait for confirmation
- Record payment in database
- Fire webhook (async)
- Return transaction hash
Payment Status
GET /payments/:txHash
Post-settlement lookup: check whether TransX402 recorded a payment for this transaction hash. Scoped to the API key's merchant. Use for deferred unlock (e.g. WordPress pay-per-article) or reconciliation after you already have a txHash.
This is not the x402 protocol pre-settlement verify step. Settlement uses combined POST /facilitate (internal verify + settle).
Auth: API Key
Response:
Status values: pending, confirmed, failed
verified is true when status === "confirmed". resource is the content URL from the original payment (use it to match pay-per-article unlocks). resource and description may be null if not provided at settlement.
Deprecated alias: GET /verify/:txHash returns the same response with a Deprecation: true header. Prefer /payments/:txHash.
GET /payments
List payments for the authenticated merchant.
Auth: API Key
Query parameters:
| Param | Type | Description |
|---|---|---|
page | number | Page number (default: 1) |
limit | number | Items per page (default: 20, max: 100) |
status | string | Filter by status |
from | string | Filter by payer address |
since | ISO date | Filter payments after this date |
until | ISO date | Filter payments before this date |
Response:
Merchant Profile
GET /merchant/me
Get the current merchant profile.
Auth: Session cookie
PATCH /merchant/me
Update merchant profile.
Auth: Session cookie
Request:
GET /merchant/stats
Get payment statistics.
Auth: Session cookie
Response:
API Key Management
POST /merchant/api-keys
Create a new API key.
Auth: Session cookie
Request:
Response:
Important: The full key field is only returned once at creation. Store it securely.
GET /merchant/api-keys
List all API keys (shows prefix, label, environment, last used — never the full key).
Auth: Session cookie
DELETE /merchant/api-keys/:id
Revoke an API key.
Auth: Session cookie
Sandbox Utilities
These endpoints are only accessible with sandbox API keys.
POST /sandbox/fund
Fund a test wallet with IDRX or ETH on the sandbox chain. Optional token
defaults to "IDRX". For IDRX, amount is whole IDRX (same as whole IDR), default cap 100000 per request. Use "ETH" with a decimal amount such as "0.01".
Auth: Secret sandbox API Key (ipk_sandbox_... only)
Request (IDRX):
Request (ETH):
Response:
POST /sandbox/reset
Re-fork the Anvil sandbox from the latest Base mainnet block. Returns 409 sandbox_operation_unsupported on hosted CAMP (treasury) sandbox.
Auth: Secret sandbox API Key
GET /sandbox/wallets
List Anvil deterministic test wallets. Returns 409 on hosted CAMP (treasury) sandbox.
Response:
These are Anvil's deterministic accounts — safe to expose in sandbox only.
Token Information
GET /tokens
List all supported tokens.
Auth: None
GET /tokens/:symbol/price
Get current price information for a token.
Auth: None
Response:
Health Check
GET /health
Auth: None
Response:
Error Format
All errors follow a consistent format:
Error Codes
| Code | HTTP Status | Description |
|---|---|---|
invalid_signature | 400 | Permit2 signature verification failed |
insufficient_balance | 400 | Payer doesn't have enough tokens |
no_permit2_approval | 400 | Payer hasn't approved Permit2 contract |
expired_deadline | 400 | Payment authorization has expired |
unsupported_token | 400 | Token not in registry |
unsupported_network | 400 | Network not supported for this token |
simulation_failed | 400 | Transaction simulation reverted |
tx_failed | 500 | On-chain transaction reverted |
rate_limited | 429 | Too many requests |
unauthorized | 401 | Invalid or missing API key |
Rate Limits
| Endpoint | Limit |
|---|---|
POST /facilitate | 60/min per IP |
GET /payments/* | 120/min per API key |
POST /merchants/* | 10/min per IP |
| All others | 120/min per IP |