Verify an API mutation before the next step

Verify each API write with its route receipt and postcondition read, while using D1 bookmarks only to order the D1-backed parts of a request.

Last reviewed

A 2xx response proves that the route accepted its own contract; a route-specific read proves the next step can observe the intended state. Dosya’s X-D1-Bookmark orders D1 session reads, while file content may live in a workspace object outside that ordering.

Four workflow panels show defining a postcondition, retaining the route receipt, limiting bookmarks to D1 ordering, and comparing a route-specific verification read.
The diagram covers defining a postcondition, retaining the route receipt, limiting `X-D1-Bookmark` to D1-backed ordering, and comparing a route-specific verification read. Open full-size screenshot.

Before you start

  • Define the postcondition before sending the mutation: exact ID, parent, name, deleted state, version, or byte size.
  • Know the route’s replay behavior. One-shot upload has an idempotency key; a bare file DELETE can become a permanent purge on its second call.
  • Keep status and response body as the operation receipt. Retain X-D1-Bookmark when present for later D1-backed reads.

Steps

  1. Read the resource and record its current ID and state. Reject a stale local assumption before it becomes a write request.
  2. Send one narrowly scoped mutation. Require its documented status and fields, such as move or rename { "ok": true, "name": "…" } or an upload file receipt.
  3. Capture X-D1-Bookmark when the response supplies it. Send it on the next request to order that request’s D1 session; it does not create cross-storage ordering for a workspace object.
  4. Perform the mutation’s own verification read: fetch the same ID after move or rename, query the deleted listing after trash, or fetch the file ID returned by upload.
  5. Compare the read to the predeclared postcondition. Do not substitute an empty old listing for proof that the item exists in its intended new state.
  6. Persist the mutation receipt and verified state before the next dependent action. If verification is inconclusive, pause and inspect rather than replaying an unsafe write.
Dosya developer overview with API and SDK entry points for verify an api mutation before the next step.
The developer overview supplies the API and SDK entry points referenced by “Verify an API mutation before the next step”. Open full-size screenshot.

Expected result

The receipt and route-specific read agree on the same resource and committed state. Downstream automation starts only after the operation-specific postcondition is visible; a bookmark helps only where the read uses D1.

Troubleshooting

The mutation succeeded but the read looks stale. Confirm the follow-up targets the same ID and workspace. Carry the response bookmark for D1 state, but judge workspace-object content from the route response itself.

The response was lost. Read first. Replay only when the route documents idempotency or the observed precondition proves the original request did not commit.

The old location is empty. Check the destination or deleted listing by ID; absence is not a complete postcondition.

Was this helpful?

Loading helpfulness results…

Voting saves a necessary ballot cookie for up to 180 days so you can change your answer.

Questions and replies

Ask about the steps in this guide. Questions are reviewed before publication.

Keep account details, credentials and private files out of public questions. Use private support for those.

Loading questions…

    Sign in to your Dosya account to ask a question.

    Check the outcome before you retry

    Use these shared checks when a task needs a second look.