Preview token expired errors

I'm getting the following result from the API when an expired token is used. Here is the result.

  "message":"https://[REDACTED][REDACTED]?websitePreviewId=[REDACTED] not found"

I've had an error handler that looks for "This preview token has expired" that had been working, has the API changed?


The API hasn't changed and yes, this happens when the token expires. This can happen if the Prismic toolbar is not setup properly because its role is to update the preview token after a change has been made.

  • Have you tried refreshing the page?
  • Which technology are you using in your project and how did you configured the previews in it?

I'm using .NET.

I maintain the kit for this so I am keen to know if the error type api_notfound_error is only returned for expired preview tokens, or if it would be returned for any badly configured API.

I've seen this occur when a user closes the preview tab without exiting preview mode and the preview is subsequently published. Because the exception is thrown server-side there is no way for the toolbar to tidy up the cookie.

I would like to update the kit to catch the exception and use a piece of middleware to remove the cookie and reload the page.

I see, thanks for the information, I've asked the team. I'll get back to you as soon as I have an answer


Hello, I've discussed this with the team today and we've agreed to add it to the issue tracker. Also, if you would like to do a collaboration to make it quicker you can submit a PR to the kit and we'll review it as soon as we can.


This issue has been closed due to inactivity. Flag to reopen.

@benembery I've reopened this for you now.

This issue has been closed due to inactivity. Flag to reopen.

@benembery I'm just quoting you here to see if I can get more info for you.

Which api response are you describing?

The CSharp Kit sets the ref set based on the preview cookie, if the cookie is expired they the request throws an exception.

This exception has changed.

  "message":"This preview token has expired",

I should be able handle it correctly if this is the correct response.

HI Ben,

I'm really sorry about how long it took to get this information for you. I suck.

So I confirmed with Seb and Renaud. If any ref starts with https:// and is either expired or invalid you get this error. The API hasn't changed and this has been how expired ref have been returned as long as I've been at the company anyway.

@Phil you definitely do not suck. I appreciate your support, thanks for getting back to me, it wasn't super critical. I now have another little improvement I can make for people using prismic with .NET. :smiley:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.