3. General rules and definitions
This section defines rules and definitions that apply to many or all CRUD operations.
3.1 Resources
Section titled “3.1 Resources”Resources, Collections, Fields, Resource IDs and Resource Representations are defined in section 2.5.
3.1.1 Collections
Section titled “3.1.1 Collections”COLLECTION_SLUG MUST
Collections in the same CRUD API MUST be uniquely identified by Slugs, regardless of language-specific typing or naming.
COLLECTION_NOT_FOUND MUST
An operation on a Collection that does not exist MUST fail with the NOT_FOUND error, except as allowed by COLLECTION_CREATE_IMPLICIT.
COLLECTION_CREATE_IMPLICIT MAY
A Server MAY create a Collection implicitly on the first create operation on it. A Server that does so MUST declare it.
3.1.2 Fields
Section titled “3.1.2 Fields”FIELDS_CAMEL_CASE SHOULD
Fields in the same Collection SHOULD be formatted in camelCase.
FIELDS_NAMES MUST
A Field name MUST be a non-empty string. It MAY contain any character, including spaces and ., subject to FIELDS_NO_PREFIXES; nested Fields are addressed with the field path syntax of UnQuery (PATH_DOT_NOTATION), which defines how names with special characters are quoted.
FIELDS_NO_PREFIXES MUST NOT
Field names MUST NOT start with $ or @. In the LingoData family, $ marks ECSON typed values and @ marks operators and control parameters.
FIELDS_RESERVED MUST
Fields defined by this specification or by an extension, such as _id, are reserved and MUST be used only with the meaning defined for them. Other Field names MAY start with _.
FIELDS_EXTENSION_RESERVED SHOULD
Extensions that define reserved Fields SHOULD name them with a leading _, and MUST list them explicitly.
3.1.3 Resource IDs
Section titled “3.1.3 Resource IDs”ID_KEY MUST
The _id field MUST be used to uniquely identify a Resource following the Section 3.1.3 Resource IDs specs below, except when it is a composite key.
ID_UUID SHOULD
A Resource ID SHOULD be a UUID version 7 (RFC 9562, section 5.7), represented in the uuid-hex format.
A UUID Resource ID MAY be represented in the uuid-base64url format instead.
Resource IDs made of many Fields (a.k.a. “composite keys”) MUST be represented in the format application/x-www-form-urlencoded.
3.1.4 Resource representation
Section titled “3.1.4 Resource representation”REPR_JSON MUST
A Resource Representation MUST be valid JSON (RFC 8259). Servers SHOULD accept JSON5 input, as recommended by ECSON.
REPR_ECSON SHOULD
Resources SHOULD be represented in ECSON (application/vnd.ecson+json), to preserve types between Client and Server.
Servers MAY use application-defined ECSON types, following the ECSON tag namespace rules.
Resources are made of values of the types defined by ECSON (dates, big integers, references and others). ECSON is how those values travel without loss; it is not how they are stored (ECSON section 5.2).
REPR_PLAIN_JSON MUST
When the negotiated Resource Representation is plain JSON, the Server MUST send values in their plain JSON form (ECSON section 5.3) and MUST read request bodies as plain JSON (ECSON PLAIN_FORM_READ).
REPR_NO_CONVERSION MUST NOT
The Server MUST NOT convert values read as plain JSON to other types, unless an extension defines the conversion (for example, the Schema extension).
REPR_NATIVE_STORAGE MUST
Providers MUST store values in the native types of the Data source, and MUST NOT store their ECSON serialization.
REPR_DOWNGRADE MUST
When the Data source has no native type for a value, the Provider MUST store its plain JSON form, and the Server MUST report the TYPE_DOWNGRADED Warning, with the field.
REPR_NO_ENVELOPES MUST
Resources MUST NOT be wrapped in envelopes such as data, result, response, or similar constructs. Operation Inputs and Outputs MUST always directly reflect Resources, optional Parameters (as defined by the Protocol), or errors.
3.2 Search queries
Section titled “3.2 Search queries”3.2.1 Definition and representation
Section titled “3.2.1 Definition and representation”A “Search Query” is a filter that selects Resources in some operations, written in a format negotiated between Client and Server.
SEARCH_QUERY_UNQUERY SHOULD
Servers SHOULD support Search Queries in the UnQuery format, in both its JSON (application/vnd.unquery+json) and SQL (text/vnd.unquery.sql) syntaxes.
Servers MAY support other Search Query formats, such as the native query language of a Data source, identified by media types and negotiated as specified in section 3.4.1.
3.3 Parameters
Section titled “3.3 Parameters”This section defines Parameters that apply to several operations. Parameters specific to one operation are defined in section 4. Each Protocol defines how Parameters are sent.
3.3.1 Field lists
Section titled “3.3.1 Field lists”Projection and sorting Parameters take a field list: an ordered list of field paths, each with a modifier (omit, for projection; descending, for sorting).
FIELD_LIST_PATHS MUST
Each item of a field list MUST be a field path as defined by UnQuery (PATH_DOT_NOTATION), so that nested Fields use dot notation and names with special characters are quoted.
FIELD_LIST_NO_INDEX MUST
This specification does not define array indexes (UnQuery PATH_INDEX) in field lists. The Server MUST fail with the INVALID_INPUT error for a field list with an item that has an index.
FIELD_LIST_TEXT MUST
When a field list is written as text, items MUST be separated by , and the modifier MUST be a - before the path; segments that contain , or start with - MUST be quoted. Protocols MAY use other forms, such as JSON arrays, with the same meaning.
3.3.2 Projection parameter
Section titled “3.3.2 Projection parameter”A “Projection Parameter” selects which Fields are returned in the Result.
A Projection Parameter MUST be a field list, where the - modifier omits a Field.
PROJECTION_INCLUDE_DEFAULT MUST
When a Projection Parameter has no omitted Fields, only the listed Fields MUST be returned.
PROJECTION_EXCLUDE MUST
When a Projection Parameter has only omitted Fields, every other Field MUST be returned.
When a Projection Parameter has both listed and omitted Fields, the Server MUST first select the listed Fields and then remove the omitted ones.
PROJECTION_ID MUST
The Resource ID MUST always be returned, unless the Projection Parameter omits it explicitly (for example -_id).
3.3.3 Custom parameters
Section titled “3.3.3 Custom parameters”A “Custom Parameter” is a Parameter defined by a Server and not by this specification.
PARAM_CUSTOM_DECLARE SHOULD
A Server SHOULD declare the Custom Parameters it accepts and the operations they apply to.
PARAM_CUSTOM_UNKNOWN MUST
When a Client sends a Parameter that the Server does not recognize, the Server MUST ignore it and report the PARAM_IGNORED Warning. If the Client asked for Warnings to be treated as errors (META_WARN_PREFERENCE), the operation MUST fail.
3.4 Metadata
Section titled “3.4 Metadata”Operation “Metadata” is data exchanged between Client and Server about the operation itself: content negotiation, specification versions, counts, correlation and warnings. Each Protocol defines how Metadata is carried (for example, HTTP headers or the MCP _meta object).
3.4.1 Content negotiation
Section titled “3.4.1 Content negotiation”“Content negotiation” is the exchange of Metadata in which Client and Server agree on the formats of the Input and the Output: the Resource Representation and the Search Query format.
META_RES_PREFERENCE SHOULD
The Client SHOULD declare the Resource Representations and Search Query formats it accepts. The Server MUST either use one of them or fail the operation with the NEGOTIATION error.
META_RES_FALLBACK MUST
When the Client declares no Resource Representation, the Server MUST respond in ECSON if it supports ECSON, and in JSON otherwise. When the Client declares no Search Query format, the Server MUST interpret Search Queries as UnQuery if it supports UnQuery.
META_RES_TIE MUST
When the Client accepts both ECSON and plain JSON with the same preference, including a declaration that accepts any format, the Server MUST respond in ECSON if it supports ECSON. The Server MUST respond in plain JSON only when the Client does not accept ECSON, or prefers plain JSON to ECSON.
META_PREFER_REPRESENTATION MAY
The Client MAY declare a return preference: representation, to receive the Resources affected by the operation, or minimal, to receive only the operation status.
META_RES_DEFAULT MUST
Without a return preference, the Server MUST behave as if the Client declared representation.
META_PREFER_STATUS MUST
With the minimal return preference, the Server MUST NOT send Resources when the operation succeeds, and MUST send only the error data (section 3.4.4) when it fails.
3.4.2 Specification versions
Section titled “3.4.2 Specification versions”META_CRUD_SPECS MUST
The Server MUST declare the specifications it implements, the Base Specification and each extension, with the versions it supports for each, as Semantic Versioning versions, for example base@0.2.0, async@0.1.0.
The Client MAY declare the specifications it requires, each with a version range in the syntax of node-semver ranges, for example base@^0.2.0, async@~0.1.0.
When the Client declares required specifications, the Server MUST select, for each one, the highest version it supports that satisfies the range, and MUST declare the selected versions in the Output. If any required specification is not supported, or no supported version satisfies its range, the operation MUST fail with the NEGOTIATION error, listing the supported versions.
3.4.3 General metadata
Section titled “3.4.3 General metadata”META_MATCHED_COUNT SHOULD
Operations that take a Search Query SHOULD include a “Matched Count” Metadata field with the total number of Resources matched by the Search Query, regardless of pagination.
META_MODIFIED_COUNT SHOULD
Write operations SHOULD include a “Modified Count” Metadata field with the number of Resources modified by the operation.
META_CORRELATION_ID SHOULD
The Client SHOULD send a “Correlation ID” Metadata field with a new UUIDv7 in uuid-hex format. If the Client sends one, the Server MUST return the same value; otherwise, the Server SHOULD generate one and return it.
3.4.4 Error handling
Section titled “3.4.4 Error handling”When an operation fails, the Server reports one of the error codes below. Each Protocol specification maps these codes to its own (for example, HTTP status codes or JSON-RPC error codes), so that Clients handle errors the same way over any Protocol.
RES_ERROR_DATA MUST
When an operation fails, the Server MUST send error data in the negotiated representation, with at least the error code from the table above (or from an extension) and a human-readable message (the detail member, in a Problem Details object). For NOT_FOUND, the error data SHOULD also include a target with the kind of missing element: resource or collection, or a target defined by an extension.
ERROR_PROBLEM_DETAILS SHOULD
Error data SHOULD be a Problem Details object (RFC 9457), with the error code in a code member and, for NOT_FOUND, the target in a target member. The status member SHOULD be present only when the Protocol has numeric status codes, such as HTTP.
Every Protocol specification MUST map each error code of this specification and of the extensions it supports to an error of the Protocol, and MUST carry the error code of this specification in the error data.
Extensions MAY define additional error codes, which MUST NOT reuse the codes of this specification.
Servers MAY define their own error codes, which MUST be prefixed with a namespace and a . (for example acme.QUOTA_EXCEEDED).
Error data MAY include additional Fields, such as documentation URLs or tracing information.
3.4.5 Warnings
Section titled “3.4.5 Warnings”META_WARN MAY
The Server MAY report Warnings: conditions that do not prevent the operation, such as deprecations, quotas, ignored Parameters or reduced limits. Each Warning MUST have a code and a human-readable message.
META_WARN_PREFERENCE MUST
The Client MAY declare a strict preference. When it does, the Server MUST fail any operation that would produce Warnings with the STRICT_WARNINGS error, reporting the Warnings in the error data. Without it, Warnings MUST NOT make an operation fail.
META_WARN_PREFERENCE_EXCEPT MAY
The strict preference MAY list Warning codes that remain Warnings. When it does, the Server MUST report Warnings with a listed code without failing, and MUST fail with the STRICT_WARNINGS error any operation that would produce a Warning with another code. A Server that does not support the list MUST apply the strict preference to every Warning.
WARN_DATA MAY
Besides the code and the message, a Warning MAY include the members parameter (the name of a Parameter), field (a field path), id (a Resource ID) and error (an error code), as specified for each Warning code, and other members, such as documentation URLs.
| Code | Condition | Members |
|---|---|---|
PARAM_IGNORED |
A Parameter the Server does not recognize was ignored (PARAM_CUSTOM_UNKNOWN) |
parameter |
LIMIT_REDUCED |
The Server reduced the limit sent by the Client (PAGINATION_LIMIT_MAX) |
parameter |
ORDER_NOT_PRESERVED |
The Result is not in the order of the Subject (RES_DETERMINISTIC_WRITES) |
|
ID_IGNORED |
A Resource ID in a replacement Resource was ignored (SUB_NO_ID) |
id |
WRITE_FAILED |
A Resource was not written in a partial write (WRITE_PARTIAL) |
error, id when known |
TYPE_DOWNGRADED |
A value was stored in its plain JSON form (REPR_DOWNGRADE) |
field |
DEPRECATED |
The operation used a Parameter, format or feature that the Server will remove | parameter when it applies |
WARN_STANDARD_CODES MUST
For the conditions in the table above, the Server MUST use the Warning codes and members of the table.
Extensions and Protocol specifications MAY define additional Warning codes, and MUST NOT reuse the codes of this specification.
Servers MAY define their own Warning codes, which MUST be prefixed with a namespace and a . (for example acme.QUOTA_LOW).
WARN_UNKNOWN_CODES MUST
Clients MUST accept Warnings with codes they do not know, and treat them as generic Warnings.
Source: lingodata/crud@bc225ba · specs/base/sections/03-general-rules.md · base 0.2.0 (draft)
LingoData specifications, reference implementations and this site are licensed under the Apache License 2.0. Copyright 2026 Gustavo Gondim.