Error: This value is already used by another document

When adding a value to your UID field, you may encounter an error when trying to save your page.

This could mean another page in your repository already has this UID value. It could be a page that is drafted or in the archive. If you can't find the page with this UID value, one of your pages used to have this UID value, and kept it stored in its history. To re-assign a UID, you must delete the document that currently has that UID.

This article will explain why an old UID becomes locked and how to unlock it.

Old UID Values

A UID field will save all previous UID values.

We save all the previous UID values of a given document so that your old links won't be broken on your site when you change a UID value.

Because the UID value must be unique, the document can not reuse an old UID value on a different one. You will receive the above error if you try to use an old UID name on a different document.

Preventing an old URL from appearing on your site

To prevent a page from appearing with the old URL, we suggest that you check with each URL to see if the UID received is the current one. If so, load the page; if not, redirect to the current URL.

Finding, removing, & unlocking an old UID value from a document

What if I need to use a UID that has previously been used?

Let’s say you have an old UID value called old-uid that you wish to reuse on another document. To reassign it, duplicate the document associated with old-uid and delete the document’s original version.

If you don’t know which document is storing old-uid, navigate to your API Explorer (replace your-repo-name with your repository’s name):

https://your-repo-name.prismic.io/builder/explorer

Change the request method to getByUID, select your document type, and enter the UID you’re looking for. The document associated with old-uid will be returned.

Note that if your repo uses more than one language, you might need to select different lang parameters.

Once you've found the page, you need to duplicate it. You can do this by going to that page, click on the three dots next to the Publish button, and click on Duplicate.

After you've duplicated it, you can delete the original, and this will allow you to use old-uid again.

1 Like

Threads close after a period of inactivity. Flag this thread to re-open it and continue the conversation.

Hey,

But in my case, I use UIDs as the page paths.
And when I want to add a link in page (A) to point to page (B), I do that by linking the page documents internally (i.e. add a link in page A document pointing to page B document). So if I duplicate and delete the old document of page (B) all the links to page (B) in other documents will be broken.

Also, according to SEO, it is not recommended to have 2 urls serving the same content. Is there any way I can unlock the old UIDs to reuse them without deleting the old page document?

Thanks :slight_smile:

Hello @mahmoud.elbayoumy, Yes. If you delete a document you'd need to re-add the links where you used it. For the moment this is the only workaround to reuse an existing old UID.

Hello @maxime.hersand

Duplicating a document is making a copy of that sole document. Nothing else gets duplicated except that one. In the duplicated version, all content will be the same, including Links to other documents, but these are just references to those docs. It doesn’t mean they get duplicated as well.

We are already tracking it as a feature request for future improvement.

Thanks for pointing this out.

Priyanka

And in the case a document was deleted (not archived), is there a way to free up that UID value?

Hi @stefan.suhani_blondi, Deleting a document automatically frees the use of the reserved UID value.

Hi Pau,

I'm in a situation where performing the above query returns one document but this document is not visible in my Prismic dashboard. What am I supposed to do to free up the UID in that case?

When I go to the document based on the ID, there is a mismatch between the route name and the UID value I want to use. :scream:

Hey @prismic24, I'm not sure why this could be happening. I'll need the following info to try and reproduce it:

  • URL of your repository
  • The query
  • UID and type of the document

For future users that encounter this issue but can't find the document with that uid in the api:

For me, the document returned in in the API didn't have the same uid, but still walking through the steps above on that very document deleted the uid in question. It's like that document had 2 uids.

Hope this helps others that end up in this tricky spot!

1 Like

How do I delete the original? It's only archived and still has the same UID.

Hi @technigo ,

If you visit the archived document you can delete it from there.