corridor-in-a-box

HTTP API

@corridor/service turns the engine library into a service (zero runtime deps, Node http).

POST /payments

Body is a PaymentIntent:

{
  "idempotencyKey": "demo-0001",
  "corridorId": "mx-example",
  "sender": { "id": "sender-1" },
  "recipient": { "id": "recipient-1" },
  "sourceAmount": { "asset": "USDC", "amount": "100.00" }
}

Status code mapping

StatusError / ConditionDescription
200—Payment completed successfully, run state returned, health check ok, or metrics rendered
400invalid payment body, invalid JSONMalformed JSON or invalid PaymentIntent body structure
401unauthorizedMissing or invalid Bearer API key
403KYC_REJECTEDReceiving anchor rejected customer KYC
403PRESETTLE_RECEIVER_NOT_ACCEPTEDThe recipient's SEP-12 status is no longer ACCEPTED at the pre-settle gate; nothing was sent
404unknown corridor, not foundUnknown corridor ID, run key not found (or foreign tenant key), or unmatched route
409IDEMPOTENCY_CONFLICTReplay with conflicting parameters or in-flight payment with same key
409QUOTE_EXPIREDAnchor quote expired before settlement could begin
409KYC_REQUIREDCustomer KYC incomplete or customer action required
409PRESETTLE_TX_MISMATCHThe transaction the anchor opened is not what the engine was about to pay (amount, deposit account or memo); nothing was sent
409PRESETTLE_QUOTE_WINDOWThe firm quote would not survive settle and confirm; nothing was sent
409MANIFEST_CHANGEDCorridor manifest changed since the run started; resume refused before settle
409DRY_RUN_COMPLETEA dryRun: true run passed the pre-settle gate and stopped before settling; nothing was sent. The HTTP API never starts dry runs, so this code only appears from the engine or CLI
413payload too largeRequest body exceeds maxBodyBytes cap (default 64 KiB)
422AMOUNT_INVALIDAmount is not a positive decimal or cannot be settled
422CAPABILITY_MISMATCHAdapter capabilities do not match corridor manifest or settlement strategies
422MANIFEST_INVALIDCorridor manifest validation failed
422PRESETTLE_DESTINATION_UNSAFEDestination account missing, without a trustline, or not authorized; nothing was sent
422PRESETTLE_INSUFFICIENT_FUNDSThe signer's balance cannot cover amount, fee and reserve; nothing was sent
422PRESETTLE_AMOUNT_OUT_OF_RANGEAmount is outside the anchor's or manifest's min/max; nothing was sent
422CORRIDOR_UNPROVENAmount is above the canary cap on a lane that is not yet PROVEN
429rate_limitedToken-bucket rate limit exceeded for client IP or API key
500SETTLEMENT_FAILEDOn-chain Stellar payment transaction failed
500RECONCILE_MISMATCHSettled amounts or assets do not match anchor transaction record
500internalUnexpected server error or unhandled failure fallback
501REFUND_UNSUPPORTEDPayment failed and anchor does not support refund
502QUOTE_UNAVAILABLEOrigin or destination anchor failed to provide a quote
502PRESETTLE_ANCHOR_DRIFTThe anchor's live /info or stellar.toml no longer matches what was verified; nothing was sent
502ANCHOR_UNAVAILABLEUpstream anchor service unreachable or returned an upstream error
503CORRIDOR_HALTEDCircuit breaker is open for this corridor: too many consecutive lane failures. No run was created and nothing was sent to the anchor. Retry is pointless until the lane is reset — see docs/operations.md §7. Non-retryable
503ROUTE_REFUSEDThe resolver would not route the payment (for example an unattested anchor). Well-formed request, no trusted route available
503drainingThe service is shutting down and is refusing new payments
504SETTLEMENT_TIMEOUTStellar network submission timed out
504RECONCILE_STALLEDAnchor transaction polling timed out

Other endpoints

  • GET /payments/:key — current run state (scoped to authenticated tenant).
  • GET /healthz — liveness (public, unmetered).
  • GET /readyz — readiness: 200 when every check passes, 503 while draining or when one fails (public, unmetered).
  • POST /callbacks/sep31/:corridorId — the receiving anchor's signed callback; wakes the reconcile loop for that transaction.
  • GET /metrics — Prometheus text exposition format (public, unmetered; served when metricsText is configured).

Optional bearer API-key auth and an in-memory token-bucket rate limiter are configured on the service context. For more than one replica, inject RedisTokenBucket so the limit holds fleet-wide. The full contract, with every request and response shape, is packages/service/openapi.yaml (OpenAPI 3.1).