Passing webhook doc ids to new query

Hello Prismic community,

I hope this message finds you well. I'm currently encountering an issue with the "@prismicio/client" npm package, specifically version "^7.3.1," and I could use some assistance in resolving it.

Goal: From a Webhook request, retrieving document to build url in order to invalidate nextJS page cache from path

Problem Description: When making requests using the getByID or getByIDs methods, I am consistently receiving empty documents as a response. I have verified that the Access Token and repository client values are correct, and I've confirmed that the IDs provided in the requests are valid.

Code Sample:

javascriptCopy code

const document = await this.prismic.getByID(id);
// OR
const { results } = await this.prismic.getByIDs(ids);

Additional Details:

  • Package Version: ^7.3.1
  • Environment: Local with staging credentials
  • Access Token and Repository Client values are correctly configured.

Steps Taken:

  1. Checked and confirmed the correctness of the Access Token and Repository Client values.
  2. Verified that the provided document IDs are valid.
  3. Double-checked the ID yielded to the request, and it appears to be correct.
  4. Attempted the request with different valid document IDs, still receiving empty documents.

Expected Outcome: I expect to receive the actual document data corresponding to the provided document IDs.

Actual Outcome: The requests consistently return empty documents or error from getByID


  • Node.js version: 18.19 (Latest as of [Current Date])
  • Operating System: MacOS 14.1.1

Note: This issue is hindering my development progress, and any assistance or insights you can provide would be greatly appreciated. If there are any additional details or logs needed, please let me know, and I'll be happy to provide them.

Thank you for your time and assistance.

Best regards,

Additional Detail:
I'm using the getSingle method to fetch a document by its type, and the response is successful. However, when I attempt to retrieve the same document using its ID with the getByID method, the returned document is empty.

Code Sample:

const response = await this.prismic.getSingle('template');
// Response is okay
const doc = await this.prismic.getByID(;
// Document is empty

Hi @antoine.duvillier ,

Are you, by any chance, confusing the ID and the UID?

Despite using the document IDs provided by the webhook, the subsequent attempt to fetch the document using getByID still results in an empty document. I've noticed that the IDs I'm working with are UID values rather than traditional document IDs.

const webhookResponse = //... // The response from the webhook containing the 'documents' property
const documentID = webhookResponse.documents[0]; // Using the first document ID from the list
const doc = await this.prismic.getByID(documentID);
// At this point, 'doc' is consistently empty

Could the usage of UID instead of ID be influencing this behavior? Any guidance on how to handle UIDs in this context would be highly appreciated.

Thank you for your continued assistance.

Best regards,

Other example:

const response = await this.prismic.getSingle('template');
// Response is okay
const doc = await this.prismic.getByID(;

If you're using UIDs with the getByID method it will fail. The UID, which acts as the URL for the document, can be used to query a document with getByUID(type, uid).

If you're trying to invalidate the Next cache then the method here also works:

Are you understand this code below? i already post it thee times, and the issue is obvious.
I'm using the id.

const response = await this.prismic.getSingle('template');
// Response is okay
const doc = await this.prismic.getByID(;
// Doc is ko

I understand the code, I'm just trying to clarify because whatever you're passing as is breaking the query in that case, unless no document exists.

The best way to see why it's not working is to console log, then if it's anything other that an ID such as ZTtDgBIAAFAMojmh then your code is breaking down there.

If response is a variable which represents the webhook payload as described in the article below then you'll your code should be prismic.getByIDs(arrayOfIDs) since you're dealing with an array in the response, the array in this case would be response.documents, so prismic.getByIDs(response.documents)

But again if your goal is...

Then the method I linked to will most likely be more robust.