Insights · Career guidance · 6 minute read

Build an API Work Sample That Survives Duplicates and Retries

Show a hiring team how your integration behaves when the same message arrives twice or the result of a request is uncertain. Build one small workflow with a clear business rule and make its failure cases reproducible.

By Vitaver Staffing ·

Show that one business request produces one intended result

If you want an integration engineering role, build a small work sample that stays understandable when messages arrive twice or a response disappears. Imagine a fictional supplier sending order updates to a distributor. The receiver needs to create one fulfillment task for an approved order and retain enough evidence to investigate a failed handoff. A working API call begins the demonstration. The stronger evidence is what happens after an interruption.

Keep the exercise local with synthetic orders, a small database, a receiver and a simulated downstream service. Write the business rule before the code: an eligible order creates one fulfillment task, and a later cancellation prevents any new task when the order is already cancelled. Define which system owns the current order status. Choose a few event types and document the payload fields you accept. Someone reviewing the sample should be able to identify the rule and run the checks without purchasing a service.

Distinguish receiving a message from completing its work

Record the delivery identifier and the business identifier separately. A delivery identifies an incoming event; the order identifier connects events about the same order. Store a durable receipt before acknowledging work you intend to process later. Have a worker validate the event, record its progress and call the simulated downstream service. Give failed work a visible state and a next action. Avoid logging customer details or secrets merely to make the trace look complete.

GitHub’s webhook guidance recommends prompt responses and describes queues as a way to process events after reception. It also explains that a requested redelivery retains the original X-GitHub-Delivery identifier. Use that provider behavior as a concrete example while documenting the contract of your own simulator. A repeated delivery should reach the existing processing record. GitHub, Best practices for using webhooks.

Use the database to enforce the identity rule under concurrency. A check followed by an unprotected insert can still permit two workers to act. Demonstrate what happens when the same delivery arrives simultaneously. Also consider two different events that request the same business action. Keeping delivery identifiers alone cannot decide whether both should create a fulfillment task. Explain the business key and the transaction boundary that protect that decision.

Make the ambiguous failure part of the demonstration

Introduce a failure after the downstream service has created a task but before your worker receives its response. Restart the worker and show how it finds out whether the task exists. A stable operation identifier can help a downstream service recognize a retry. Stripe’s idempotency documentation gives a real example of this design and describes limits that differ across its API versions. Read the relevant contract before assuming how any provider handles repeated requests. Stripe, Idempotent requests.

For the local sample, state how long the downstream simulator remembers operations and how it responds if a retry changes the request. Preserve the same identifier while resolving an uncertain operation. If the downstream system offers no suitable duplicate protection, show how your operator reconciles state and holds the case for review. Document the gap rather than promising that a retry will always be harmless.

Exercise event order as well. Stripe documents that webhook events can arrive out of sequence and that duplicate deliveries can occur. In your fictional workflow, send a cancellation before an older approval event. Demonstrate how a version rule or an authoritative status lookup keeps the late event from reopening the order. Distinguish evidence of a stale update from an event you could not process. Stripe, Receive events in your webhook endpoint.

Give the reviewer a short failure tour

Package a repeatable sequence covering normal delivery, concurrent duplicates, the lost-response case, a stale update and an invalid request. Show the expected business state beside the observed state after each case. For the invalid request, demonstrate the signature or authentication check appropriate to the interface and confirm that no fulfillment work occurs. Keep a separate retry policy for temporary failures, with a limit and an operator-visible stop state.

Include the relevant tests, sample logs, setup commands and a small diagram showing where state is persisted. Explain what survives a restart, which failures require review and what remains outside the demonstration. Have a peer run it from a clean setup. Their ability to trace an uncertain order and recover it is more useful feedback than a screenshot of a successful request.

This draws on the Vitaver Playbook’s emphasis on evidence and ownership. In an interview, identify the rule you chose, the failure you deliberately introduced and the test that changed your implementation. Credit any framework or borrowed component. You give the hiring team something concrete to assess when you can explain both the result and the conditions under which you can trust it.

← All Insights