Skip to content

4. Headers and metadata

Operation Metadata (Base section 3.4) is carried in HTTP header fields. New header fields defined by this specification have no X- prefix (RFC 6648) and, when structured, use Structured Field Values (RFC 9651).

HTTP_ACCEPT SHOULD

Clients SHOULD send the Accept header field with the Resource Representations they accept (application/vnd.ecson+json, application/json). Servers MUST respond with a matching Content-Type, chosen as specified in section 4.1.1, or fail with the NEGOTIATION error.

HTTP_PLAIN_JSON MUST

application/json MUST be treated as the plain JSON Resource Representation (Base REPR_PLAIN_JSON), and application/vnd.ecson+json as ECSON, both in responses and in request bodies.

HTTP_CONTENT_TYPE MUST

Request bodies MUST be labeled with Content-Type: a Resource Representation for Resources, application/json-patch+json or application/merge-patch+json for patches, and an UnQuery media type for Search Queries in QUERY requests.

HTTP_ACCEPT_QUERY SHOULD

Servers that support the QUERY method SHOULD advertise the Search Query formats they accept in the Accept-Query response header field (RFC 10008).

HTTP_PREFER MUST

The return preference (Base META_PREFER_REPRESENTATION) MUST be sent as Prefer: return=representation or Prefer: return=minimal, and the strict preference (Base META_WARN_PREFERENCE) as Prefer: handling=strict (with handling=lenient as the default), as defined by RFC 7240.

HTTP_PREFER_ALLOW MUST

The Warning codes that remain Warnings under the strict preference (Base META_WARN_PREFERENCE_EXCEPT) MUST be sent as the allow parameter of handling=strict, as a quoted string of codes separated by spaces.

HTTP_PREFERENCE_APPLIED SHOULD

Servers SHOULD report the preferences they applied in the Preference-Applied response header field.

4.1.1 Choosing the Resource Representation

Section titled “4.1.1 Choosing the Resource Representation”

The Accept header field decides between ECSON (application/vnd.ecson+json) and plain JSON (application/json) in responses. ECSON is the default: plain JSON is sent only when the Client asks for it explicitly.

HTTP_ACCEPT_WEIGHT MUST

The Server MUST give ECSON and plain JSON the weight (q) of the most specific media range of Accept that matches each of them (RFC 9110, section 12.5.1), where */* and application/* match both. A Representation that no media range matches, or whose weight is 0, is not accepted.

HTTP_ACCEPT_ECSON_DEFAULT MUST

The Server MUST respond in ECSON, if it supports ECSON, when there is no Accept header field, when Accept has only wildcard media ranges (*/*, application/*), and when ECSON and plain JSON have the same weight (Base META_RES_FALLBACK and META_RES_TIE).

HTTP_ACCEPT_PLAIN_JSON MUST

The Server MUST respond in plain JSON only when ECSON is not accepted, or when plain JSON has a higher weight than ECSON.

Accept sent by the Client Response Content-Type Why
(none) application/vnd.ecson+json no declaration
*/* (default of curl and of fetch) application/vnd.ecson+json only wildcards
application/json, text/plain, */* (default of axios) application/vnd.ecson+json same weight: */* also accepts ECSON
application/json application/json ECSON is not accepted
application/json, */*;q=0.8 application/json plain JSON has the higher weight
application/json, application/vnd.ecson+json;q=0 application/json ECSON is refused
application/vnd.ecson+json application/vnd.ecson+json explicit

HTTP_VARY_ACCEPT SHOULD

Responses whose Representation depends on Accept SHOULD include Vary: Accept (RFC 9110, section 12.5.5), so that caches do not serve an ECSON response to a plain JSON Client.

HTTP_CRUD_SPECS MUST

Servers MUST send the CRUD-Specs response header field, a Structured Field Dictionary whose keys are specification names and whose values are Strings with the version (Base META_CRUD_SPECS).

HTTP_CRUD_REQUIRE MAY

Clients MAY send the CRUD-Require request header field, a Structured Field Dictionary whose keys are specification names and whose values are Strings with node-semver ranges (Base META_CRUD_REQUIRE).

HTTP_COUNTS SHOULD

The Matched Count and the Modified Count (Base META_MATCHED_COUNT and META_MODIFIED_COUNT) SHOULD be sent in the Matched-Count and Modified-Count response header fields, as decimal integers.

HTTP_LOCATION MUST

When a write operation targets a single Resource, the Server MUST send its URL in Content-Location when the response carries the Resource (return=representation), and in Location otherwise.

When the Metadata extension is supported, Resource metadata is also mirrored in standard header fields for operations on a single Resource (Metadata META_PROTOCOL_MIRROR).

HTTP_META_ETAG SHOULD

The ETag response header field SHOULD be the strong entity tag of _meta.hash, and Last-Modified the timestamp of the updated event (or of created, before any update).

HTTP_META_IF_MATCH SHOULD

Servers SHOULD support If-Match on write operations as the expected hash (Metadata META_DOC_CONDITIONAL), failing with 412 Precondition Failed (PRECONDITION_FAILED) when it does not match.

HTTP_META_IF_NONE_MATCH MAY

Servers MAY support If-None-Match on GET /:collection/:id, responding 304 Not Modified without a body when the hash matches.

HTTP_CORRELATION_ID SHOULD

The Correlation ID (Base META_CORRELATION_ID) SHOULD be sent in the Correlation-ID header field, in uuid-hex format, by Clients in requests and by Servers in responses.

HTTP_TRACEPARENT SHOULD

Servers SHOULD accept and propagate the traceparent header field of W3C Trace Context. When a request has traceparent and no Correlation-ID, the Correlation ID MUST be its trace-id, formatted as uuid-hex. When both are present and differ, Correlation-ID prevails.

HTTP_WARNING MUST

Warnings (Base META_WARN) MUST be sent in the Warning response header field as a Structured Field List of Strings, each String being a Warning code with a message parameter. Several Warnings MAY be sent in one field value, separated by commas, or in several Warning field lines, which are equivalent.

HTTP_WARNING_DATA MUST

The other members of a Warning (Base WARN_DATA), such as parameter, field, id and error, MUST be sent as parameters of its item, with String values.

Preconditions make a write operation fail, without writing, when the current state is not the one the Client expects. They are header fields, as HTTP conditional requests are, and fail with 412 Precondition Failed.

HTTP_EXPECT_MATCH MUST

The expected match count (Base PARAM_EXPECT_MATCH) MUST be sent in the Expect-Match request header field, as a decimal integer. When it does not match, the Server MUST respond 412 Precondition Failed with the EXPECT_MISMATCH code.

HTTP_DENY_UPSERT MUST

The denial of upserts (Base PARAM_DENY_UPSERT) MUST be sent as If-Match: * on PUT /:collection/:id, which by RFC 9110 is false when the Resource does not exist. The Server MUST then respond 412 Precondition Failed with the UPSERT_DENIED code.

Source: lingodata/crud@bc225ba · specs/http/sections/04-headers.md · http 0.2.0 (draft)

LingoData specifications, reference implementations and this site are licensed under the Apache License 2.0. Copyright 2026 Gustavo Gondim.