Partner Listing Onboarding Gateway: API and Pipeline Design
System DesignModel answerLast updated
Design an HTTP gateway through which third-party partners submit property listings, which are checked by an internal validation team's service, with safe retries, async results and observability.
Problem
Your platform wants to let outside partners (for example, property-management tools and channel managers) push listings into it programmatically. You are asked to design the partner-facing ingestion gateway.
Partners send create or update requests for listings. The gateway does not own business rules. Instead, it forwards each request to an internal validation and domain service run by a different team. Once that service has decided, the partner must be told the outcome.
Expect to be pushed hard on API detail and to be asked to draw (in text) the full request flow.
What the system must do
- Accept create and update requests for listings over HTTP with JSON bodies.
- Perform cheap checks at the edge: authentication, schema, payload size.
- Hand the request to the internal validation service for business checks.
- Give the partner one of three clear outcomes: accepted or created, rejected with a list of validation errors, or still in progress.
- Make retries safe, so a repeated request never produces a duplicate listing.
Non-functional expectations
- Handle high request volume from many partners, including a few very large ones.
- Stay healthy when partners retry aggressively, and when the validation service is slow or down.
- Provide metrics, logs, distributed tracing and an audit trail.
What to deliver
- An API design: endpoints, example request and response bodies, required headers, authentication and authorization approach, and the idempotency mechanism. List the HTTP status codes and when each is returned.
- A request flow from partner to final result (a text diagram is fine).
- Notes on scaling, reliability and the important edge cases.
State your own assumptions about traffic, payload size and downstream latency before you start.
Hints
Hint 1
Decide early whether the API is synchronous or asynchronous. If the validation service can take seconds or go down, what should the partner's first response look like, and how do they later learn the result?
Hint 2
There are two independent ways to stop duplicates: a natural business key (partner id plus the partner's own listing id) and a client-supplied idempotency key with a stored request hash. Work out what each one protects against and what should happen when a key is reused with a different body.
Hint 3
Think about the gap between 'write to my database' and 'send to the downstream system'. How do you avoid losing or double-sending a message, and how do you keep updates to the same listing in order?
Hint 4
Separate edge errors (HTTP status on the submit call) from business rejections (reported in the operation result). Decide which status codes belong to each.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Assumptions
- About 1,000 partners, with a handful producing most traffic. Around 2k requests/s average and 15k/s at peak (bulk syncs).
- Payloads of 5-50 KB, hard cap 1 MB. Photos are URLs, not binary data.
- Validation service: p50 about 300 ms, p99 several seconds, occasional outages, and its own capacity limits.
- Hard rules: never create a duplicate listing, and apply updates to one listing in order.
Core decision: make the API asynchronous by default. Return 202 Accepted plus an operation resource. This decouples partner connections from downstream latency and outages. An optional sync fast path can return 201 if validation finishes within a short budget (about 2 s).
2. API
Base: https://api.example.com/v1
Auth. OAuth 2.0 client-credentials gives a short-lived JWT (about 15 min) carrying partner_id and scopes (listings:write). Large partners can add mTLS. Authorization uses partner_id from the token only, never from the body, so partners can only touch their own listings.
Headers.
| Header | Purpose |
|---|---|
Authorization: Bearer ... | Identity |
Content-Type: application/json | Other types get 415 |
Idempotency-Key | Safe retries on writes |
traceparent / X-Correlation-Id | Tracing, generated if missing, echoed back |
If-Match | Optimistic concurrency on updates |
ETag, Location, Retry-After, rate-limit headers | Response metadata |
Endpoints.
PUT /partners/{pid}/listings/{partnerListingId}: create or upsert. The partner's own id is the key, so it is naturally idempotent. Returns202withLocation: /v1/operations/{opId}and a body such as{operationId, status: "PENDING", listingRef, submittedAt}.PATCHon the same path (merge-patch) for partial updates.GET /operations/{opId}: status isPENDING -> PROCESSING -> SUCCEEDED | REJECTED | FAILED. A rejection returns HTTP 200 witherrors: [{code, field, message}].FAILEDmeans an internal error persisted after retries and the partner may resubmit.GET /partners/{pid}/listings/{id}: current accepted state withETag.POST /partners/{pid}/listings:batch: up to 100 items, one operation per item, so partial success is explicit.- Webhooks: partners register a URL and secret. Completion events are signed (HMAC-SHA256 with timestamp), delivered at least once, and include
operationIdfor dedupe. Polling stays as the fallback.
Status codes.
| Code | Use |
|---|---|
| 200 | GET ok, or replay of a completed request |
| 201 | Sync fast path finished |
| 202 | Accepted for async work |
| 400 | Malformed JSON or schema violation |
| 401 / 403 | Bad token / not owner or missing scope |
| 404 | Unknown listing or operation |
| 409 | Idempotency key reused with different body, or conflicting in-flight operation |
| 412 | Stale If-Match |
| 413 / 415 | Too large / wrong type |
| 422 | Semantic error detectable at the edge |
| 429 | Partner over quota, with Retry-After |
| 503 | Gateway shedding load, with Retry-After |
Business rejections from the validation service live in the operation, not in the status of the original 202.
3. Idempotency and ordering
Two layers:
- Natural key. A unique constraint on
(partnerId, partnerListingId)in the mapping table to the internallistingId. Even with no header, a retried create cannot make two listings. - Idempotency-Key store (durable table, 24 h TTL) holding
key -> {requestHash, operationId, status, response}. Use a conditional insert:- Same key, same hash: return the stored response (same
operationId). - Same key, different hash:
409. - Same key, still in flight:
202with the existingoperationId.
- Same key, same hash: return the stored response (same
Ordering. Partition the queue by partnerId:partnerListingId so one listing's updates are processed serially. Use sourceTimestamp and version numbers to drop stale updates, reported as REJECTED: STALE_UPDATE.
4. Flow
Partner -> API gateway (TLS, JWT check, WAF, per-partner rate limit, size cap)
-> Ingestion API (stateless)
1. schema validation (400/422)
2. ownership check (403)
3. idempotency conditional put
4. in ONE DB transaction: write operation(PENDING) + outbox row
5. return 202 + Location
Outbox relay -> partitioned queue (key = partnerId:partnerListingId)
Worker -> validation service (timeout, retry w/ jittered backoff, circuit breaker)
-> persist result, update operation, update listing mapping
-> emit webhook event (separate delivery queue, retries, DLQ)
Partner -> GET /operations/{id} or receives webhook
The transactional outbox removes the dual-write problem: either both the operation record and the message exist, or neither does. Consumers are idempotent (keyed by operationId), so at-least-once delivery is safe.
5. Scaling and reliability
- Stateless API tier behind a load balancer, autoscaled on CPU and request rate. The queue absorbs bursts.
- Fairness: per-partner token-bucket limits at the gateway plus per-partner concurrency caps in workers, so one bulk sync cannot starve others. Consider separate queues or priority lanes for large partners.
- Backpressure on the validation service: workers use a rate limiter matching its agreed quota, a circuit breaker, and pause consumption when it is unhealthy. Operations stay
PENDINGand partners are not harmed. - Retries: exponential backoff with jitter, a retry cap, then a dead-letter queue and
FAILEDstatus with alerting. Distinguish retryable errors (timeouts, 5xx) from permanent ones (validation rejection). - Storage: a partitioned key-value or SQL store keyed by partner, with operation records retained for a defined period (for example 30-90 days) for audit.
- Webhooks: per-endpoint retry schedule, signature verification, and auto-disable after sustained failure with notification.
6. Observability and audit
- Metrics: request rate, 4xx/5xx by partner, operation latency (submit to terminal state), queue depth and age, downstream error rate, DLQ size, webhook success rate.
- Structured logs with
partnerId,operationId, trace id. Never log full payloads with personal data. - Distributed tracing across API, queue, worker and the validation call.
- Append-only audit log of every state transition and the identity that caused it.
- SLOs, for example 99% of operations terminal within 30 s when downstream is healthy, with alerts on oldest-message age.
7. Edge cases
- Client times out and retries the same key: returns the same operation.
- Same key, changed body: 409, not silent overwrite.
- Two concurrent updates to one listing: serialized by partition, plus
If-Matchgives 412 for stale writers. - Out-of-order delivery after retries: version and
sourceTimestampchecks. - Worker crashes after calling downstream but before saving: the downstream call must be idempotent on
operationId, or the worker reconciles by querying it first. - Validation service outage: operations queue up; the API still returns 202, and 503 is used only if the queue or store itself is overloaded.
- Poison messages: bounded retries, then DLQ.
Common mistakes
- Holding the partner's HTTP connection open for the whole validation.
- Returning a 4xx on the original request for business rejections that happen later.
- Relying only on an idempotency header and having no natural unique key.
- Writing to the database and publishing to the queue as two separate steps.
- Taking
partnerIdfrom the request body. - Ignoring noisy-neighbor effects between partners.