# API Conditional Requests Validation

> Implement conditional request validators for safe concurrency: strong/weak ETags, If-Match/If-Unmodified-Since, 412 and 428. Use when preventing lost updates on PUT/PATCH/DELETE.

- Skill: `deangrant/api-conditional-requests-validation` (Agent Skill, multi-file: 4 files)
- Install (CLI): `npx skillmds@latest add deangrant/api-conditional-requests-validation`
- Raw SKILL.md: https://api.skillmd.com/api/skills/deangrant/api-conditional-requests-validation/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: deangrant (https://skillmd.com/u/deangrant)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/deangrant/api-conditional-requests-validation

---


# Conditional Requests and Validation

Use this skill for **optimistic concurrency** on mutations.

---

## 1. Preconditions

| Header | Typical use |
| ------ | ----------- |
| `If-Match` | Mutate only if ETag matches (strong) |
| `If-None-Match` | GET revalidation / create-if-absent patterns |
| `If-Unmodified-Since` | Time-based precondition |

Mismatch → **412 Precondition Failed**. Missing required precondition may be
**428 Precondition Required**. Business conflict → **409**.

---

## 2. Strong vs weak ETags

Use **strong** ETags when byte-identity matters for writes. Weak ETags (`W/`)
are for semantic equivalence / caching, not safe lost-update prevention.

---

## 3. Quick checklist

- [ ] Strong ETag on contested resources.
- [ ] Require `If-Match` on PUT/PATCH (and DELETE if needed).
- [ ] 412 / 428 / 409 distinguished correctly.
- [ ] Precedence rules documented.

See [reference.md](reference.md) and [examples.md](examples.md).

