← Openai Interview Insights

Openai·Software Engineer·Onsite - System Design / Architecture·Senior

Senior
Jun 2026

Summary

System design round at OpenAI for a software engineer role, focused entirely on building a payment processing service sitting between merchants and payment providers. Four parts covering architecture, data modeling, consistency, and scaling. Pretty intense for a single session.

Questions Asked (7)

Q1

Sketch the end-to-end architecture for a payment processing service that sits between merchants and upstream payment providers. Walk through a single successful charge from the merchant's API call to the response, including where authentication and validation happen, how the request reaches the provider, what state transitions occur, and what the merchant sees synchronously versus what's deferred.

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

This is the kind of question where you can spend 20 minutes just on the intro and still feel like you haven't said anything.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by outlining the high-level components (API gateway, auth service, validation, payment orchestrator, provider adapters, state store, async workers) and then walk through a single charge step-by-step, emphasizing synchronous vs asynchronous boundaries. Focus on idempotency, state transitions, and error handling to show depth.

Pro tip: Explicitly call out idempotency keys and how you handle duplicate requests—this is a common real-world pitfall and demonstrates production experience. Also, mention that you'd log and monitor each state transition for observability.

1. High-level architecture

Sketch the main components: API gateway, authentication service, validation layer, payment orchestrator, provider adapters, state store (e.g., database), and async workers/queues. Explain their responsibilities and interactions.

2. Synchronous request flow

Walk through the merchant's API call: authentication (API key/OAuth), request validation (schema, business rules), idempotency check, and initial state persistence (e.g., 'pending'). Then the orchestrator routes to the appropriate provider adapter.

3. Provider communication and state transitions

Describe how the request reaches the upstream provider (e.g., HTTP call with retries, circuit breaker). Outline state transitions: pending -> authorized -> captured (or failed). Mention how you handle provider responses and update state accordingly.

4. Synchronous response to merchant

Explain what the merchant receives immediately: typically a charge ID and status (e.g., 'pending' or 'succeeded' if synchronous). Clarify that final settlement or capture may be deferred.

5. Asynchronous processing and deferred actions

Cover what happens after the synchronous response: webhooks to merchant, async capture, reconciliation, retries, and notifications. Mention how you ensure exactly-once processing and handle failures.

Key Points to Mention

  • Idempotency keys to prevent duplicate charges
  • Authentication and authorization (API keys, OAuth, scopes)
  • Validation: request schema, business rules, fraud checks
  • State machine for charge lifecycle (pending, authorized, captured, failed, refunded)
  • Synchronous vs asynchronous boundaries: what the merchant sees immediately vs later via webhooks
  • Error handling and retries with exponential backoff and circuit breakers
  • Observability: logging, metrics, tracing for each state transition

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Define the core API (create charge, capture, refund, get status) and the underlying data model. Specifically, how do you ensure a retried or duplicated request never results in a double charge?

Data ModelingAPI & IntegrationsSystem Design
Author's notes

The idempotency key piece felt straightforward but I almost missed the subtlety: you need to persist the original response and replay it on retry, not just deduplicate the write.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the core API endpoints and the data model, emphasizing the role of idempotency keys and unique constraints. Then explain how the system enforces idempotency at both the API and database layers to prevent double charges. Finally, discuss how retries and duplicates are handled safely, including error responses and reconciliation.

Pro tip: Demonstrate maturity by mentioning that idempotency keys should be scoped to the user and have a reasonable expiration, and that you should return the same response for duplicate requests to simplify client handling.

1. Define the API contract

Outline the endpoints for create charge, capture, refund, and get status, specifying required parameters like amount, currency, and idempotency key. Clarify the expected responses and error codes.

2. Design the data model

Describe the tables for charges, refunds, and idempotency keys, including fields like id, status, amount, and timestamps. Highlight the need for a unique constraint on the idempotency key to prevent duplicates.

3. Enforce idempotency

Explain how the idempotency key is used to detect and handle duplicate requests, either by storing the key with the charge or using a separate idempotency table. Emphasize atomic operations and unique constraints.

4. Handle retries and duplicates

Describe the flow when a duplicate request arrives: check for existing idempotency key, return the original response if found, or proceed with the charge if not. Discuss race conditions and how to handle them with database locks or transactions.

5. Discuss edge cases and reconciliation

Cover scenarios like partial failures, timeouts, and how to reconcile state. Mention the importance of logging and monitoring to detect and resolve inconsistencies.

Key Points to Mention

  • Idempotency keys: client-generated unique keys for each request, stored server-side to detect duplicates.
  • Unique constraint on idempotency key in the database to prevent race conditions.
  • Returning the same response for duplicate requests to ensure idempotent behavior.
  • Using database transactions and locking to handle concurrent duplicate requests.
  • Expiration and cleanup of idempotency keys to manage storage.
  • Handling edge cases like partial failures and ensuring eventual consistency.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

A provider call times out and you don't know whether the card was actually charged. How do you keep the system consistent? Describe your source of truth, how you resolve unknown outcomes, and how async capture, settlement, and reconciliation work.

System DesignTechnical Trade-offsData Modeling
Author's notes

This one genuinely stumped me for a second.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by establishing the ledger as the source of truth, then explain how you handle unknown outcomes through idempotency and reconciliation. Finally, describe the async capture, settlement, and reconciliation flows, emphasizing how each step maintains consistency.

Pro tip: Emphasize that you never assume success or failure on timeout; instead, you treat it as an unknown and rely on idempotent operations and reconciliation to resolve it. This shows you understand the importance of eventual consistency in distributed systems.

1. Define the Source of Truth

Identify the ledger as the authoritative record of all financial transactions, ensuring it is append-only and immutable. This provides a single reference point for resolving discrepancies.

2. Handle Unknown Outcomes

Use idempotency keys for all provider requests to safely retry without double-charging. On timeout, record the attempt as pending and trigger a reconciliation process to query the provider's status.

3. Explain Async Capture

Describe how authorization and capture are separated: an initial auth reserves funds, and capture is done asynchronously later. This allows for handling delays and failures without blocking the user flow.

4. Describe Settlement

Explain that settlement is the process where funds are actually transferred, often batched and delayed. The system must reconcile settlement reports from the provider with the ledger to ensure accuracy.

5. Detail Reconciliation

Outline a reconciliation process that periodically compares the ledger with provider reports, identifies mismatches, and resolves them through automated or manual adjustments, ensuring eventual consistency.

Key Points to Mention

  • Idempotency keys to prevent duplicate charges on retries
  • Ledger as append-only source of truth with double-entry accounting
  • State machine for payment lifecycle: pending, authorized, captured, settled, failed
  • Reconciliation jobs that query provider APIs for unknown transactions
  • Async capture to decouple authorization from capture, improving resilience
  • Settlement reports and how they are ingested and matched against the ledger

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

How do you scale this service to thousands of charge requests per second, isolate a slow or failing upstream provider from affecting the rest of the system, deliver webhooks reliably, and maintain visibility into system health and financial correctness?

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

Bulkheads and per-provider queues were my main angle for isolation.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then walk through a layered architecture that addresses each concern: horizontal scaling with stateless services and sharding, bulkheads and circuit breakers for isolation, a durable webhook delivery system with retries and dead-letter queues, and comprehensive observability with idempotency and reconciliation for financial correctness. Emphasize trade-offs and how you would validate the design under load and failure scenarios.

Pro tip: Proactively discuss idempotency and exactly-once semantics for charge requests and webhooks, as financial systems demand it, and mention how you'd use canary deployments and chaos engineering to build confidence in the system's resilience.

1. Clarify Requirements and Constraints

Ask about expected peak load, latency SLAs, consistency requirements, and failure modes. Confirm whether the system must handle exactly-once processing and what the tolerance for delayed webhooks is.

2. Design for Horizontal Scalability

Propose a stateless service layer that can scale out, with sharding or partitioning of charge requests (e.g., by customer ID) to distribute load. Use asynchronous processing and queues to absorb spikes.

3. Isolate Upstream Failures

Implement bulkheads, circuit breakers, and timeouts per upstream provider. Use fallback strategies and degrade gracefully so a slow provider doesn't cascade failures.

4. Ensure Reliable Webhook Delivery

Design a durable, persistent queue for webhooks with at-least-once delivery, exponential backoff retries, and a dead-letter queue for poison messages. Include idempotency keys to allow safe retries.

5. Maintain Observability and Financial Correctness

Instrument metrics, logs, and traces for all critical paths. Implement reconciliation jobs to detect discrepancies, and use idempotency and transactional outbox patterns to guarantee financial correctness.

Key Points to Mention

  • Horizontal scaling with stateless services and sharding
  • Circuit breakers, bulkheads, and timeouts for fault isolation
  • Durable webhook delivery with retries, exponential backoff, and dead-letter queues
  • Idempotency keys and exactly-once processing for charges and webhooks
  • Observability: metrics, logging, tracing, and alerting
  • Reconciliation and audit trails for financial correctness

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q5

How would you support separate authorization and delayed capture, where funds are held at order time and captured later at shipment? Include how you'd handle authorization expiry.

System DesignAPI & Integrations
Author's notes

Follow-up question.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the business flow and requirements, then design a two-phase payment system with separate authorization and capture APIs, including idempotency and state management. Explain how you would handle authorization expiry through scheduled jobs, webhooks, and fallback strategies like reauthorization or voiding.

Pro tip: Emphasize idempotency and reconciliation: use idempotency keys for all payment operations and implement a reconciliation process to handle edge cases like partial captures or expired authorizations.

1. Clarify Requirements and Flow

Ask about the expected delay between order and shipment, payment methods, and whether partial captures are needed. Confirm the need for separate authorization and capture operations.

2. Design API Endpoints and Data Model

Define endpoints for authorization (e.g., POST /payments/authorize) and capture (e.g., POST /payments/{id}/capture). Model payment states (authorized, captured, expired, voided) and store authorization expiry timestamps.

3. Handle Authorization Expiry

Implement a scheduled job to monitor expiring authorizations and trigger reauthorization or voiding. Use webhooks from the payment provider to receive expiry notifications and update order status accordingly.

4. Ensure Idempotency and Error Handling

Use idempotency keys for authorization and capture requests to prevent duplicate charges. Define retry policies and error handling for failures like expired authorizations or insufficient funds.

5. Reconciliation and Monitoring

Set up reconciliation jobs to compare internal records with payment provider reports. Monitor key metrics like authorization success rate and capture latency, and alert on anomalies.

Key Points to Mention

  • Idempotency keys for authorization and capture to avoid duplicate charges
  • State machine for payment lifecycle: authorized, captured, expired, voided
  • Scheduled jobs and webhooks to handle authorization expiry proactively
  • Fallback strategies: reauthorization, voiding, or notifying the customer
  • Partial captures and multiple captures support if needed
  • Reconciliation with payment provider to ensure consistency

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q6

A merchant resubmits a request using the same idempotency key but with a different amount. What do you return and why?

API & IntegrationsTechnical Trade-offs
Author's notes

Return a 422 or similar conflict error.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying that the correct behavior is to reject the request with a 409 Conflict or 422 Unprocessable Entity, because the idempotency key is already associated with a different request payload. Explain that this prevents accidental duplicate charges and maintains data integrity, and mention that the server should store a hash of the request body to detect such mismatches.

Pro tip: Emphasize that returning the original response would be dangerous because it could mask a client bug or malicious attempt, and that logging the mismatch with sufficient context (without exposing sensitive data) is crucial for debugging and security monitoring.

1. Identify the conflict

Recognize that the same idempotency key is being reused with a different request payload, which violates the idempotency contract.

2. Choose the appropriate error response

Return a 409 Conflict (or 422) with a clear error message indicating that the idempotency key was already used with a different request.

3. Explain the rationale

Justify why returning the original response is incorrect: it could lead to unintended financial consequences and hide client-side bugs.

4. Describe detection mechanism

Mention that the server should store a hash of the request body alongside the idempotency key and compare it on subsequent requests.

5. Discuss edge cases and best practices

Cover scenarios like key expiration, logging for auditing, and how to handle partial failures or retries with exponential backoff.

Key Points to Mention

  • Idempotency keys are meant to ensure that the same request is not processed multiple times; reusing a key with a different payload breaks this guarantee.
  • Returning the original response would be incorrect because it could result in the merchant believing the new amount was processed when it wasn't.
  • HTTP 409 Conflict is the standard status code for such conflicts, though 422 is also acceptable depending on API design.
  • The server must store a fingerprint (e.g., hash) of the original request to detect mismatches.
  • Logging the mismatch with details (without sensitive data) helps with debugging and detecting malicious activity.
  • Consider idempotency key expiration policies to avoid indefinite storage and potential key collisions.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q7

Walk through end-of-day reconciliation where the provider's settlement file lists a charge your system has no record of. What happens?

System DesignRoot Cause AnalysisData Modeling
Author's notes

Flag it as an exception, hold the funds, investigate.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the reconciliation process and the data flow between the provider and your system. Then, systematically trace the unknown charge through each stage—ingestion, storage, and matching—to identify where the discrepancy arises. Finally, propose a resolution and preventive measures, emphasizing data integrity and error handling.

Pro tip: Demonstrate a bias toward action: immediately isolate the unknown charge to prevent it from affecting other records, then investigate. Also, mention the importance of logging and monitoring to catch such issues early.

1. Clarify the Reconciliation Process

Explain how end-of-day reconciliation typically works, including the sources of data (provider settlement file, internal transaction records) and the matching criteria (e.g., transaction ID, amount, timestamp).

2. Trace the Unknown Charge

Walk through the steps to trace the charge: check if it exists in any internal logs, queues, or dead-letter queues; verify if it was ingested but failed validation; and examine if it was recorded under a different identifier.

3. Identify Root Cause

Determine the likely root cause: e.g., a bug in the ingestion pipeline, a race condition, a data mapping error, or a missing transaction due to a system outage. Consider both technical and process failures.

4. Resolve and Reconcile

Propose immediate actions: manually add the missing charge if valid, or flag it for investigation if suspicious. Ensure the reconciliation completes with appropriate adjustments and audit trails.

5. Prevent Recurrence

Suggest long-term fixes: improve logging, add validation checks, implement idempotency, set up alerts for reconciliation mismatches, and conduct regular audits.

Key Points to Mention

  • Idempotency and exactly-once processing to avoid duplicates or missing records
  • Data validation and schema enforcement at ingestion
  • Dead-letter queues and retry mechanisms for failed transactions
  • Audit trails and logging for traceability
  • Reconciliation metrics and alerting for mismatches
  • Root cause analysis techniques (e.g., 5 Whys, fishbone diagram)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.