Duplicate Gift Card Orders: How Idempotency Keys Help

Timeout → Same key → One order
In short: A timeout on a gift card API order means you did not get a reply, not that the order failed. Send the retry with the same idempotency key. The platform then matches the repeat to the original order and returns that result, instead of issuing a second set of codes.

What happens if your order request times out

Your order may already exist. A timeout only tells you that no reply arrived in time.

It does not tell you whether the gift card was issued. The two are separate events.

The safe move is to retry with the same idempotency key you sent the first time.

The platform then matches the repeat to the original order. It returns that order rather than issuing again.

Without that key, a retry can look like a fresh purchase. That is how duplicate issuance starts.

Why a retried order can issue value twice

An order request crosses several steps before you see a response.

The request reaches the platform. Validation runs. The order is accepted. Value is issued. A response travels back.

A network timeout can land after any of those steps. Your side sees the same blank result either way.

So a retry sent without a shared reference is ambiguous by design. The platform has no way to link it to the earlier call.

Two accepted orders then mean two sets of codes. One of them was never intended.

Why this matters beyond the code itself

A duplicate order is not only an operational annoyance. It creates value that someone must account for.

Issued value rises. Redeemed value may not. The gap shows up in outstanding liability reporting later.

Settlement also drifts. The partner was invoiced for stock it did not order.

What an idempotency key actually is

An idempotency key is a unique value the partner generates for one intended order.

It is created before the order exists. That is the whole point.

The partner sends it with the order request. The platform stores it against the resulting order.

If the same key arrives again, the request is treated as a repeat. The stored result is returned.

An order ID cannot do this job alone. The platform creates the order ID after acceptance, so a timed out first attempt leaves the partner with nothing to quote.

Picking a key that behaves

A good key is unique per intended order, not per attempt.

Reusing one key across genuinely different orders is also a problem. The second real order may be refused as a repeat.

So tie the key to your own order record. One purchase intent, one key, many attempts if needed.

Where idempotency sits in the API lifecycle

Valuedesign describes its distribution API flow as authenticate, fetch catalogue, place order, then fulfil and reconcile.

Duplicate risk is not spread evenly across those steps. It concentrates at one of them.

StepWhat it doesDuplicate riskMain control
AuthenticateEstablishes partner-scoped accessLow, nothing is issuedAccess scope and credentials
Fetch catalogueReturns products, SKUs and denominationsLow, the call only readsCatalogue and SKU governance
Place orderCommits product, SKU, amount and partner contextHigh, value can be createdIdempotency key, validation, limits
Fulfil and traceIssues approved digital value and records the traceMedium, repeats may appear as two tracesException handling and status query
ReconcileMatches orders, inventory and settlement contextLow, but it exposes earlier errorsMIS trace and reporting

Read it as one rule. Reads are safe to repeat, and writes need a key.

The distribution API pages and the distribution API guide describe this same sequence for partners.

Validation and limits do a different job

Idempotency handles the repeat of one intended order. It does not judge whether the order made sense.

That is where the other controls come in. Valuedesign lists validation, idempotency, limits and exception handling together for a reason.

  • Validation checks product, SKU, denomination and partner context before anything is issued.
  • Idempotency matches a repeat request to the order it belongs to.
  • Limits cap how much value one partner can order in a window.
  • Exception handling gives the partner a usable answer when the result is unclear.

Each one catches a case the others miss.

Say a retry loop escapes key matching because of a bug on the partner side. Validation will not stop it, since every request is well formed.

A limit will. It ends the run early and turns a large exposure into a small exception.

A worked example of a retry that stays safe

Let's take a simple example. The names and numbers here are an illustration only.

Say a B2B reseller places an order for 200 units of a game top up SKU through a distribution API.

The reseller creates one key for that order, for example a value tied to its internal order record.

The request goes out. The platform validates the SKU and denomination, accepts the order, and starts issuance.

The response is then lost on the way back. The reseller sees a timeout.

The reseller retries the same request, with the same key attached.

The platform recognises the key. It returns the original order and its status instead of creating a second one.

Issued value stays at 200 units. Reconciliation matches cleanly at month end.

Now change one detail. Remove the key.

The second request looks new. The reseller holds 400 units, pays for 400, and sells 200.

The rest sits as unsold stock and as outstanding liability on the issuer side.

What exception handling should return

Good error behaviour is part of duplicate prevention. A vague error invites another retry.

The response to a recognised repeat should make three things clear.

  1. That the request was matched to an existing order.
  2. The order reference and its current status.
  3. Whether fulfilment is complete, pending or failed.

A pending status needs its own path. The partner should be able to query the order by the key or reference, rather than resending it.

The partner side also needs a stopping rule. Retry a small number of times, with a short wait between attempts, then escalate.

When escalating, quote the key, the timestamps and the SKU. That gives the support team enough to trace the order.

What to check before you go live

Most duplicate order problems are found in testing, not in production.

  • Generate one key per intended order, stored with your own order record.
  • Send the key on every attempt for that order, including the first.
  • Never reuse a key for a different product, SKU or amount.
  • Handle the repeat response as a success path, not as an error.
  • Test a forced timeout and confirm that a retry creates no second order.
  • Confirm that your limits are set at a level your real order volumes respect.
  • Check that the MIS trace shows one order, not two, after the retry test.

Catalogue hygiene supports this too. Stale SKUs cause failed orders, and failed orders cause retries, as covered in keeping a gift card catalogue in sync by API.

Technical references sit in the developer API center, and the control framing of prevent, detect, respond and evidence sits in the trust center.

How this shows up in reconciliation

Reconciliation is where a duplicate order becomes visible to finance.

The order count, the issued value and the settlement figure stop agreeing.

For a publisher, the same noise distorts a channel view. A channel can look busier than its real player demand, which matters when reviewing channel performance.

So the cleanest reconciliation starts at the order step, not at the report.

Valuedesign works with marketplaces, fintechs and wallets, rewards platforms, B2B resellers and gaming partners through this same order and reconcile flow.

Talk to Valuedesign

If you are building or reviewing an order integration, the retry path deserves a proper test plan. Contact Valuedesign to discuss idempotency, limits and exception handling for your distribution setup.

Frequently asked questions

What is an idempotency key on a gift card API?

It is a unique value the partner generates for one intended order. The partner sends it with the order request. If the same key arrives again, the platform treats the call as a repeat of the first order, not as a new one.

Does retrying a timed out order create a second gift card?

It can, if the retry carries no idempotency key. The platform sees a fresh request and may issue again. With the same key attached, the repeat is matched to the original order and the original result is returned.

Is an order ID the same as an idempotency key?

They serve different purposes. The partner creates the idempotency key before the order exists, so a retry can be matched. The order ID is created by the platform after the order is accepted, and is used for tracing and reconciliation.

What should an API return for a repeat request?

It should return the original order and its status, with a clear signal that the request was recognised as a repeat. A plain error with no reference leaves the partner guessing, and guessing often leads to another retry.

How do limits help when retries loop?

Limits cap how much value one partner can order in a window. If a retry loop escapes idempotency matching, the limit stops the run early. That turns a possible large exposure into a small, reviewable exception.

What should a partner do when the status stays unclear?

Stop retrying after a small number of attempts. Query the order by the idempotency key or order reference instead. Then raise an exception with timestamps and the key, so the order can be traced and closed.