Reliability Recommended
Stop lost updates with ETags
Send an ETag with every resource, and require If-Match on updates, so one client can't silently overwrite another's change.
How to do it
Use strong ETags, such as a version number in quotes, because If-Match never matches a weak W/ tag. Answer 412 when the If-Match value no longer matches, as RFC 9110 defines. Answer 428 when an update arrives without If-Match on a resource that requires it, as RFC 6585 defines. The same ETags let readers use conditional requests. The database side is in conditional writes.
How to check
Two clients read the same order, and both send a PATCH with the first ETag. The second gets 412. A PATCH without If-Match gets 428.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers api design playbook: https://agentwranglers.se/playbook/api-design/reliability/optimistic-concurrency.