Overview
WebSocket streams provide realtime events for customer activity across merchants, commerce orders, and payor checkout sessions. Frames are delivered as JSON objects in the canonicalPepayEvent envelope.
Typical use cases:
- Live merchant dashboards (invoice and payment activity).
- Commerce order tracking in apps or internal tools.
- Payor checkout UIs (session-scoped updates).
GET /ws/merchant/eventsGET /ws/commerce/eventsGET /ws/payment
Streams
- Merchant stream: account-wide
invoice.*andinvoice_payment.*activity (filterable by invoice, customer, environment). - Commerce stream:
commerce.order.*updates and linked invoice/payment context. - Payor stream: session-scoped checkout updates (per payment session).
Authentication
Merchant/commerce streams:- Server-to-server:
x-api-key(merchant) orx-commerce-api-key(commerce) in the WS upgrade headers. - Browser/mobile:
token=<ws_token>query param (mint viaPOST /api/v1/ws/token).
token=<payment_session_jwt>query param (returned fromPOST /api/v1/payments/payment-addresses)
- If a partial payment is received, the invoice becomes
underpaid. - Fetch
GET /api/v1/payments/session-detailsto readlocked_network,locked_token_id, andlocked_payment_address. - The remaining balance must be paid using the locked network/token.
Request
Connection URL examples (token auth):token query param.
Filters (query params):
types: Comma-separated event types (supports wildcards, e.g.invoice.*,commerce.order.*).since: Replay cursor (event id), e.g.evt_1700000000000-123.- Merchant stream:
invoice_type,invoice_id,customer_id,environment. - Commerce stream:
order_id,invoice_id,customer_id,wallet_address,wallet_network. format:event_v1(recommended).
Response
Representative event frame:Resilience and replay
- Delivery is at-least-once; dedupe by
event.id. - Use
since=<event_id>to replay within retention. - If
sinceis too old, the server sends a bounded snapshot and resumes realtime. - Handle
ws_controlframes (replay hints) andws_errorframes (terminal errors).
WebSockets vs webhooks
- WebSockets deliver the same event types as webhooks, but with replay and REST backfill for realtime resilience.
- The merchant stream includes replay/backfill, making it more redundant and reliable than webhooks alone for live updates.
- Webhooks are best for server-side side effects and audit trails.
- Many teams use both for redundancy: WebSockets for live updates, webhooks for durable processing.

