Pcornel
Automation · APIs

PUT

Cheat sheet · https://pcornel.dk/topic.php?topic=5297

Back to the Topic

Answer

Replacement or creation of the representation at a known resource URI with idempotent request semantics.

Remember

  • PUT idempotent ≠ no change on repeated calls; the same intended representation may still update metadata or timestamps.
  • PUT ≠ partial update by default; omitting fields can replace or reset state depending on the contract.
  • 200/204 ≠ stored representation matches input; server normalization or policy may alter values.
  • Known URI ≠ authorized target; caller scope and conditional concurrency still matter.

First checks

  • curl -sS -X PUT -H 'Content-Type: application/json' -d @full.json https://<api>/v1/items/<id> — replace
  • Full representation required — semantics
  • ETag/If-Match for concurrency — lost update prevention

Verify in this order

PUT full object → resource replaced

Where it usually breaks

A successful PUT response proves request processing, not that omitted fields, concurrent changes or server normalization produced the intended final state.

Client payload/auth → HTTP transport → endpoint validation/policy → request accepted → queued/job execution → target mutation → effective state → consumer workload.

PUT API boundary map

BoundaryHealthy evidenceSuspicious evidence
Caller / requestEnvironment/version, identity and exact request contract are attributableHidden defaults, wrong endpoint/version, leaked or mismatched credentials
Server / responseStatus, headers, structured body and request ID are interpreted togetherStatus-only handling, ignored error body, ambiguous async result or unsafe retry
State / proofWrite result is reconciled with resource read-back or acceptance testResponse success treated as final target success without verification
TroubleshootingFirst failed boundary is preserved, changed minimally and retestedBlind retries, credential rotation, replay or payload edits before evidence is captured

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5297

Confirmation

Confirm action

Continue?