Scrivio Interview library
LeadershipPrincipal6 min read · updated 12 November 2026

Your company is exposing a public payments API to partners. As the senior technical leader, what long-term commitments about retries and idempotency would you make in the API contract, and what are the risks of getting them wrong?

I would commit to documented idempotency key semantics, a retention window and specific error codes, because partners will build their retry logic on them, and I would version those semantics explicitly since changing them later breaks partners. The risks of getting it wrong are double charges with financial and regulatory consequences, and duplicates when retention is shorter than partners' slow retries. The internal architecture, sharding and regions, must be able to honour the contract globally, and we keep request hashes and outcomes for the retention period to support audit and disputes.

Why this question is asked

An internal API can change its retry behaviour in a sprint. A public payments API cannot: once partners have written code against it, its idempotency rules are effectively frozen, and a mistake shows up as money moved twice. Interviewers ask this at the twenty-year level because it is about long-term commitments, the cost of breaking them, and whether the platform can keep them as it grows. In this answer, we will set out what the contract must promise, why it must be versioned, what goes wrong when it is wrong, what the architecture must guarantee to honour it across regions, and how audit and disputes rely on it.

1Why the Contract Matters More Than the Code

Partners will retry. Their networks drop connections, their jobs restart, their engineers write loops that retry on any 5xx. Whether those retries are safe depends entirely on what our contract says and whether we keep it. A partner who reads that a repeated request with the same Idempotency-Key returns the original result will design their system around that sentence, perhaps retrying for hours during an outage of their own.

So the contract is a long-term commitment, comparable to a database schema shared with hundreds of teams we do not control. The technical implementation behind it can change many times; the promise cannot, at least not without a new version.

2What the Contract Must Say

The contract should leave nothing to interpretation. It defines the Idempotency-Key header as required on every request that creates or changes money movement, with a stated format and length; the scope, keys are unique per partner account, not globally; the retention window, for example 7 days, during which a retry is guaranteed to return the original outcome; and the behaviour in each case, with status codes partners can program against.

Promised behaviour for a request with an Idempotency-Key
SituationOur responseWhat the partner should do
First requestnormal result, e.g. 201store the payment id
Retry, same key and body, completedthe original response, same bodytreat as success
Retry while still processing409 with Retry-Afterretry later with the same key
Same key, different body422, key reusedfix the client; never auto-retry
Key older than 7 daystreated as a new requestdo not retry beyond the window
Missing key on a money request400add a key
Each row is a promise partners will code against.

Notice the row for expired keys. It is as important as the others, because it tells partners exactly where the guarantee ends, and lets them design their retry policy to stay inside it.

3Version the Semantics Explicitly

Changing these rules later breaks partners in ways they may not notice until money moves twice. If we shorten retention from 7 days to 24 hours, a partner whose reconciliation job retries failed payments after two days now creates duplicates. If we change 409 to 425 for in-progress requests, a partner's retry loop that only retries on 409 stops retrying and leaves payments unresolved.

So idempotency semantics are part of the API version, the same as field names. We document them in the versioned reference, change them only in a new version, give long deprecation periods, and test them in the public sandbox so partners can verify their retry logic against the real behaviour. Internally, a contract test suite pins every row of the table above, so an implementation change that alters behaviour fails the build.

4The Risks of Getting It Wrong

The most direct risk is double charges. A customer charged twice by a partner's checkout complains to the partner, the partner complains to us, and regulators may take an interest if it happens at scale; in some jurisdictions, repeated failures in payment processing carry reporting obligations and fines. Refunding is possible but costs operations time, chargeback fees and trust.

The subtler risk is retention that is too short. Partners' retries are not always fast: a batch job that resubmits failed payments overnight, or a partner whose own system was down for a day, retries far later than our engineers imagine. If our retention is shorter than their real retry window, every late retry becomes a duplicate payment, and the partner believes they followed our rules. A generous, clearly documented window is cheap insurance.

5Honouring the Contract Across Shards and Regions

A promise made by the API must be kept by the whole platform. As we grow, payments may be sharded by partner or merchant and served from several regions. The key lookup must be able to find an earlier request wherever it was processed. If a partner's first request went to the European region and the retry, after a DNS failover, reaches the US region, the US region must see that key, or it will create a second payment.

Step throughWhere can a retry be served?
  1. Retry arrives in region Bfirst request was processed in region A
  2. Key lookup is global or partner-homed?
    YesFinds the original, replays itNoRegion B sees no key
  3. Region B creates a second paymentcontract broken: double charge

3 steps in order. Play them, or step through them one at a time.

Either the key store is global, or each partner is homed to one region and requests are routed there.

There are two common ways to keep the promise: home each partner to one region and route all its money requests there, with failover that moves the key data too, or keep the idempotency key store in a globally consistent database. Both cost something, latency or operational complexity, and that cost must be accepted before the contract is published, not discovered after.

6Audit and Dispute Handling

Disputes always come down to what was asked and what was done. For every key we keep, for the full retention period and longer for audit, a hash of the request, the time it was received, the outcome and the payment id it produced. When a partner says they sent one request and were charged twice, we can show whether two different keys were used, whether the same key came with two different bodies, or whether we failed, and act on facts.

Keeping request hashes rather than full bodies limits the sensitive data we store, while still proving whether two requests were identical. The audit retention period is usually set by financial regulation and is longer than the idempotency window; the two should be designed together.

7Follow-up questions

How long should the retention window be?

Longer than any realistic partner retry, including retries after their own outages and overnight batch reprocessing. Many payment APIs choose a window of at least 24 hours; I would lean towards several days for a partner API, because storage for keys and hashes is cheap compared with a duplicate payment. Whatever we choose, we publish it and keep it for the life of the API version.

Should we let partners send requests without a key?

For money movement, no. Without a key we cannot distinguish a retry from a new payment, and the partner bears the risk without realising it. Rejecting such requests with 400 forces the right behaviour from the first integration test.

What do you monitor once the API is live?

Replayed responses per partner, key reuse with different bodies, 409 rates, retries arriving near or after the retention window, and cross-region key lookups. A partner with many 422s has a bug we can help fix before it becomes a dispute.

8Conclusion

In this answer, we treated idempotency in a public payments API as a long-term promise. The contract documents key semantics, scope, a retention window and status codes for every case, and it is versioned so that changes never silently break partners. Getting it wrong means double charges with financial and regulatory consequences, or duplicates when retention is shorter than partners' slow retries. The architecture must honour the promise across shards and regions, and keeping request hashes and outcomes supports audit and dispute handling.

What to say in the interviewAbout 90 seconds aloud

Open with

I would treat the idempotency rules as one of the most important long-term commitments in the API, because partners will build their retry logic on them and we cannot change them quietly later.

Then, if they want more

The contract would say that the Idempotency-Key header is required on every money-moving request, keys are scoped per partner, and they are honoured for a documented retention window, say seven days.

It would define every case: a retry with the same key and body gets the original response, a retry while processing gets 409 with Retry-After, the same key with a different body gets 422, and a key older than the window is a new request.

These semantics are part of the API version, pinned by contract tests, and only changed in a new version with a long deprecation period. The risks of getting it wrong are concrete: double charges mean financial loss, chargebacks and possibly regulatory issues, and a retention window shorter than partners' real retries, like overnight batch resubmissions, turns those retries into duplicates.

I would also make sure our architecture can keep the promise globally, for example by homing each partner to a region or using a global key store, so a retry after a regional failover still finds the original. And I would keep request hashes and outcomes for the retention period and beyond, so disputes are settled with evidence.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your company is exposing a public payments API to partners. As the senior technical...": https://scrivio-interview-library.netlify.app/spring-boot/distributed-data/e5db389daa/