﻿# PRECONDITION_REQUIRED — PATCH request missing required If-Match header

PATCH applies a merge patch to the entitys stored state rather than replacing it wholesale. Because the patch is applied relative to the current stored d…

<em>cyoda-go version <a href="https://github.com/Cyoda/cyoda-go/releases/tag/v0.8.2">0.8.2</a></em>

# errors.PRECONDITION_REQUIRED

## NAME

PRECONDITION_REQUIRED — a PATCH request was submitted without an `If-Match` header, which is mandatory for patch operations.

## SYNOPSIS

HTTP: `428` `Precondition Required`. Retryable: `no`.

## DESCRIPTION

PATCH applies a merge patch to the entity's stored state rather than replacing it wholesale. Because the patch is applied relative to the current stored data, cyoda-go requires the caller to state a precondition explicitly via `If-Match`. Omitting the header entirely is rejected.

This behaviour is specific to PATCH. A PUT without `If-Match` is treated as an unconditional replace and is accepted.

Not retryable as-is — the same request without an `If-Match` header produces the same error.

## RECOVERY

Add an `If-Match` header to the PATCH request. Two modes are supported:

- **Conditional patch** — supply the `transactionId` obtained from your most recent GET of the entity as the `If-Match` value. The patch is applied only if the entity has not changed since that read; a `412 ENTITY_MODIFIED` is returned if another writer has committed in the meantime.
- **Unconditional patch (last-writer-wins)** — supply `If-Match: *` to explicitly accept that the patch will be applied to whatever the current stored state is, without a version check.

Choose the conditional form when you need to detect concurrent modifications; choose `*` when you intentionally want last-writer-wins semantics and have already decided the patch is safe to apply regardless of concurrent changes.

## SEE ALSO

- errors
- errors.ENTITY_MODIFIED
- errors.BAD_REQUEST

## See also

- [`cyoda help errors`](/help/errors/) — Every error response from the Cyoda REST API carries a structured `errorCode` in the `properties` object. Multiple codes may share the same HTTP status. Programmatic handling keys on `errorCode`, not HTTP status.
- [`cyoda help errors ENTITY_MODIFIED`](/help/errors/entity_modified/) — When an entity update request carries an `If-Match` header, the server requires the supplied transaction ID to equal the entity's current `meta.transactionId`. A mismatch means another writer has updated the entity since the caller's last read. The optimistic-concurrency guard rejects the update rather than silently overwrite.
- [`cyoda help errors BAD_REQUEST`](/help/errors/bad_request/) — Fired when the server cannot parse or structurally process the incoming request. Common triggers include invalid JSON, missing required fields, unsupported format specifiers, or mutually exclusive parameters being set simultaneously.

## Raw formats

- [`/help/errors/precondition_required.json`](/help/errors/precondition_required.json) — full descriptor (matches `GET /help/{topic}` envelope)
- [`/help/errors/precondition_required.md`](/help/errors/precondition_required.md) — body only