A client reads a record. A person or a job spends a few seconds, or a few minutes, changing it. Then the client writes the whole record back. If another writer saved in between, the second save silently erases the first. Both requests return success, and nothing in the logs looks wrong. This is the lost update problem, and it is a common source of unexplainable data drift in multi-tenant SaaS APIs.
This article is for tech leads and senior engineers who own a write API. It covers three things. First, how strong validators such as ETag and If-Match detect stale writes. Second, why the check must run inside the datastore write, because read-compare-then-write is not compare-and-swap. Third, how to keep retries and timeouts from turning one stale write into duplicate or conflicting changes.
Two scope notes. The conditional-write contract described below is a proposed design for you to adapt and test. It is not a certified standard, and we are not claiming every system already uses it. All code is illustrative. It shows the invariants, not an official API contract for any specific database or framework.
Key Takeaways
- Bottom line: Any write that is computed from a previously read state needs a precondition that the datastore evaluates atomically as part of the write.
- HTTP scope:
ETag,If-Match,412, and428apply to HTTP. For queues, gRPC, GraphQL, and background workers, carry an explicit expected-version field and enforce it the same way.- Not a CAS: Select, compare in application code, then update leaves a race window. Put the comparison in the
WHEREclause or condition expression of the write itself.- Tenant safety: Include the tenant in every predicate and in every validator scope. Identifiers such as version counters and content hashes can leak information, so treat them as sensitive.
- Retries: After an ambiguous timeout, a
412does not tell the client whether its own write applied. Reconcile with a durable, tenant-scoped operation record bound to a payload hash.- Rollout: Use go/no-go controls, not a weighted score. Start in shadow mode, measure your own would-have-conflicted rate, then enforce.
Why Lost Updates Happen, and Why Multi-Tenancy Raises the Stakes
Key takeaway: Lost updates come from any gap between reading state and writing it back. More writers (humans, integrations, jobs, automation) widen that gap, and shared tenant data makes the damage harder to see.
The mechanism is simple. A client performs read, modify, write. Between the read and the write, the server state changes. The write then overwrites the newer state with a value computed from the older one. The MDN guide to HTTP conditional requests describes this as a race whose winner changes from run to run, which is why it is so hard to debug.
Multi-tenancy changes the picture in three ways. Shared tenant objects such as workspace settings, billing profiles, role mappings, and routing rules are edited by several administrators and several integrations at once. Automation volume is higher, since a tenant's import job, a sync connector, and an admin console can all target the same record. And detection is weaker: an audit log shows two successful writes, so the loss only surfaces when a customer reports that a setting reverted.
Who writes, and how long is the read-to-write gap?
| Writer type | Typical read-to-write gap | How the loss appears |
|---|---|---|
| Browser form or admin console | Seconds to hours (a tab left open) | An admin saves a stale form and reverts a colleague's change |
| Mobile or offline-capable client | Minutes to days | A sync pushes an old full-object snapshot |
| Partner integration or connector | Seconds to minutes | Periodic full-record PUT overwrites fields edited in the UI |
| Background job or bulk import | Milliseconds to minutes | A batch computes new values from rows that changed mid-run |
| AI agent or workflow automation | Seconds, with retries | A plan built from an old read is applied after state moved on |
An illustrative scenario
Illustrative only, not a customer result. Suppose a tenant's notification-routing configuration is a single JSON document. At 10:00:00 an admin opens it in the console. At 10:00:20 a sync connector reads it, adds three routes, and writes it back. At 10:01:10 the admin saves a change to one route from the copy loaded at 10:00:00. Both saves return 200. The three connector-added routes are gone, and no component has an error to report.
If your system already enforces tenant isolation at the database level, as described in our guide to multi-tenant database architecture and isolation trade-offs, lost updates are a separate problem. Isolation keeps tenants apart. It does not stop two writers inside one tenant from overwriting each other.
How Most Teams Handle It, and Why Those Approaches Break
Key takeaway: Most existing defenses protect the common path and fail under concurrency: last-write-wins, application-level timestamp checks, and long-held locks each leave a gap.
Teams rarely ignore the problem entirely. They usually apply a partial fix. The table below compares the usual approaches and where each stops working.
| Approach | What it protects | Where it breaks |
|---|---|---|
| Last-write-wins (no precondition) | Nothing; it is simply the default | Silent data loss under any concurrency |
updated_at compared in app code | Slow, human-speed conflicts | Coarse timestamp resolution, clock skew, and a race between the check and the write |
| Read, compare, then write (two statements) | Most sequential conflicts | A second writer commits between the two statements; both succeed |
| Version field in the request body that the server never enforces | Documentation value only | Clients omit it, background paths ignore it |
| Pessimistic lock held across HTTP requests | Strict exclusion | Abandoned locks, lock expiry races, poor fit for stateless APIs |
| Conditional write evaluated by the datastore | Writes based on stale reads | Needs client cooperation and a conflict-handling workflow (see below) |
Read-compare-then-write is not compare-and-swap
The most common near-miss looks safe in a code review because the comparison is right there:
// Anti-pattern (illustrative): the check and the write are two separate steps row = db.select(tenantId, id) if (row.etag != presentedEtag) return 412 db.update(tenantId, id, newBody) // A second writer can commit between select and update, and both requests succeedThe comparison must be evaluated by the target system as part of the mutation. That is what a conditional UPDATE ... WHERE etag = ? or a condition expression gives you. If your datastore offers no conditional-write primitive, you have two honest options: serialize all writes per resource through a single writer, or document the limitation and the residual risk. Do not describe an application-level compare as atomic.
Pessimistic locking has its place for short, in-transaction critical sections. It is a poor fit for the human-speed gaps in the table above, where a lock would have to survive a browser tab, a retry, and a network partition.
A Proposed Conditional-Write Contract for Tenant-Safe APIs
Key takeaway: Treat the validator as part of the resource contract. Define who must send it, what happens when it is missing, stale, or malformed, and where the check runs.
The following rules form a proposed design. Adapt them to your stack, then verify them with concurrency tests before depending on them.
The rules
- Expose an opaque, tenant-scoped validator. Return an
ETagon reads. Treat it as opaque: the HTTP semantics specification (RFC 9110) defines an entity tag as an opaque validator, not a revision number with arithmetic meaning. - Require the validator on writes derived from prior state. On HTTP, that is
If-MatchonPUT,PATCH, andDELETEof shared, multi-writer resources. On other transports, require anexpected_etagorexpected_versionfield. - Use strong comparison only.
If-Matchuses strong comparison, so a weak tag (prefixedW/) never matches. If a proxy or compression layer weakens your tags, conditional writes will fail in production even though they pass in local tests. - Answer a missing precondition with
428, if you adopt it. RFC 6585 defines428 Precondition Requiredfor exactly this lost-update case, but notes the status code is optional and clients cannot rely on it. Document your policy rather than assuming clients follow it. - Answer a false precondition with
412. The server must not apply the change. The response should tell an authorized same-tenant client how to refetch, and nothing more. - Run the check inside the write. Use a conditional
UPDATE, a condition expression, or an expected-stream-version append. Never a separate read. - Put the tenant in every predicate. A request for another tenant's object should behave like a request for a missing object. This is the object-level authorization concern described in the OWASP API Security Top 10 entry on broken object level authorization.
- Give side-effecting writes an operation identity. The conditional write handles concurrency; the operation record handles retries (next sections).
Status mapping
| Situation | Suggested response | Client action |
|---|---|---|
| Validator required but absent | 428 (or 400 if you do not adopt 428) | Fetch the resource and resend with If-Match |
| Validator malformed or weak | 400 for malformed; 412 for weak (it never matches) | Use the exact strong tag from the last read |
| Validator stale | 412 | Refetch, reconcile, decide whether to resubmit |
| Resource missing or in another tenant | 404 | Stop; do not probe |
| Validator matches but a business rule rejects the change | 409 or 422 (your convention) | Fix the request; retrying the same payload will not help |
| Applied | 200 or 204 with a new ETag | Store the new validator |
What the exchange looks like
GET /v1/projects/p_42/settings 200 OK ETag: "b81f03c9d2" PUT /v1/projects/p_42/settings If-Match: "b81f03c9d2" Idempotency-Key: op_01HZ-example 412 Precondition Failed (someone else saved first; nothing was applied)Idempotency-Key is a widely used convention. Its standardization has been in progress as an IETF draft, so verify its current status before you cite it as a standard in your own documentation. Whatever the header is called, the semantics (tenant scope, payload binding) are yours to define and document.
Making the Check Atomic: Patterns by Storage Engine
Key takeaway: Pick the conditional primitive your datastore actually provides, and know what a failed condition looks like in code. If there is no such primitive, say so and serialize.
| Datastore pattern | Conditional mechanism | Failure signal | Caveat |
|---|---|---|---|
| Relational (PostgreSQL) | UPDATE ... WHERE tenant_id = ? AND id = ? AND etag = ? | Zero rows affected | Isolation level changes how concurrent updates surface (see below) |
| Key-value or wide-column (DynamoDB-style) | Condition expression on the write | Conditional check failure | Put the tenant in the key; verify per-operation semantics in the vendor docs |
| Event-sourced aggregate | Append with expected stream version | Version conflict on append | Rebuild decision from new events, do not just retry |
| Datastore without conditional writes | Single-writer queue per resource key | Ordering, not rejection | Document throughput and head-of-line risk |
| Search index or cache copy | None (never the authority) | Not applicable | Never take a validator from a replica or cache that can lag |
PostgreSQL: guard in the WHERE clause
-- Illustrative PostgreSQL: the guard lives inside the write UPDATE project_settings SET body = $4, etag = $5, -- new random opaque token generated by the server updated_at = now() WHERE tenant_id = $1 AND id = $2 AND etag = $3 -- presented validator RETURNING etag; -- 1 row: applied. -- 0 rows: stale validator, missing row, or another tenant's row. -- Choose 412 vs 404 with a tenant-scoped diagnostic read after the fact. -- That read is for the error message only. It is never the guard.Under the default Read Committed level, the PostgreSQL transaction isolation documentation explains that an UPDATE that had to wait on a concurrent update re-evaluates its WHERE clause against the newly committed row version. A stale validator therefore matches nothing. Under Repeatable Read, a concurrent update to the same row raises a serialization error instead, and the application must retry the whole transaction. Know which of the two your connection uses, and test both outcomes.
Key-value stores: condition expressions
// Illustrative pseudocode shaped like a DynamoDB UpdateItem request Key: { pk: "TENANT#t_9", sk: "SETTINGS#p_42" } UpdateExpression: "SET body = :body, etag = :newEtag" ConditionExpression: "attribute_exists(pk) AND etag = :presented" // A conditional-check failure means stale or missing. // Map it to 412 or 404 only after a tenant-scoped read.The DynamoDB condition expression documentation describes this model: the condition is part of the write request. Confirm exact behavior, such as consumed capacity on failed conditions and what comes back on failure, for the service and SDK version you use.
Random token or version counter?
A random opaque token regenerated on every write is the safer default. A monotonic counter is convenient for ordering and debugging, but it is guessable, reveals write activity, and invites clients to do arithmetic on it. If you need ordering, keep an internal revision column and do not expose it. A content hash is tempting because it needs no extra column, but it makes the validator an equality oracle for anyone who can guess the content, and it forces you to serialize identically across every code path.
Retries, Timeouts, and Operation Identity: Where a 412 Becomes Ambiguous
Key takeaway: A conditional write stops conflicting writers. It does not tell a client whether its own earlier attempt applied. For consequential mutations, reconcile before retrying, and bind a tenant-scoped operation ID to an immutable payload hash.
The ambiguity
Consider a client that sends PUT with If-Match: "A". The server applies the change, moves the validator to "B", and the response is lost. The client times out and resends the same request with If-Match: "A". The condition is now false, so the server answers 412. The client cannot tell whether someone else changed the resource or its own first attempt succeeded. RFC 9110 allows a server that has verified the requested change is already reflected in current state to respond with a 2xx instead of 412. A server can only do that safely if it has recorded which operation produced the current state.
An unknown result means completion could not be confirmed. It is not success, and it is not verified failure. Clients, queues, and dashboards should carry that third state explicitly. Our detailed guide to ambiguous timeouts and reconcile-before-retry design covers the client side. The server-side building block is an operation record.
Operation record requirements
- Tenant-scoped identity. The uniqueness key is
(tenant_id, operation_id). The same ID from two tenants is two unrelated operations. - Immutable payload binding. Store a keyed hash of the canonicalized, approved payload. If the same operation ID arrives with a different payload hash, reject it. Never silently apply or replay it.
- Atomic claim. The claim, the conditional mutation, and the recorded result commit in one transaction. Two workers presenting the same operation ID cannot both apply it.
- Legitimate later operations. A deliberate second change to the same resource gets a new operation ID and the validator from a fresh read. It is not a duplicate.
- Authoritative reconciliation. Offer a way to look up an operation's outcome by ID, scoped to the tenant, so clients can reconcile instead of guessing.
-- Illustrative PostgreSQL: claim, guarded write, and result in one transaction BEGIN; INSERT INTO operation_ledger (tenant_id, operation_id, payload_hmac, target_id) VALUES ($1, $2, $3, $4) ON CONFLICT (tenant_id, operation_id) DO NOTHING; -- 0 rows inserted: another transaction holds or committed this operation id. -- Read the existing row for this tenant. -- Same payload_hmac: return the recorded result (a replay, not a second apply). -- Different payload_hmac: reject, the operation id was reused with a changed payload. UPDATE project_settings SET body = $5, etag = $6 WHERE tenant_id = $1 AND id = $4 AND etag = $7 RETURNING etag; -- 0 rows: ROLLBACK (the claim rolls back with it) and respond 412. UPDATE operation_ledger SET result_etag = $6 WHERE tenant_id = $1 AND operation_id = $2; COMMIT; -- A committed ledger row therefore always means the mutation was applied.In PostgreSQL, a concurrent insert of the same unique key waits on the other transaction's outcome. Confirm the equivalent behavior in any other engine, and test it with two real connections rather than assuming it. This pattern extends the ideas in our production-ready idempotency framework. If a background worker performs the write, pair the operation record with the lease and fencing-token controls in worker leases and fencing tokens. A stale lease holder must fail the conditional write, not just the lease check.
Queue consumers and asynchronous callers
When the write is driven by a message or a workflow step, the HTTP status codes still help, but the acknowledgment rules matter more. The message is acknowledged only after the conditional write and its operation record have committed.
| Outcome | Meaning | Consumer action | Acknowledge? |
|---|---|---|---|
| Applied, ledger committed | Verified success | Emit downstream events via outbox | Yes |
| Ledger replay, same payload hash | Already applied earlier | Return recorded result | Yes |
| Same operation ID, different payload hash | Terminal contract violation | Route to a quarantine queue with an alert | Yes, after quarantine is recorded |
412 on a message built from an old read | Terminal for this message: its base state is gone | Send to a conflict-review path or rebuild the intent from fresh state under a new operation ID | Yes, after routing is recorded |
| Timeout or connection reset | Unknown | Look up operation status by ID before any retry | No, until reconciled |
| Malformed or missing validator on a protected resource | Uncertain input | Fail fast, never guess a validator | Yes, to a dead-letter path with the reason |
For dead-letter handling and safe re-drive, see our dead letter queue redrive playbook. If the mutation was authorized by a human or policy, the approved payload hash must travel with the operation. Our design for approval-gated AI agent actions shows how approval binds to a specific payload. A 412 on an approved action means the approval no longer matches current state and should be re-requested.
Privacy ownership
Operation IDs, validators, and payload hashes are identifiers, and identifiers can be sensitive. Decide who owns them before you ship:
- Hash payloads with a keyed hash (HMAC) using a per-tenant key. A plain hash of low-entropy content can be guessed by brute force.
- Store the hash, not the payload, in the ledger unless you need the payload for replay.
- Keep ledger retention no longer than the retry and reconciliation window you actually support.
- Include the ledger in tenant data export and erasure workflows. See verified erasure workflow design for the broader pattern.
- Do not write full validators, operation IDs, or customer-derived values to shared logs without a retention decision.
Why This Fails in the Real World
Key takeaway: Teams that understand optimistic concurrency still ship gaps, because the invariant spans several code paths and no single owner or test covers all of them.
Failure pattern 1: the side door
The public API enforces If-Match. The bulk-import service, a admin script, and an internal batch job call the service layer or the database directly, without a validator. The conflict window moves from the UI to the importer, which has the highest write volume. Nobody made a bad decision. The precondition lived in the controller, and the invariant belonged to the resource. Fix: enforce the conditional write in the data-access layer that every path shares, and make unconditional writes to protected resources impossible by construction.
Failure pattern 2: the validator that means less than it seems
The ETag is computed from a serialized subset of fields, or the JSON serializer does not produce stable ordering. Two different states can share a tag, or one state can produce two tags. Separately, a compression layer or intermediary converts strong tags to weak tags, and every If-Match starts failing, or a well-meaning engineer relaxes the comparison to weak to make the errors stop. Because staging often lacks the production edge, tests pass. Fix: use a stored random token that changes on every committed write, and run the conditional-write tests through the real edge path.
Failure pattern 3: the helpful auto-retry
A client SDK handles 412 by refetching and resending the user's original body with the new validator. It looks like resilience. It recreates last-write-wins with extra steps, because the stale edit is applied over the newer state without any merge decision. Fix: treat 412 as a conflict that requires either an explicit merge or a user decision. Auto-resubmit is acceptable only for operations you have proven commutative.
Failure pattern 4: the hot row
Once enforcement is on, a shared record that many workers update, such as a counter, a status summary, or a tenant-wide quota, produces a storm of 412 responses and retries. The team concludes that conditional writes do not scale. Fix: optimistic concurrency suits low-contention, human-speed records. Contended aggregates should use commutative or append-only designs, such as increments or per-writer rows rolled up later.
Why intelligent teams still miss these
- Unit tests run one writer at a time, so a race never appears.
- The contract was written for the UI team, not for the connector, job, and agent teams.
- Success responses look identical for a correct write and a lossy one, so dashboards stay green.
- Nobody owns the cross-path invariant, so each team assumes another enforces it.
Trade-offs to accept openly
| Cost | Why it exists | Mitigation |
|---|---|---|
| Client friction | Callers must store and send validators | Report-only rollout, clear 428 messages, SDK helpers |
| More conflicts surfaced | Conflicts that used to be invisible are now errors | Provide diff or refetch endpoints for authorized users |
| Contention on hot rows | Only one writer wins per round | Use commutative updates or split the aggregate |
| Extra storage and retention duty | Operation ledger and tokens | Bounded retention, tenant-scoped erasure |
| Partial protection for patches | Disjoint-field PATCH may be safe without a validator, but only if the changes are independent | Declare per field group whether a precondition is required |
Test the interleaving, not just the code
Write a deterministic concurrency test for every protected resource. Two transactions both read validator A. Writer 1 commits. Writer 2 attempts its write with A. The test passes only if writer 2 is rejected and writer 1's data survives. Then add a second test: the same operation ID is submitted twice concurrently, and exactly one mutation is applied.
A Lower-Risk Rollout: Go/No-Go Controls and a Staged Plan
Key takeaway: Roll out in stages: inventory writers, run in report-only mode, then enforce per resource. Gate each stage with all-required controls, not a summed score.
Staged plan
- Inventory writers per resource. List every code path, client type, job, and integration that mutates it. Mark which ones compute changes from a prior read.
- Choose a protected set. Start with shared, multi-writer, high-impact resources such as tenant settings, role assignments, and routing rules. Skip append-only and single-writer data.
- Add the validator and the conditional write behind a flag. Return tokens on reads. Evaluate the precondition but only log the outcome.
- Measure your own data in shadow mode. Count writes where the presented validator, or the version the writer last saw, would have failed. Log only tenant, resource type, writer type, and a hashed resource ID, not payloads. This number belongs to you and should drive prioritization. It would be a mistake to borrow someone else's rate.
- Enforce per resource and per tenant cohort. Move to
428and412responses, publish the contract, and watch client error rates. Provide a documented exemption path with an expiry for legacy clients. - Add the operation ledger for any mutation with side effects, money movement, external calls, or approvals.
Go/no-go controls (all required before enforcing on a resource)
This is a readiness gate, not a certification of production readiness. Any unchecked item means no-go for that resource.
- Every write path to the resource uses the same conditional primitive, or unconditional paths are documented and blocked.
- The comparison runs inside the datastore write, not in a prior read.
- Tenant ID is in every predicate; cross-tenant requests behave like missing objects.
- Validators are opaque, tenant-scoped, and not derived from guessable counters or low-entropy content hashes.
- Strong comparison is verified end to end through the real edge, including compression and proxies.
- Missing, malformed, weak, and stale validators each have a tested, documented response.
- Side-effecting writes carry a tenant-scoped operation ID bound to a payload hash; reuse with a changed payload is rejected.
- Claim, conditional write, and result are atomic, or the recovery path is explicitly documented and tested.
- Ambiguous timeouts lead to reconciliation by operation ID, never a blind retry; the client and the consumer can represent an unknown state.
- Queue consumers acknowledge only after a verified outcome; terminal failures route to a defined path.
- A two-writer interleaving test and a duplicate-operation test pass in CI.
- Retention, export, and erasure of ledger data have a named owner.
- Hot-row contention was reviewed, and the resource is suitable for optimistic concurrency.
Not sure which of your write paths bypass the guard?
Most teams find at least one importer, script, or connector that skips the precondition. Find it before a customer does.
Talk to Developers.dev engineers about a write-path and concurrency review for your multi-tenant API.
Contact Us2027 Update
The set of API writers keeps growing. Automation platforms and AI agents now issue writes at machine speed, often based on a read taken several steps earlier, which makes the stale-write gap easier to hit. The controls do not change: explicit preconditions, datastore-side conditional writes, operation identity, and reconciliation of unknown outcomes. Treat any new class of writer as another row in your writer inventory, and the contract above stays valid. If you need engineering capacity to retrofit these controls, our backend development services team can work alongside your engineers.
Conclusion: What to Do Next
Lost updates are preventable, but only if the guard lives in the write itself and the retry path is designed for uncertainty. Use these actions as a starting checklist:
- Inventory your writers for the three most contended tenant resources, including jobs, importers, and automations, and mark which compute changes from a prior read.
- Replace any read-compare-then-write with a conditional
UPDATEor condition expression, and add the two-writer interleaving test to CI. - Run shadow mode for one release and measure your own would-have-conflicted rate before you enforce
428and412. - Add a tenant-scoped operation record with a keyed payload hash for side-effecting mutations, and teach clients and consumers to treat timeouts as unknown and reconcile first.
- Assign owners for validator design, ledger retention, and erasure, since identifiers can be sensitive data.
About the author team
Developers.dev is an offshore software development and staff augmentation company founded in 2007, with 1000+ in-house IT professionals delivering backend, cloud, DevOps, and AI engineering for clients primarily in the USA, EMEA, and Australia. The company states that it holds CMMI Level 5, SOC 2, and ISO 27001 credentials. Those describe company-level processes. They do not certify the design in this article, and they do not determine your own legal or compliance obligations. Reviewed by the Developers.dev Expert Team.
Frequently Asked Questions
Is ETag with If-Match enough to prevent lost updates?
Only if the server evaluates the comparison atomically as part of the write and uses strong comparison. If the application reads the row, compares tags, and then writes in a separate statement, a second writer can slip in between. Also confirm that every write path, including jobs and scripts, enforces the same check. Clients can omit headers, so the server must define what happens when the precondition is missing.
Should we return 412 or 409 for a stale write?
HTTP defines 412 Precondition Failed for a false If-Match condition, so it is the most precise choice for stale-validator rejections. Many teams reserve 409 Conflict or 422 for business-rule conflicts where the validator matched but the request still cannot be applied. Pick a convention, document it, and keep it consistent across resources.
Do we have to adopt 428 Precondition Required?
No. RFC 6585 describes 428 as optional, and clients cannot rely on it to prevent lost updates. It is useful when you want to force callers to send a validator on a protected resource, but you can also use 400 with a clear error body. What matters is that the policy is documented and enforced server-side.
Does optimistic concurrency replace idempotency keys?
No, they solve different problems. A conditional write stops two different writers from overwriting each other. An operation identity prevents the same logical operation from being applied twice and gives retries a recorded outcome. After a lost response, a conditional-write retry returns a stale-validator error, which is ambiguous without an operation record. Use both for consequential mutations.
Should the validator be a version counter or a random token?
A random opaque token regenerated on every committed write is the safer default. Counters are guessable, reveal write rates, and encourage clients to treat them as numbers. Content hashes can become equality oracles and depend on stable serialization. If you need ordering internally, keep a revision column and do not expose it.
How do conditional writes work outside HTTP, such as queues, gRPC, or GraphQL?
ETag and If-Match are HTTP mechanisms. For other transports, carry an explicit expected_etag or expected_version in the message or input type and enforce it with the same datastore-side conditional write. Define how consumers treat a stale-validator failure: usually as terminal for that message, routed to conflict handling rather than retried indefinitely.
Does PATCH need a precondition?
It depends on how the patch was produced. If the client computed it from a prior read, for example a recalculated total or a reordered list, a stale base can corrupt the result and a precondition is needed. If a patch changes independent fields with commutative semantics, you may not need one. Decide per field group and write that decision into the API contract.
What should a client do after a 412?
Refetch the current state, show or compute the difference, and make an explicit decision: merge, discard, or resubmit with the new validator. Do not auto-resubmit the original body, since that recreates last-write-wins. If the earlier request may have timed out, check the operation status by ID first to learn whether your own write was the one that applied.
Silent overwrites are cheaper to prevent than to explain to a customer.
If your multi-tenant API has shared records, background writers, or agent-driven changes, a focused concurrency and retry-safety review can surface the gaps early.
Work with Developers.dev engineers to design, test, and roll out conditional writes and reconciliation for your platform.
Contact UsPlatform Engineering Services
This guide is designed for engineering leaders who want to plan a practical implementation. Use the related Developers.dev path to compare delivery options, implementation fit, risk, and practical next steps.
Reviewed by the Experts team
This guide is reviewed for clarity, technical and operational relevance, service alignment, and a useful next step. Verified by our SEO team for clear search presentation.
Reviewed by the Experts team. Verified by our SEO team. Validate legal, security, data, budget, and operational requirements with the relevant stakeholders before rollout.

