# How are local IDs supposed to be used?

**URL:** <https://discuss.jsonapi.org/t/how-are-local-ids-supposed-to-be-used/2789>\
**Category:** Uncategorized\
**Created:** [March 6, 2024, 5:23pm UTC](https://discuss.jsonapi.org/t/how-are-local-ids-supposed-to-be-used/2789 "2024-03-06T17:23:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerry87](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/jerry87/32/887_2.png) [@Jerry87](https://discuss.jsonapi.org/u/Jerry87)\
**Post date:** [March 6, 2024, 5:23pm UTC](https://discuss.jsonapi.org/t/how-are-local-ids-supposed-to-be-used/2789/1 "2024-03-06T17:23:49Z")

</div>

Section 7.2.1 ([Identification](https://jsonapi.org/format/#document-resource-object-identification)) suggests to use a “lid” member inside of resource identifier objects to identify the resource locally within the document when creating new resources. But the specification does not provide further examples.

When creating a new resource, the corresponding JSON:API document can only contain the one resource object that should be created on the server. Where in the document may the primary resource be referenced by the “lid” member?

Thanks for clarification!

---

<div class="post-metadata">

**Author:** ![jelhan](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/jelhan/32/822_2.png) [@jelhan](https://discuss.jsonapi.org/u/jelhan)\
**Post date:** [April 6, 2024, 8:53pm UTC](https://discuss.jsonapi.org/t/how-are-local-ids-supposed-to-be-used/2789/2 "2024-04-06T20:53:45Z")

</div>

The local identifier (`lid`) is expected to be used by extensions. An example is the [Atomic Operations](https://jsonapi.org/ext/atomic/) extension.

---

<div class="post-metadata">

**Author:** ![Jerry87](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/jerry87/32/887_2.png) [@Jerry87](https://discuss.jsonapi.org/u/Jerry87)\
**Post date:** [April 10, 2024, 5:21pm UTC](https://discuss.jsonapi.org/t/how-are-local-ids-supposed-to-be-used/2789/3 "2024-04-10T17:21:09Z")

</div>

Thanks for your answer. That point is not clearly stated in the specification. Or did I miss it?

But when the only use of the local identifier is by extensions, shouldn´t it be specified by the corresponding extension instead of the official specifictation?

---

<div class="post-metadata">

**Author:** ![jelhan](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/jelhan/32/822_2.png) [@jelhan](https://discuss.jsonapi.org/u/jelhan)\
**Post date:** [April 10, 2024, 7:11pm UTC](https://discuss.jsonapi.org/t/how-are-local-ids-supposed-to-be-used/2789/4 "2024-04-10T19:11:08Z")

</div>

A note explaining intent of local identifiers / `lid` may be helpful indeed. I created [Explain intent of local identifiers in a note in the spec · Issue #1740 · json-api/json-api · GitHub](https://github.com/json-api/json-api/issues/1740) to track it.

The assumption was that many extensions need local identifiers. It was added to base specification to avoid multiple solutions to the same problem and compatibility issues. If I got it right. @dgeb feel free to correct me as I wasn’t part of the discussions at that time.

---

<div class="post-metadata">

**Author:** ![dgeb](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/dgeb/32/17_2.png) [@dgeb](https://discuss.jsonapi.org/u/dgeb)\
**Post date:** [April 10, 2024, 10:44pm UTC](https://discuss.jsonapi.org/t/how-are-local-ids-supposed-to-be-used/2789/5 "2024-04-10T22:44:09Z")

</div>

I think that you’ve got it at least 99% right. The rationale you’re missing is a very subtle one which involves creating a resource with a relationship to the same resource. While we couldn’t find any non-contrived examples we also didn’t want to punt at the same time we are adding extensions.

I think your note will add some useful clarity.
