REST API - Space Export/Import

Available since v. 2.15.0

  • Added space export/import REST APIs

Available since v. 2.18.0

  • Export space is available to all users with space export permission


Export space

Available only for Confluence Administrator

Available to all users with space EXPORT permission

Method type: poST

URL: {CONFLUENCE_URL}/rest/extender/1.0/export/space/{SPACE_KEY}

  • where {SPACE_KEY} is the space key

Request format: JSON

Example request:

1 2 3 4 5 { "exportType": "XML", "exportComments": true, "exportAttachments": true }
1 2 3 { "exportType": "HTML" }
  • exportType - required - export type - XML or HTML

  • exportComments - optional - export comments flag - true or false (default)

  • exportAttachments - optional - export comments flag - true or false (default)

Response format: JSON

Example response:

1 2 3 4 5 { "message": "writing export", "taskId": "95d6a1d3-0bd2-401b-8288-057e022c6475", "status": "in progress" }

 

1 2 3 4 5 { "message": "another export is in progress", "taskId": "4f3a1aec-5493-4049-8e54-54563c19a971", "status": "waiting" }

 

 


Check export task status

Available only for Confluence Administrator

Method type: GET

URL: {CONFLUENCE_URL}/rest/extender/1.0/export/task/{TASK_ID}

  • where {TASK_ID} is the task id from export api (example: 4f3a1aec-5493-4049-8e54-54563c19a971)

Response format: JSON

Example response:

1 2 3 4 5 6 7 8 9 { "isSuccessful": true, "currentStatus": "Starting... ", "percentageComplete": 0, "name": "Export Space", "prettyTimeRemaining": "Unknown", "isComplete": false, "prettyElapsedTime": "12 seconds" }
1 2 3 4 5 6 7 8 9 { "isSuccessful": true, "currentStatus": "Writing export", "percentageComplete": 36, "name": "Export Space", "prettyTimeRemaining": "20 seconds", "isComplete": false, "prettyElapsedTime": "11 seconds" }
1 2 3 4 5 6 7 8 9 10 11 { "fileName": "Confluence-space-export-105420-1762.html.zip", "isSuccessful": true, "downloadPath": "/confluence/download/temp/htmlexport-20210410-105400-1761/Confluence-space-export-105420-1762.html.zip", "currentStatus": "Export complete. Download <a class=\"space-export-download-path\" href=\"/confluence/download/temp/htmlexport-20210410-105400-1761/Confluence-space-export-105420-1762.html.zip\">here</a>.", "percentageComplete": 100, "name": "Export Space", "prettyTimeRemaining": "Unknown", "isComplete": true, "prettyElapsedTime": "25 seconds" }
1 2 3 4 5 6 7 8 9 10 11 { "fileName": "Confluence-space-export-113149-3510.html.zip", "isSuccessful": true, "downloadPath": "/confluence/download/temp/htmlexport-20210410-113127-3509/Confluence-space-export-113149-3510.html.zip", "currentStatus": "Export complete. Download <a class=\"space-export-download-path\" href=\"/confluence/download/temp/htmlexport-20210410-113127-3509/Confluence-space-export-113149-3510.html.zip\">here</a>.", "percentageComplete": 100, "name": "Export Space", "prettyTimeRemaining": "Unknown", "isComplete": true, "prettyElapsedTime": "30 seconds" }

 


Import space

Available only for Confluence Administrator

Method type: poST

URL: {CONFLUENCE_URL}/rest/extender/1.0/export/import/file

Request format: JSON

Example request:

1 2 3 4 { "fileName": "Confluence-space-export-113149-3510.zip", "reindex": true }
1 2 3 { "fileName": "Example_file.zip" }
  • fileName - required - space export file name from <confluence-home>/restore directory

  • reindex - optional - reindex flag - true or false (default) - this will perform a full reindex of your site immediately after the space or site file is imported

Response format: JSON

Example response:

1 2 3 4 5 { "message": "importing file", "taskId": "2d7c282e-a256-46cf-9d88-a0af0d15a735", "status": "in progress" }
1 2 3 4 5 { "message": "another import is in progress", "taskId": "49d53b5f-a87b-4e6c-bd81-d51203aba04c", "status": "waiting" }
1 2 3 4 { "message": "unexpected import zip file contents: Confluence-space-export-113149-3510.html.zip", "status": "canceled" }

 

 


Check import task status

Available only for Confluence Administrator

Method type: GET

URL: {CONFLUENCE_URL}/rest/extender/1.0/export/import/{TASK_ID}

  • where {TASK_ID} is the task id from import api (example: e142839b-babf-4326-8d34-c7e2ba275c3f)

Response format: JSON

Example response:

1 2 3 4 5 6 7 8 9 { "isSuccessful": true, "currentStatus": "Complete.", "percentageComplete": 100, "name": "Importing data", "prettyTimeRemaining": "Unknown", "isComplete": true, "prettyElapsedTime": "1 minute, 32 seconds" }
1 2 3 4 5 6 7 8 9 { "isSuccessful": false, "currentStatus": "Import failed. Check your server logs for more information. com.atlassian.confluence.importexport.ImportExportException: Unable to complete import because the data does not match the constraints in the Confluence schema. Cause: JdbcSQLIntegrityConstraintViolationException: Unique index or primary key violation: \"PUBLIC.UK_JP1AD5YUFSIH5R7LQRYGAKPUG_INDEX_9 ON PUBLIC.SPACES(SPACEKEY) VALUES 1540099\"; SQL statement:\ninsert into SPACES (SPACENAME, SPACEKEY, LOWERSPACEKEY, SPACEDESCID, HOMEPAGE, CREATOR, CREATIONDATE, LASTMODIFIER, LASTMODDATE, SPACETYPE, SPACESTATUS, SPACEID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [23505-200]", "percentageComplete": 0, "name": "Importing data", "prettyTimeRemaining": "Unknown", "isComplete": false, "prettyElapsedTime": "7 seconds" }