Is there any difference between a document's UID versus ID?

Hi all!

Just a couple quick questions that I couldn't find a direct answer to. What is the difference, if any, between the document's UID and its ID?

I know the Prismic types for Typescript specify two different kinds of documents - one with a uid of null and one with a uid as string. Custom types follow this, as a singleton doesn't necessarily need a UID field it looks like. Because of this, I figure document IDs are always present, but do they follow the conventions of a document UID? Are document IDs ever changed for any reason?

Thanks!

Hello Cameron,

Thanks for reaching out to us.

This is a very nice question. So document UID is a unique identifier and is often (though not always) used to create the URL of your website. UIDs are also unique. Prismic ensures that no two documents with the same Custom Type have the same UID. And you are correct that Uid is meant to use for repeatable Custom types to distinguish and create URLs of the same Custome type based on different UID's. UID Field Reference - Documentation - Prismic

The ID is specified in the document’s _id property and must be unique. ID's and UID don't follow the same convention. The ID cannot be modified once a document is created since it tracks its history and relations.

I hope it's clear to you. Let me know if you have any further questions.

Thanks,
Priyanka

1 Like