System Design Atlas

Ticket sales with assigned seats

04 / 10Worked example

Interfaces

What can a webhook acknowledge before domain processing finishes?

The API makes retries and responsibilities explicit. EV-17 denotes the incoming payment-result event. Hold and checkout requests come from the ticket interface; the payment result arrives later from the payment service. The webhook response acknowledges durable event ingestion, not ticket confirmation.

Starting point The starting point is the asynchronous payment result Z-17 after B-17.

Assumptions for the example case

Example design for one event with 1,000 numbered seats. Each order contains exactly one seat. Hold, sale, payment and ticket are separate entities. All figures and targets are illustrative assumptions, not provider metrics. Admission scanning, resale, dynamic pricing and multi-seat orders are outside scope. Sources checked on 8 September 2026. The order model covers successful payments, including delayed success; final unpaid cancellations need their own terminal state before implementation.

Four contracts from hold to order status

Four contracts with caller, result and retry behaviour

1POST /holdsVisitor → ticket APIV-17, S-42, requestKey201 H-17 or 409
300 s validity
2POST /holds/H-17/checkoutVisitor → ticket APIrequestKey, payment initiationpayment_pending B-17
External
3POST /payment-eventsPayment service → Ticket APISignature, eventId, Z-172xx after inbox commit
later
4GET /orders/B-17Visitor → ticket APIonly own orderpayment_pending, confirmed or compensation

The API compares the key and request fingerprint. An identical retry returns the original result; changed content produces 409.

The browser receives a traceable hold or order response. Payment is evidenced through a verified event or documented status reconciliation.

Each contract identifies the caller, input, result and retry behaviour.

Proposed Application and Provider Contracts

  1. POST/holds

    Create H-17 for S-42

    Input
    Authorized Visitor Context, V-17, S-42 and Idempotency Key
    Result
    201 with H-17 and expiresAt or 409 with active binding
    Retry behaviour
    same key and content gives the same result
  2. POST/holds/H-17/checkout

    Create B-17 and initiate payment

    Input
    Authorized visitor assigned to H-17 and Idempotency key
    Result
    payment_pending with B-17 and Z-17
    Retry behaviour
    Same key and content deliver the same order; modified content generates 409
  3. POST/payment-events

    Accept signed payment feedback

    Input
    Raw data, signature, provider account, event identifier EV-17 and payment Z-17
    Result
    2xx after permanent inbox commit
    Retry behaviour
    eventId is deduplicated; processing takes place later
  4. GET/orders/B-17

    Read your own order status

    Input
    Authorized visitor context
    Result
    payment_pending, confirmed, compensation_pending or refunded
    Retry behaviour
    Read-only; creates no new domain effect

Differentiate provider protocol and own contract

Own draft
Paths, status names and idempotency comparison are suggestions for this Atlas case. They do not specify a payment provider.
Pattern source
Stripe describes signature verification, prompt 2xx responses, retries and events arriving out of order. The application therefore persists inbox events before acknowledging them.
Secure start of payment
Checkout atomically persists B-17, local payment reference Z-17 and a payment command. The worker sends the outbox command with a stable key; after a lost response, it retries with that key or reconciles with the provider. The provider ID stays associated with B-17; a timeout creates no second payment command.
Limitation of repetition
Idempotency keys are scoped to the authorised caller and operation. The key and result are persisted together. A new key still cannot create another order for H-17. Event IDs are deduplicated within the provider account; domain validation also handles multiple event IDs for the same payment. Retention must cover the retry and investigation window. Once the provider's retention period expires, reconcile an unknown result before triggering an external effect again.

Terms in this step

Webhook inbox
An inbox durably stores an external event with a stable identifier before the application processes its domain effect.

Try it yourself

Specify callers, inputs, results and retry behaviour for hold, checkout and payment webhook contracts. Mark the point of durable ingestion.

A hint for your attempt

The feedback can be quickly confirmed once it has been checked and stored permanently. Ticket logic may follow.

Compare with a possible solution
Hold and Checkout
For a hold, the visitor sends V-17/S-42 and a key: the result is 201 with H-17 and its expiry, or 409. The visitor assigned to H-17 sends the hold and key for checkout: after local commit, the result is B-17 in payment_pending with payment reference Z-17. The same key and content repeat the stored result; changed content produces 409. Each hold has at most one order.
Webhook
The payment service sends the unchanged raw body, signature, EV-17 and Z-17. The API verifies origin, deduplicates and durably persists the event, then responds 2xx. A retry acknowledges the existing inbox record. The worker validates the domain effect later.

Apply to your project

Which external event must your system persist before acknowledging it?

Next, use the contracts to define the data model, states and transaction boundaries.