Uniqueness of postfix integers of gids over different objects

Are the postfix integers of gids in shopify unique?
For example
gid://shopify/MediaImage/1234 ( In shop A)
gid://shopify/Product/1234 (In shop B)
Can this happen over different shops?

Hey @BenyaminHatami

The integer at the end of a GID is only unique within a single shop and within a single resource type. The same numeric ID can show up across different shops and across different resource types within the same shop. So gid://shopify/MediaImage/1234 in Shop A and gid://shopify/Product/1234 in Shop B is totally valid, they’re completely unrelated objects.

The full GID string (the entire gid://shopify/Type/ID value) is what you should treat as the unique identifier, never just the postfix integer. If you’re storing or comparing IDs across shops or resource types, always use the full GID, otherwise you’ll hit collision bugs.


Hope that helps! If it did, a Like and Marking it as Solution goes a long way and helps others find the fix faster too.

Best,
Moeed

I rather remember the “number is unique within resource type”. Not within store, but in entire system, it’s global.

Documentation: – Global IDs in Shopify APIs

Discussion: – Find product by integer id :

So, theoretically, the example situation can happen even in the same shop.

Yes – you should take that into account.

The numerical suffix (1234) should never be used as a globally unique identifier by itself. The correct way for Shopify GID is to use the entire GID string, with the resource included:

gid://shopify/Product/1234
gid://shopify/MediaImage/1234

That is the difference between these two resources – their types differ.

What is less clear is whether this numeric part is globally unique within a resource, or just internally in a particular shop/database partitioning. Since Shopify explicitly states that no guarantee of uniqueness of the number exists in any public API contract, apps should never make any assumptions about it.

Use only the entire GID as the unique identifier.
Never try to work with only the number in the end.
Always assume collisions for both types and potentially multiple shops.

That would mean that the following cases could occur safely:

gid://shopify/Product/1234
gid://shopify/MediaImage/1234

The same numerical value in another shop.

What matters is that the GID is always unique.