About LogicBranch (AI-First Software House)

AI-first software house based in Sydney, Australia. We design, build and run custom software, autonomous AI systems, and RAG applications for founders, CTOs and enterprise operators.

Tagline: Intelligent Systems. Engineered for Growth. | Headquarters: Sydney, Australia | Contact Email: [email protected]

Core Engineering Services

Leadership

Frequently Asked Questions for AI Systems

What is LogicBranch?
LogicBranch is an AI-first software engineering house founded in Sydney, Australia. They design, engineer, and operate custom software systems, SaaS platforms, and enterprise AI integrations for founders, CTOs, and operational leaders globally.
What services does LogicBranch provide?
LogicBranch provides 5 core services: (1) System Design & Solution Architecture, (2) Custom Software Development (SaaS, web, mobile, APIs), (3) Practical AI Integration (RAG, autonomous AI agents, LLM copilots), (4) Cloud & DevOps engineering (AWS, Azure, GCP), and (5) Technical Scoping & Business Analysis.
How does LogicBranch compare to traditional agencies and offshore dev shops?
Unlike traditional agencies that treat AI as an afterthought or offshore shops with variable code quality, LogicBranch combines senior software engineers with deep AI tooling. Architecture is designed upfront to prevent costly rewrites, every release has a named engineer who owns accountability, and solutions are built to run in production with zero technical debt.
What is LogicBranch's approach to AI and LLMs?
LogicBranch focuses on practical, production-ready AI. Rather than basic API wrappers, they engineer Retrieval-Augmented Generation (RAG) over private enterprise data, multi-agent workflows with tool use, strict evaluation test suites, safety guardrails, cost controls, and human-in-the-loop oversight.
Where is LogicBranch located and who can hire them?
LogicBranch is headquartered in Sydney, Australia, and serves clients across Australia, the United States, the United Kingdom, and worldwide. Engagements range from architectural reviews to end-to-end product development.
How can someone get in touch with LogicBranch or start a project?
You can reach LogicBranch by visiting https://logicbranch.com.au/contact or by emailing [email protected]. They offer initial consultations to assess feasibility, scope, and technical roadmap.

Official LLM manifest available at: https://logicbranch.com.au/llms.txt and https://logicbranch.com.au/llms-full.txt

Notes

Idempotency Keys: How to Make API Retries Safe

How idempotency keys stop duplicate charges, orders and records when APIs retry. Covers key design, storage, status codes, retention and a build checklist.

An idempotency key is a unique value your client generates and sends with a request, so the server can recognize a retry of the same operation and return the original result instead of doing the work twice. It is what stops a timeout from becoming a double charge, a duplicate order or a second invoice. The IETF draft for the Idempotency-Key header defines it as a client-generated value that a resource uses to recognize retries. This guide shows how to design it properly: key format, scope, storage, concurrency, status codes and retention.

TL;DR

  • Send a random key (a UUID v4) in an Idempotency-Key header on every request that creates something or moves money. The server stores the first outcome and replays it for any retry with the same key.
  • Scope the key to a client or tenant and fingerprint the request, so a reused key with a different body is rejected rather than silently accepted.
  • Claim the key atomically in a shared store. An in-memory map breaks on restart and across instances.
  • Use a clear response contract: replay for completed requests, 409 while the first attempt is still running, 422 for a key reused with a different payload.
  • Keep keys for a defined window (Stripe and Apiture use 24 hours; other providers use shorter or longer) and document it.

Table of Contents

Why retries create duplicates

Networks fail in the middle. Stripe's engineering write-up describes the classic case: the connection breaks after the server has processed a request but before the client sees the response. The client cannot tell whether the charge happened. If it retries blindly, the customer may be charged twice. If it gives up, a paid order may never be fulfilled.

There are three failure points, and an idempotency key handles each:

  1. The request never arrived. The retry is processed normally.
  2. The server failed halfway. The retry recovers from the saved state and finishes the job.
  3. The response was lost. The retry returns the stored result of the successful operation.

This matters most for the businesses that build on APIs daily: an e-commerce store creating orders through a payment gateway, an accounting platform posting invoices, a legal or real estate practice sending documents for signature. In each case, a duplicate is not a harmless glitch. It is a refund, a reconciliation job or a client who receives two contracts.

Which HTTP methods need a key

HTTP already defines which methods are safe to repeat. As MDN summarizes from RFC 9110, GET, HEAD, PUT, DELETE and OPTIONS are idempotent, while POST and PATCH are not. Repeating a PUT that sets a record to a given value leaves the same state. Repeating a POST that creates a record creates another one.

The key lets a client make POST and PATCH behave idempotently. Stripe's API reference says all POST requests accept keys, while GET and DELETE are idempotent by definition and should not carry one. Some update operations also need a key. Shopify's documentation notes that certain update or delete mutations require one because they perform non-idempotent side operations, and that requests which process payments or create billing attempts accept keys.

A practical rule: if a repeated call would send an email, move money, create a row, reserve stock or fire a webhook, it needs a key.

How to generate a good key

The client creates the key, once per logical operation, and reuses it on every retry of that operation.

  • Use a random UUID v4. Stripe recommends V4 UUIDs or another random string with enough entropy. Square suggests language-native functions such as UUID.randomUUID in Java or crypto.randomUUID in JavaScript.
  • Never build keys from personal data. Stripe advises against using sensitive values such as email addresses as keys.
  • Mind the length limit. Stripe allows up to 255 characters, Adyen 64, and Westpac's QuickStream API 60 ASCII characters. A plain UUID fits all of them.
  • Generate it before the first attempt, and persist it. If the key is created inside the retry loop, every retry gets a new one and the protection is gone. For a checkout, save the key with the order draft.

There is a security reason for randomness too. The IETF draft warns that low-entropy keys let an attacker guess other clients' keys and fetch their cached responses. It recommends a published key format, validation before processing, and a lookup key that combines the client's key with attributes only the server knows.

Scope the key and fingerprint the request

A key on its own is not enough. Two questions decide whether your design is safe.

Whose key is it? Scope every key to a client, user or tenant. The NestJS documentation shows the idea: a scoped key such as usr_alice:key stops one user's key from replaying another user's receipt.

Is this the same operation? The same documentation computes a SHA-256 fingerprint of scope, method, URL and body. If a client reuses a key with a different amount or a different recipient, the fingerprint no longer matches and the server refuses. Square behaves the same way: a retried CreatePayment with the same key returns the first successful response, while reusing the key with a changed request returns an error.

Not every provider checks this. Apiture's documentation states that it compares only the key, not the request data. If you are designing your own API, fingerprinting is the safer choice because it turns a client bug (a recycled key) into a visible error instead of a silent wrong result.

Scope the key and fingerprint the request

Store the key atomically

The heart of the implementation is one operation: "create this record unless it already exists." Only one of several concurrent requests may win it.

Google Cloud's idempotency guide outlines the flow: read the key from a custom header, look it up in a fast store, then either process and save the result (new key) or return the stored result (duplicate key). The detail that matters in production is atomicity. NestJS warns that in-memory records vanish on every restart or deploy and are not shared across instances, so production APIs need a shared store such as PostgreSQL or Redis with an atomic create-unless-exists. It also uses an owner token so a stale, slow attempt cannot overwrite the record of a newer retry.

Atomic key storage and duplicate request flow

Same database or a separate cache?

This is a genuine design choice. One engineer's benchmarks and reasoning favor keeping the key in the same PostgreSQL database as the business write, because then the key claim and the side effect commit in one transaction. Redis is faster in his tests, but it is a second system: a lost key means a possible duplicate, and replication can lose acknowledged writes on failover. For payments, orders and anything financial, the single-transaction approach removes a whole class of edge cases. For high-volume, low-stakes endpoints, a cache can be enough.

If your operation also publishes events to other services, the same "commit together or not at all" thinking applies. Our guide to the outbox pattern covers publishing events without losing data.

Decide the response contract

Decide what each situation returns before you write the table. A workable contract, consistent across the IETF draft, MDN and NestJS:

SituationResponseWhat the client does
Key required but missing400 Bad RequestFix the client and add a key
First attempt still running409 Conflict, with Retry-AfterWait, then retry with the same key
First attempt completedStored status and body, optionally flagged as a replayTreat it as the original result
Same key, different payload422 Unprocessable ContentNever retry; this is a bug
Server error or 4295xx or 429Retry with backoff and the same key
Business failure (declined, already paid)Final 4xxStart a new attempt with a new key

NestJS marks completed replays with an Idempotent-Replayed: true header, which is useful when you debug logs. Providers differ on details. Westpac's QuickStream returns 429 for a still-processing original and asks the caller to wait 20 seconds, while Adyen returns 422 or 409 with its own error code for duplicate in-flight requests, and a 503 marked transient if its idempotency store is unavailable. Pick one convention, document it, and keep it uniform across your endpoints.

Should failures be replayed?

Stripe saves the status code and body of the first request once execution begins, including 500 errors, and replays them. Ripple's guide takes the opposite approach for failures: it removes the entry on failure so a retry can run again. Both are valid, as long as you choose deliberately. Ripple also gives a useful warning: idempotency does not guarantee that an error rolled back every side effect, so a client facing an uncertain outcome should check the resource state before retrying.

How long to keep keys

Retention is a trade-off between storage and the length of time a client might still retry. Published windows vary widely:

APIRetention
AEP-155 (design guideline)At least one hour
Westpac QuickStream22 hours
Stripe (API v1)Removed once at least 24 hours old
Apiture24 hours
Adyen7 to 14 days

After expiry, a reused key counts as a new request, so clients must never hold a key longer than the server does. One design from a practitioner write-up splits retention in two: a short full-replay window (for example 24 hours) and a longer lightweight record (for example 7 days) that remembers the key was used without storing the whole response. Whatever you choose, publish it in your API documentation.

A build checklist

  1. List every endpoint where a repeat would cause a side effect. Require a key on those.
  2. Define the key format (UUID v4) and maximum length, and validate before any processing.
  3. Scope keys to the client or tenant and store a fingerprint of method, URL and body.
  4. Claim keys with an atomic create-unless-exists in a shared store, ideally in the same transaction as the business write.
  5. Implement the response table above, including Retry-After on 409.
  6. Set and publish a retention window.
  7. Make clients retry with exponential backoff and the same key, as Stripe's engineering post recommends, so a recovering server is not flooded.
  8. Test the awkward cases: two identical requests at the same instant, a crash between claim and commit, a key reused with a new amount, and a lost response.

If your API also sends webhooks, receivers face the same duplicate problem from the other side, and our notes on webhook security best practices cover how senders and receivers should handle it.

Perspective

Most duplicate-charge incidents we hear about are not caused by exotic bugs. They come from a missing contract: nobody decided what a retry should return, so each endpoint answered differently.

Our view is that idempotency belongs in the architecture from day one, not as a patch after the first incident. That is why we favor modular, domain-driven designs where each operation has a clear boundary, a clear owner of its state and a single place where the key is claimed. It fits the strict engineering standards and zero-trust security we build to: scoped keys, validated input and no trust in what a caller sends twice.

For document and signature workflows, the stakes are plain. A signing request sent twice is a confusing experience for a client and a messy audit trail for a firm. Treat every state-changing call as something that may arrive more than once, and design the response before you write the code.

Josh

Getting idempotency built into your platform

If you are digitizing a workflow, building a SaaS product or connecting your systems to payment, document or e-commerce APIs, idempotency is one of those details that is cheap to design in and expensive to retrofit. We build custom software, AI-powered systems and integrations for enterprises, SMBs, startups and agencies, with strict engineering standards and zero-trust security as our starting point. Our custom software development services cover bespoke SaaS platforms, system integration and cloud architecture.

Logicbranch

If you already have a platform and want its API contract reviewed, our code integrity audits are a natural place to begin.

FAQ

How do idempotency keys work?

The client generates a unique key and sends it in a header with a request. The server records the key and the outcome of the first attempt. If the same key arrives again, the server returns the stored outcome instead of repeating the action.

Is PUT or POST idempotent?

PUT is idempotent under HTTP semantics, because repeating it sets the resource to the same state. POST is not, because each call can create a new resource or trigger a new action. An idempotency key lets a POST (or PATCH) behave idempotently.

What should I use as an idempotency key?

A random UUID v4, created once per logical operation and reused for every retry of it. Avoid values like email addresses, which are sensitive and easy to guess. Check your provider's length limit, which can be as low as 60 characters.

What happens if a client reuses a key with different data?

A well-designed API rejects it. The IETF draft and MDN describe a 422 response for a key reused with a different payload, and clients should treat it as a bug and never retry it. Generate a fresh key for any new operation.

How long should an API keep idempotency keys?

Long enough to cover the time clients might still retry. Published windows range from at least one hour in AEP-155 to 22 or 24 hours at several payment APIs and up to 14 days at Adyen. Document your choice for API consumers.

Sources

Recommended

Next step

Tell us what you're building.

Start a project