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
Available since v. 2.36.0
Export space - added new flags multiple and synchronous
Import space - added new flag synchronous
General information
Due to restrictions imposed by Atlassian, the export/import REST APIs only work in Confluence from version 6.10.* to 8.9.*
For Confluence from version 9.0.*, we suggest using the built-in REST API to export/import space.
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:
{
"exportType": "XML",
"exportComments": true,
"exportAttachments": true
}
{
"exportType": "HTML"
}
{
"exportType": "XML",
"exportComments": true,
"exportAttachments": true,
"multiple": true
}
{
"exportType": "HTML"
"synchronous": true
}
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)
multiple - optional - skip checking another export task, which allows you to start exporting another space at the same time - true or false (default)
synchronous - optional - the export will be performed synchronously - true or false (default)
Response format: JSON
Example response:
{
"message": "writing export",
"taskId": "95d6a1d3-0bd2-401b-8288-057e022c6475",
"status": "in progress"
}
{
"message": "another export is in progress",
"taskId": "4f3a1aec-5493-4049-8e54-54563c19a971",
"status": "waiting"
}
Check the 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:
{
"isSuccessful": true,
"currentStatus": "Starting... ",
"percentageComplete": 0,
"name": "Export Space",
"prettyTimeRemaining": "Unknown",
"isComplete": false,
"prettyElapsedTime": "12 seconds"
}
{
"isSuccessful": true,
"currentStatus": "Writing export",
"percentageComplete": 36,
"name": "Export Space",
"prettyTimeRemaining": "20 seconds",
"isComplete": false,
"prettyElapsedTime": "11 seconds"
}
{
"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"
}
{
"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/import/file
Request format: JSON
Example request:
{
"fileName": "Confluence-space-export-113149-3510.zip",
"reindex": true
}
{
"fileName": "Example_file.zip"
}
{
"fileName": "Confluence-space-export-113149-3510.zip",
"reindex": true,
"synchronous": true
}
fileName - required - space export file name from
<confluence-home>/restore
directoryreindex - 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
synchronous - optional - the import will be performed synchronously - true or false (default)
Response format: JSON
Example response:
{
"message": "importing file",
"taskId": "2d7c282e-a256-46cf-9d88-a0af0d15a735",
"status": "in progress"
}
{
"message": "another import is in progress",
"taskId": "49d53b5f-a87b-4e6c-bd81-d51203aba04c",
"status": "waiting"
}
{
"message": "unexpected import zip file contents: Confluence-space-export-113149-3510.html.zip",
"status": "canceled"
}
Check the import task status
Available only for Confluence Administrator
Method type: GET
URL: {CONFLUENCE_URL}/rest/extender/1.0/import/task/{TASK_ID}
where {TASK_ID} is the task id from import api (example:
e142839b-babf-4326-8d34-c7e2ba275c3f
)
Response format: JSON
Example response:
{
"isSuccessful": true,
"currentStatus": "Complete.",
"percentageComplete": 100,
"name": "Importing data",
"prettyTimeRemaining": "Unknown",
"isComplete": true,
"prettyElapsedTime": "1 minute, 32 seconds"
}
{
"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"
}