StateSet UCP Handler is a standalone Rust server that implements the Universal Commerce Protocol (UCP) checkout flow. It exposes discovery, checkout session lifecycle, tokenization, webhook delivery, and optional OAuth identity linking.Documentation Index
Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
Use this file to discover all available pages before exploring further.
Key capabilities
- Discovery at
/.well-known/ucp - Checkout session lifecycle endpoints
- Fulfillment and discount extensions
- Order webhooks and audit logs
- Tokenization endpoints (
/tokenize,/detokenize) - Optional OAuth 2.0 identity linking and AP2 mandate extension
- gRPC API with JSON payloads
- Optional iCommerce backend with SQLite persistence
Quickstart
http://0.0.0.0:8081 by default. Run the demo flow:
Required headers
By default the handler requires:UCP-Agenton all requestsRequest-SignatureonPOSTandPUT
Request-IdwhenUCP_REQUIRE_REQUEST_ID=trueIdempotency-KeywhenUCP_REQUIRE_IDEMPOTENCY=true
Create a checkout session
Core endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /.well-known/ucp | Discovery document |
| GET | /api/checkout-sessions | List checkouts |
| POST | /api/checkout-sessions | Create checkout |
| GET | /api/checkout-sessions/:id | Retrieve checkout |
| PUT | /api/checkout-sessions/:id | Update checkout |
| POST | /api/checkout-sessions/:id/complete | Complete checkout |
| POST | /api/checkout-sessions/:id/cancel | Cancel checkout |
| GET | /api/orders | List orders |
| GET | /api/orders/:id | Retrieve order |
| POST | /tokenize | Tokenize credential |
| POST | /detokenize | Detokenize credential |
| GET | /metrics | Prometheus metrics |
| GET | /health | Health check |
| GET | /ready | Readiness check |
Commerce backend
iCommerce is enabled by default and stores checkouts and orders in./commerce.db. Disable it for in-memory storage:
Webhooks and audit trails
SetUCP_ORDER_WEBHOOK_URL to send order events when a checkout completes. The handler also exposes:
/api/audit-events/api/webhook-deliveries
OAuth and AP2 extensions
Enable identity linking withUCP_OAUTH_ENABLED=true. Enable AP2 mandate support with UCP_AP2_ENABLED=true and UCP_AP2_MERCHANT_AUTH.
gRPC access
The gRPC server listens on0.0.0.0:50051 by default and uses JSON payloads in payload_json. Auth can be provided via authorization or x-api-key metadata.