json-api

Example of using "lid" in JSON:API


The spec for JSON:API v1.1 mentions that "when the resource object originates at the client and represents a new resource to be created on the server", "a lid member may be included to uniquely identify the resource by type locally within the document".

However, when creating a new resource, "the request must include a single resource object".

So, it seems the only case where "lid" might be useful is to create a resource with a relationship to itself.

Is this correct? Else, what would another example be?


Solution

  • Local identifiers (lid) are meant to be used by extensions. The Atomic Operations extension is an example how local identifiers can be used.

    The author of the specification expected that many extensions (and maybe profiles) need local identifiers. To avoid having many different solution for the same problem, they were added to the base specification in version 1.1.

    Within the base specification local identifiers can only be used to create a resource having a relationship to itself. I don't think there are many cases in which such a self-referencing relationship makes sense.

    Please see for sources the answers to the same question in the official discussion forum of the JSON:API specification.