[{"data":1,"prerenderedAt":123},["ShallowReactive",2],{"/api/overview/concurrency":3,"/api/overview/concurrency-surround":114},{"id":4,"title":5,"body":6,"description":105,"extension":106,"links":107,"meta":108,"navigation":109,"path":110,"seo":111,"stem":112,"__hash__":113},"docs/api/1.overview/concurrency.md","Concurrency",{"type":7,"value":8,"toc":97},"minimark",[9,18,23,26,32,36,43,69,76,86,90],[10,11,12,13,17],"p",{},"The Capacities API is a stateless REST API. It has ",[14,15,16],"strong",{},"no cross-request transactions"," — each HTTP request is independent, and the API provides no mechanism to group multiple operations into an atomic unit that either fully succeeds or fully rolls back.",[19,20,22],"h2",{"id":21},"last-write-wins-semantics","Last-write-wins semantics",[10,24,25],{},"When two requests modify the same object concurrently, the result is determined by whichever write reaches the server last. There is no automatic conflict detection or merging. This is standard last-write-wins (LWW) behavior — the second write silently overwrites the first.",[10,27,28,31],{},[14,29,30],{},"Example:"," if two processes both read an object, then both write an updated version, the process that writes last wins and the other's changes are lost.",[19,33,35],{"id":34},"avoiding-race-conditions","Avoiding race conditions",[10,37,38,39,42],{},"To keep your integration free of race conditions, ",[14,40,41],{},"serialize writes to the same resource",". Concretely:",[44,45,46,55,66],"ul",{},[47,48,49,50,54],"li",{},"Send the next mutating request only after the previous one has completed (received a ",[51,52,53],"code",{},"2xx"," response).",[47,56,57,58,61,62,65],{},"Do not issue concurrent ",[51,59,60],{},"PATCH"," or ",[51,63,64],{},"DELETE"," calls against the same object or block tree.",[47,67,68],{},"If you fan out work across multiple workers or processes, partition by resource so each resource is only written by one worker at a time.",[10,70,71,72,75],{},"Read-only (",[51,73,74],{},"GET",") requests are always safe to issue concurrently — they do not modify state.",[77,78,79],"tip",{},[10,80,81,82,85],{},"The safest pattern for automations that update existing objects is ",[14,83,84],{},"read → modify in memory → write",", executed sequentially. Avoid holding the read result for a long time before writing, as another process may have changed the object in between.",[19,87,89],{"id":88},"no-optimistic-locking","No optimistic locking",[10,91,92,93,96],{},"The API does not currently expose ETags, version numbers, or conditional request headers (such as ",[51,94,95],{},"If-Match",") for optimistic concurrency control. If your integration requires strict conflict detection, you must enforce ordering at the application layer.",{"title":98,"searchDepth":99,"depth":100,"links":101},"",1,2,[102,103,104],{"id":21,"depth":100,"text":22},{"id":34,"depth":100,"text":35},{"id":88,"depth":100,"text":89},"How the Capacities API handles concurrent requests, last-write-wins semantics, and how to avoid race conditions.","md",null,{},true,"/api/overview/concurrency",{"title":5,"description":105},"api/1.overview/concurrency","f13mSQYe-KE-KLJ5G62SYOUX8bBZnY7tzr0PrUd4Jn4",[115,119],{"title":116,"path":117,"stem":118,"children":-1},"Authentication","/api/overview/authentication","api/1.overview/authentication",{"title":120,"path":121,"stem":122,"children":-1},"Errors","/api/overview/errors","api/1.overview/errors",1781012286558]