Using an older's version page ID to get the latest's page version ID

A confluence-cloud page has a unique pageID e.g. 98306.

When I access from the webui older page versions, the pageId changes to something like 3670020 or 3702790 and it is different for every page version.

If I am on a older version page, and I know the pageId of the old version, is there a way to find the initial unique page ID using the RestAPI ( ?

something like : GET /wiki/rest/api/content/ ?

Have you tried the /wiki/rest/api/content/{id}/history endpoint? Seems like this will get you the latest ID from the ID you have.


Let me know if that works for you.

Thanks @rwhitbeck,

Well, i am working with a confluence macro and I use the pageId as the main argument.

When I try to run the macro in a older version page , I am getting the message “This content with this ID does not exist”. So I cannot run the macro to previous page versions.

The ‘history’ endpoint that was mentioned, it can work (while accessing older page versions) only if i had a way to know the pageId of the current page version .

Does that make any sense ?

Thanks again !!

Thanks for that context. Let me dig a little deeper.

I have a similar problem at the moment too: when the macro is viewed on a historical version, I get only the page id of the historical version but some of the content I want to access (attachments, custom content) are always stored under the id of the current version
It seems to be surprisingly hard (on Cloud) to go from the id of the historical version to the id of the latest version, as @mantadakise mentions all the APIs seem to go the other way: assume that you have the id of the current version and want to also see historical content

One hack that is working for me (at the moment):
the /wiki/rest/api/content/{id}/version endpoint gives a result also with an id of a historical version
Most of the other content/{id} endpoints just return 404 in that case

The content/{id}/version endpoint returns an array with a single entry when called with id of a historical version, and some of the links in that entry point to current version

I use results[0]._links.self and parse the current version id from it (the link has the format /wiki/rest/api/content/{current-version-id}/version/{version-number-of-the-historical-version}

Obviously this is not a very robust solution but better than nothing :slight_smile:
Would appreciate comments if someone knows of a more stable way to get the info!


Many thanks @riku it worked. Happy New Year btw.