Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

REST API - Deleting old version issue Edited


I have a automation which publish 10s of pages on confluence everyday. Right now i am checking page existence, if page exists delete it and create it again with new content. 

Instead of delete -> create , I am thinking to update if page exists. I think update will work all fine but issue I have is as i have 10s of pages and if i update the page  it will have versions with every page and eventually after a month, i will end up 1000s of revisions. 

So solution i was looking here is update the page and delete the version (latest -2), this way i will always main 2 versions of page and will also not end up having 1000s of versions. 

After doing some research i found below link which stats it is possible if we get pageID of version.


But I could not find the pageID of version. For sample I am pasting my output data as below: 


{"results":[{"by":{"type":"known","accountId":"xx","accountType":"atlassian","email":"dxx","publicName":"x","profilePicture":{"path":"/wiki/aa-avatar/xx","width":48,"height":48,"isDefault":false},"displayName":"x","_expandable":{"operations":"","personalSpace":""},"_links":{"self":"https://x/wiki/rest/api/user?accountId=xxx"}},"when":"2020-03-27T04:41:41.331Z","friendlyWhen":"27 minutes ago","message":"","number":2,"minorEdit":false,"syncRev":"0.confluence$content$12345","syncRevSource":"synchrony-ack","confRev":"confluence$content$12345.7","_expandable":{"collaborators":"","content":"/rest/api/content/12345"},"_links":{"self":"https:///wiki/rest/api/content/12345/version/2"}},{"by":{"type":"known","accountId":"x","accountType":"atlassian","email":"xx","publicName":"x","profilePicture":{"path":"/wiki/aa-avatar/x","width":48,"height":48,"isDefault":false},"displayName":"DevOps Confluence","_expandable":{"operations":"","personalSpace":""},"_links":{"self":"https:///wiki/rest/api/user?accountId=xx"}},"when":"2020-03-27T04:24:51.404Z","friendlyWhen":"44 minutes ago","message":"","number":1,"minorEdit":false,"syncRev":"0.confluence$content$12345","syncRevSource":"synchrony-ack","confRev":"confluence$content$123456.3","_expandable":{"collaborators":"","content":"/rest/api/content/12345?status=historical&version=1"},"_links":{"self":"https:///wiki/rest/api/content/12345/version/1"}}],"start":0,"limit":200,"size":2,"_links":{"base":"https:///wiki","context":"/wiki","self":"https:///wiki/rest/api/content/12345/version"}}

This PageID 12345 has 2 versions. Now I could use 

DELETE https://wiki/rest/api/content/12345/version/1 but i am getting 404 



1 answer

0 votes
Dario B Atlassian Team Apr 03, 2020

Hello @Sukhjinder Bhullar ,

If I understand correctly you are trying to delete a page version via REST API but this is not succeeding for you. 

I have just tested it and it worked fine for me. What I have done is the following:


1) Send a request to Get content versions (GET /wiki/rest/api/content/{id}/version):

curl -u <EMAIL-ADDRESS>:<API-TOKEN> "https://<SITE_NAME>"

"results": [
"by": {
"type": "known",
"when": "2020-03-27T10:32:39.812Z",
"friendlyWhen": "Mar 27, 2020",
"message": "",
"number": 9,
"minorEdit": false,
"_links": {
"self": "https://<SITE_NAME>"


2) From above results, you can see that the last version at the moment is version number 9


3) Send a DELETE request to remove version 4 (endpoint: /wiki/rest/api/content/<ID>/version/4). Adding the -D- flag to show the response header:

curl -D- -u <EMAIL-ADDRESS>:<API-TOKEN> -X DELETE "https://<NAME>"
HTTP/2 204 
server: AtlassianProxy/
cache-control: no-cache, no-store, must-revalidate
content-type: application/json


4) Sending another request to GET the page versions like in step #1 will now show the last version for the page to be version number 8.

This is because, as written in the documentation for the Delete content version REST API endpoint (DELETE /wiki/rest/api/content/{id}/version/{versionNumber}) the changes for the deleted version are rolled-up into next-version:

Delete a historical version. This does not delete the changes made to the content in that version, rather the changes for the deleted version are rolled up into the next version. Note, you cannot delete the current version.


I hope this helps.



Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

8,583 views 7 7
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you