Plug Your APIs and Deploy
This guide walks from zero to a running Commerce Orchestrator calling your six downstream APIs, with local smoke tests and deployment validation.
Prerequisites
- Rust toolchain (for local run and tests).
- Docker (for container build).
- Kubernetes cluster or Docker Compose for deployment (or run the server locally and point it at stub/mock URLs for development).
- An operating-system CA trust store on the host or image. Outbound HTTPS (providers, OAuth token endpoints, Web Bot Auth key directories) is verified against the platform’s trust store, not a bundled root list. The provided image installs
ca-certificates. If you build a custom image, install it too, or add your private CA there.
1. Downstream API Contracts
The orchestrator calls your services over HTTP. Each base URL must not have a trailing slash. Implement the following endpoints so the integration adapters can call them.
The machine-readable version of this section is the OpenAPI 3.1 spec providers/openapi.yaml. Generate server stubs from it, or load it into your API tooling. A test in the integration-adapters crate checks it against the adapters on every CI run, so it does not drift from what the orchestrator actually sends.
Catalog
| Method | Path | Request | Response (200) |
|---|---|---|---|
GET | {base}/items/{item_id} | — | { "id": "<string>", "title": "<string>", "price_minor": <integer> } |
POST | {base}/catalog/lookup | { "ids": ["<string>"] } | { "products": [ { "id", "title", "price_minor" } ] } |
POST | {base}/catalog/search | { "query": "<string>"? } | { "products": [ { "id", "title", "price_minor" } ] } |
- 404 or non-2xx: item not found or error.
Pricing
| Method | Path | Request (JSON body) | Response (200) |
|---|---|---|---|
POST | {base}/prices/resolve | Cart projection (see adapter) | { "prices": [ { "line_id": "<string>", "unit_price_minor": <int>, "total_minor": <int> } ] } |
POST | {base}/discounts/resolve | { "cart": <cart projection>, "codes": ["<string>"] } | { "discounts": [ { "code": "<string>", "description": "<string>"?, "amount_minor": <int>, "line_id": "<string>"? } ] } |
- Request body is the orchestrator’s cart projection; your service returns one price entry per line.
discounts/resolveprices the buyer’s adjustment codes. Return only the codes you grant; a non-2xx rejects the codes (use it for expired or ineligible campaigns), andamount_minoris positive and is clamped to the amount owed. It is only called when the cart carries at least one code.
Tax
| Method | Path | Request (JSON body) | Response (200) |
|---|---|---|---|
POST | {base}/tax/resolve | Cart projection | { "total_tax_minor": <integer> } |
Geo
| Method | Path | Request (JSON body) | Response (200) |
|---|---|---|---|
POST | {base}/geo/check | { "cart": <CartProjection>, "request": <CheckoutRequest> } | { "allowed": <boolean> } |
- Return
allowed: trueif the cart/request is allowed in the given geography; otherwisefalse.
Payment
| Method | Path | Request (JSON body) | Response (200) |
|---|---|---|---|
POST | {base}/authorize | Checkout request | { "authorized": <boolean>, "reference": "<string>" } |
POST | {base}/capture | Payment lifecycle request | { "success": <boolean>, "reference": "<string>" } |
POST | {base}/void | Payment lifecycle request | { "success": <boolean>, "reference": "<string>" } |
POST | {base}/refund | Payment lifecycle request | { "success": <boolean>, "reference": "<string>" } |
GET | {base}/state/{transaction_id} | — | Optional: `{ “state”: “<authorized |
- For reconciliation, implement
GET .../state/{transaction_id}; if you don’t, the orchestrator treats provider state as unknown.
3DS2 step-up (optional). Set PAYMENT_AUTHENTICATION_ENABLED=true only if your payment service implements these:
| Method | Path | Request (JSON body) | Response (200) |
|---|---|---|---|
POST | {base}/authorize | Checkout request | Add "authentication_required": { "authentication_id", "device_data_collection_url"?, "challenge_url"?, "acquirer_details"?, "directory_server"? } with "authorized": false when the issuer wants 3DS2 first |
GET | {base}/authentication/{authentication_id} | — | { "status": "pending" } or { "status": "completed", "result": { "outcome", "electronic_commerce_indicator"?, "three_ds_cryptogram"?, "transaction_id"?, "version"? } } |
POST | {base}/authentication/{authentication_id}/authorize | { "checkout": <CheckoutRequest>, "result": <AuthenticationResult> }, Idempotency-Key: <checkout key>:authenticated | { "authorized": <boolean>, "reference": "<string>" } |
- The URLs are pages you host that run the 3DS Method and the challenge in the buyer’s browser; EMV 3DS messages never pass through the orchestrator.
acquirer_details(acquirer_bin,acquirer_country,acquirer_merchant_id,merchant_name) anddirectory_server(visa,mastercard,american_express) are what ACP agents need for delegate authentication; without both, ACP sessions show noauthentication_metadata.outcomeuses ACP’s values (authenticated,attempt_acknowledged,denied,rejected,abandoned, …). The orchestrator only calls/authorizeon the authentication forauthenticatedandattempt_acknowledged.- Without the flag, an
authentication_requiredanswer is treated as a decline and 3DS2 is not advertised.
Receipt
| Method | Path | Request (JSON body) | Response (200) |
|---|---|---|---|
POST | {base}/receipts/generate | { "cart": <CartProjection>, "result": <TransactionResult> } | { "content": "<string>" } |
contentis the receipt text or payload your system returns (e.g. PDF URL or plain text).
Fulfillment (optional)
| Method | Path | Request (JSON body) | Response (200) |
|---|---|---|---|
POST | {base}/fulfillment/quote | { "cart": <CartProjection>, "method_type": "shipping"|"pickup", "destination": <destination>, "line_item_ids": ["<string>"] } | { "options": [ { "id", "title", "description"?, "carrier"?, "earliest_fulfillment_time"?, "latest_fulfillment_time"?, "amount_minor" } ] } |
- Without
FULFILLMENT_BASE_URL, the orchestrator quotes its built-in standard, express and pickup options.
Payment delegation (optional)
| Method | Path | Request (JSON body) | Response (200) |
|---|---|---|---|
POST | {base}/delegate_payment | { "tenant_id": "<string>", "token": "<caller token>", "method_type": "<string>?", "max_amount_minor": <int>?, "metadata": { } } | { "id": "<string>", "token": "<delegated token>", "status": "delegated", "expires_at": "<rfc3339>?" } |
- The returned
tokenmust be a new, scoped credential — returning the caller’s own token grants nothing and is not delegation. - The orchestrator forwards
Idempotency-Keyso a retry cannot mint two tokens. - Without
PAYMENT_DELEGATION_BASE_URL,POST /api/v1/acp/delegate_paymentreturns501 NOT_CONFIGUREDand the ACP discovery document omits thedelegate_paymentservice.
Identity linking (optional)
| Method | Path | Request (JSON body) | Response (200) |
|---|---|---|---|
POST | {base}/identity/link | { "tenant_id": "<string>", "merchant_id": "<string>", "agent_id": "<string>", "link_token": "<string>" } | { "link_id": "<string>", "status": "linked", "expires_at": "<rfc3339>?" } |
- Without
IDENTITY_LINK_BASE_URL,POST /api/v1/a2a/identity/linkreturns501 NOT_CONFIGUREDanddev.ucp.common.identity_linkingis absent from discovery. - Without
EMBEDDED_CHECKOUT_URL(or without signing keys),POST /api/v1/ucp/checkout/:id/embedded-linkreturns501 NOT_CONFIGUREDand theembeddedtransport is absent from discovery.
For exact request shapes, see the integration adapter types in the repo (integration-adapters crate) and the wiremock tests under crates/integration-adapters/tests/ (e.g. catalog_http_test.rs, adapters_http_test.rs).
2. Environment Variables
Configure the server with these (see also Consumption guide – Config reference and deploy/README.md).
| Variable | Required (production) | Description | Example |
|---|---|---|---|
ENV | Yes | production enables auth and real adapters. | production |
PUBLIC_BASE_URL | Yes | Public base URL advertised in /.well-known/ucp; required in production to avoid localhost discovery output. | https://orchestrator.example.com |
DATABASE_URL | Yes | PostgreSQL connection string for durable runtime state. | postgres://orchestrator:secret@postgres:5432/orchestrator |
AUTH_MODE | Yes | static or jwt. | static |
AUTH_BEARER_TOKEN | Yes (when AUTH_MODE=static) | Secret token; clients send Authorization: Bearer <token>. | (secret) |
AUTH_JWT_HS256_SECRET | Yes (when AUTH_MODE=jwt) | HS256 secret used to verify JWT tokens. | (secret) |
CATALOG_BASE_URL | Yes | Catalog service base URL, no trailing slash. | http://catalog-service:8080 |
PRICING_BASE_URL | Yes | Pricing service base URL. | http://pricing-service:8080 |
TAX_BASE_URL | Yes | Tax service base URL. | http://tax-service:8080 |
GEO_BASE_URL | Yes | Geo service base URL. | http://geo-service:8080 |
PAYMENT_BASE_URL | Yes | Payment service base URL. | http://payment-service:8080 |
RECEIPT_BASE_URL | Yes | Receipt service base URL. | http://receipt-service:8080 |
UCP_SIGNING_KEY_ID | Yes | Key id advertised in discovery and sent as keyid in Signature-Input. | orch-2026-a |
UCP_SIGNING_KEY | Yes | Base64 32 bytes for the active signing key: an Ed25519 seed, or a P-256 private scalar with UCP_SIGNING_KEY_ALG=ES256. Production refuses to start without it. | (secret) |
UCP_SIGNING_KEY_ALG | No | EdDSA (default) or ES256. ES256 is the algorithm every UCP verifier must support. | ES256 |
UCP_SIGNING_PREVIOUS_KEYS | No | Retired keys still published for verification during rotation, kid:seed or kid:ES256:secret, comma-separated. | orch-2025-b:<seed> |
UCP_AGENT_JWKS | No | Agent public keys as a JWK Set JSON ({"keys":[...]}, Ed25519 or P-256), as agents publish them in their UCP profile. Setting this or UCP_AGENT_KEYS makes inbound RFC 9421 signatures mandatory on /api/v1. | {"keys":[{"kid":"agent-1","kty":"EC",...}]} |
UCP_AGENT_KEYS | No | Ed25519 agent public keys, kid:base64-public-key comma-separated. | agent-1:<public key> |
PAYMENT_DELEGATION_BASE_URL | No | PSP delegation service. Without it POST /api/v1/acp/delegate_payment returns 501 and the ACP delegate_payment service is not advertised. | http://psp-delegation:8080 |
PAYMENT_AUTHENTICATION_ENABLED | No | true when the payment service implements 3DS2 step-up (authentication_required and the /authentication endpoints). Off by default: UCP dev.ucp.common.payment.authentication and the ACP 3ds intervention are not advertised, and a step-up answer is a decline. | true |
IDENTITY_LINK_BASE_URL | No | Identity system for agent identity linking. Without it identity linking returns 501 and dev.ucp.common.identity_linking is not advertised. | http://identity:8080 |
EMBEDDED_CHECKOUT_URL | No | Your hosted embedded checkout page. Handoff links point here with session, expires, kid and token query parameters; verify token as an Ed25519 signature over ucp-embedded-checkout:{session}:{expires} using the JWK named by kid in /.well-known/ucp. Requires signing keys. | https://shop.example.com/checkout/embedded |
MPP_CHALLENGE_SECRET | No | HMAC key that binds MPP Payment challenges. Set, MPP checkouts must answer a 402 challenge and get a Payment-Receipt. Unset, they are not challenged. Keep it in the Secret, and use the same value on every replica. | 32+ random bytes |
MPP_REALM | No | Realm named in MPP challenges. Defaults to the host of PUBLIC_BASE_URL; startup fails if neither is set while MPP_CHALLENGE_SECRET is. | shop.example.com |
MPP_CHALLENGE_TTL_SECS | No | How long an MPP challenge stays answerable, 1–3600. Default 300. | 300 |
UCP_PAYMENT_HANDLERS | No | Your payment providers’ UCP handlers, published as ucp.payment_handlers: JSON object keyed by reverse-DNS handler name, each an array of entries with id and a YYYY-MM-DD version (plus spec, schema, available_instruments, config as the handler defines). Validated at startup; unset publishes {}. | {"com.example.tokenizer":[{"id":"tok","version":"2026-08-25",...}]} |
UCP_DEFAULT_MERCHANT_ID | No | The default merchant for every protocol whose payloads carry none: UCP carts and checkouts without a merchant_id, and ACP checkout sessions and carts (REST and MCP; over MCP meta.merchant_id wins). A request value wins. Unset, such requests get MERCHANT_REQUIRED. | shop-main |
UCP_CATALOG_CURRENCY | No | ISO 4217 currency for UCP catalog prices on the MCP binding when the request has no context.currency (which wins), and for ACP carts (ACP lets the seller pick it). Validated at startup. Unset, such requests get a currency_required error. | USD |
UCP_PROFILE_NEGOTIATION | No | UCP platform profile negotiation on /api/v1/ucp/* and /api/v1/ucp/mcp: off (default, nothing fetched), lenient (fetch and negotiate, never refuse) or strict (refuse as UCP requires: invalid_profile_url, profile_unreachable, profile_malformed, version_unsupported, capabilities_incompatible). Needs egress on 443 to platforms’ profile hosts. See negotiation. | lenient |
MCP_ALLOWED_ORIGINS | No | Browser origins allowed to call the MCP endpoints (scheme://host[:port], comma-separated), or *. Validated at startup. Unset, a request carrying an Origin header is refused with 403 (DNS-rebinding protection); agents calling from servers send no Origin and are unaffected. | http://localhost:6274 |
FULFILLMENT_BASE_URL | No | Shipping rate service. Without it the built-in static rate table is used. | http://fulfillment:8080 |
MIGRATE_ONLY | No | true applies pending migrations and exits, same as passing --migrate. Used by the migration Job. | true |
BIND_ADDR | No | Listen address. | 0.0.0.0:8080 |
RUST_LOG | No | Log level. | info |
OUTBOX_INTERVAL_MS | No | Outbox processor poll interval. | 1000 |
OUTBOX_BATCH_SIZE | No | Messages dequeued per poll. | 50 |
OUTBOX_MAX_ATTEMPTS | No | Attempts before a message is dead-lettered. | 8 |
OUTBOX_DRAIN_TIMEOUT_SECS | No | Shutdown drain budget; keep below the pod’s termination grace period. | 30 |
OUTBOX_RETRY_BACKOFF_MS | No | Pause after a failed delivery, doubled per attempt. | 500 |
OUTBOX_MAX_RETRY_BACKOFF_SECS | No | Ceiling for that pause. | 30 |
PROVIDER_CIRCUIT_PROBE_TIMEOUT_SECS | No | How long a half-open probe may stay in flight before another is admitted. | 60 |
AUTH_TENANT_ID | No | Default tenant for auth context. | prod |
AUTH_CALLER_ID | No | Default caller id. | prod |
AP2_TRUSTED_ISSUERS | No | Comma-separated allowlist for strict AP2 issuer checks. | issuer.example |
Example .env for local runs (replace with your stub or real URLs):
ENV=production
PUBLIC_BASE_URL=https://orchestrator.example.com
DATABASE_URL=postgres://orchestrator:secret@localhost:5432/orchestrator
AUTH_MODE=static
AUTH_BEARER_TOKEN=dev-token-change-in-prod
CATALOG_BASE_URL=http://localhost:9001
PRICING_BASE_URL=http://localhost:9002
TAX_BASE_URL=http://localhost:9003
GEO_BASE_URL=http://localhost:9004
PAYMENT_BASE_URL=http://localhost:9005
RECEIPT_BASE_URL=http://localhost:9006
UCP_SIGNING_KEY_ID=orch-2026-a
UCP_SIGNING_KEY=$(openssl rand -base64 32)
3. Local Smoke Test (no deployment)
Without ENV=production the orchestrator runs in development mode: it uses built-in mock providers with a demo catalog (demo-tee, demo-mug, demo-cap), accepts unauthenticated calls as tenant dev, and ignores the *_BASE_URL settings. That is enough to try the API (see the README quick start). To smoke-test against your providers, run with ENV=production and the full production configuration from step 2.
- Start your six downstream services (or stubs) so they listen on the URLs you set in step 2.
- Start local Postgres (or point to an existing instance):
docker compose up -d postgres - Start the orchestrator:
cargo run -p orchestrator-http --bin orchestrator-server - Health:
curl -s http://localhost:8080/health/live curl -s http://localhost:8080/health/ready - Create cart and run checkout (use your tenant/merchant IDs and payment token as needed):
See Consumption guide for full request/response shapes.# Create cart curl -s -X POST http://localhost:8080/api/v1/cart/commands \ -H "Content-Type: application/json" \ -H "Authorization: Bearer dev-token-change-in-prod" \ -d '{"command":{"kind":"create_cart","merchant_id":"m1","currency":"USD"},"cart_id":null}' # Add item (use cart_id and line IDs from create_cart response) # Then start_checkout, then POST /api/v1/checkout/execute with cart_id, cart_version, payment_intent, idempotency_key, etc. - Payment lifecycle (after a successful checkout):
curl -s -X POST http://localhost:8080/api/v1/payments/capture \ -H "Content-Type: application/json" \ -H "Authorization: Bearer dev-token-change-in-prod" \ -d '{"tenant_id":"t1","merchant_id":"m1","transaction_id":"<tx_id>","amount_minor":1000,"idempotency_key":"cap-1"}' - Ops: Hit
POST /api/v1/ops/outbox/process,GET /api/v1/ops/dead-letter,POST /api/v1/ops/reconciliationas needed (see runbooks).
4. Staging Deployment (Kubernetes)
- Get the image. Each release tag publishes a multi-arch (
linux/amd64,linux/arm64) image to GitHub Container Registry, with an SBOM and build provenance attached. The manifests already reference it:
To run your own build instead, build from the repo root, push it to your registry, and override the image in step 5:docker pull ghcr.io/ancientice/commerce-orchestrator-api:0.13.0
With Helm, install the chart indocker build -t <your-registry>/commerce-orchestrator-api:<tag> . docker push <your-registry>/commerce-orchestrator-api:<tag>deploy/helm/commerce-orchestratorinstead of steps 2 to 5; see deployment. - Edit manifests under
deploy/kubernetes/:configmap.yaml: Set all six*_BASE_URLto your staging service URLs, plus any optional providers you run (FULFILLMENT_BASE_URL,PAYMENT_DELEGATION_BASE_URL,IDENTITY_LINK_BASE_URL).secret.yamlor create the secret manually: SetDATABASE_URL, auth variables based onAUTH_MODE(AUTH_BEARER_TOKENorAUTH_JWT_HS256_SECRET), the signing key pair (UCP_SIGNING_KEY_ID,UCP_SIGNING_KEY), and optionalAUTH_TENANT_ID,AUTH_CALLER_ID.
- Migrate before the new image serves traffic:
The Job runs the server image withkubectl apply -f deploy/kubernetes/job-migrate.yaml kubectl wait --for=condition=complete job/orchestrator-api-migrate --timeout=5m--migrate, which applies pending migrations and exits. Replicas also migrate on startup under a PostgreSQL advisory lock, so a missed Job is recoverable — but a broken migration then fails once here instead of crash-looping every pod. - Apply (ensure namespace exists):
kubectl apply -f deploy/kubernetes/ - Override image to pin a different tag or run your own build:
kubectl set image deployment/orchestrator-api orchestrator-server=ghcr.io/ancientice/commerce-orchestrator-api:0.13.0 - Ensure database reachability from the orchestrator pod (network policy, DNS, credentials, and TLS as required by your platform). The shipped NetworkPolicy allows egress to TCP 5432.
- Scale safely: the manifests ship two replicas. All durable state is in PostgreSQL, outbox dequeue uses
FOR UPDATE SKIP LOCKED, and idempotency keys are stored centrally, so replicas neither double-deliver nor double-charge. Tune the connection pool and database capacity as you scale. - Wire up monitoring: apply
servicemonitor.yaml(Prometheus Operator) and importdeploy/grafana/orchestrator-dashboard.json. See deployment.
5. Post-Deploy Validation Checklist
Run these after deployment to confirm the system is ready for traffic:
- Liveness:
GET /health/livereturns 200. - Readiness:
GET /health/readyreturns 200. - Auth: Request without
Authorization: Bearer <token>to a protected endpoint returns 401. - Cart: Create cart, add item, get cart; responses successful and cart projection looks correct.
- Checkout: Execute checkout with valid cart and payment intent; response includes
transaction_idand success status. - Payment lifecycle: Capture (and optionally void/refund) using
transaction_idfrom checkout; responses indicate success. - Events:
POST /api/v1/events/incomingwith amessage_idreturns 200 (idempotent). - Outbox:
POST /api/v1/ops/outbox/processwith body e.g.{"max_attempts":3}returns 200. - Dead-letter:
GET /api/v1/ops/dead-letterreturns 200 (list may be empty). - Reconciliation:
POST /api/v1/ops/reconciliationwith body{"transaction_ids":["<tx_id>"]}returns 200; check response for mismatches if your payment provider supports state. - Metrics:
GET /metricsreturns Prometheus text and the Grafana dashboard populates. - Discovery honesty:
GET /.well-known/ucpadvertises a signing key you control, and listsdev.ucp.common.identity_linkingonly if you configuredIDENTITY_LINK_BASE_URL.
If any step fails, check server logs, downstream connectivity, and runbooks (e.g. dead-letter handling, reconciliation).
Next Steps
- Consumer integration — REST API usage and auth.
- Consumption guide — Full request/response shapes and config.
- Provider OpenAPI spec — The downstream APIs above, as OpenAPI 3.1.
- Deployment — Kubernetes details, secrets, HPA, rollback.
- Runbooks — Outbox, dead-letter, reconciliation.