How to create spaces with blueprints through the Confluence REST API
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Purpose
If you intend to automate the space creation process, using the REST API is one of the best options available. It is possible to use the space blueprints for that end as well, following the steps below:
Solution
Identify the ID of each blueprint with the following endpoint (GET request):
/rest/create-dialog/1.0/space-blueprint/list
Sample output below:
{ "id": "09da09e2-fa72-4ca5-9bd2-376b0684b5a9", "moduleCompleteKey": "com.atlassian.confluence.plugins.confluence-software-project:sp-space-blueprint", "i18nNameKey": "confluence.blueprints.space.sp.name", "pluginClone": true, "homePageId": "82844b99-7c5f-453b-a9d8-eb38b4e5ee45", "dialogWizard": { "key": "sp-space-blueprint-wizard", "pages": [ { "id": "spSpaceId", "templateKey": "Confluence.SpaceBlueprints.SoftwareProject.Dialog.dialogForm", "titleKey": "confluence.blueprints.space.sp.dialog.create.title", "descriptionHeaderKey": "confluence.blueprints.space.sp.dialog.create.heading", "descriptionContentKey": "confluence.blueprints.space.sp.dialog.create.description", "last": true } ] }, "promotedBps": [ "com.atlassian.confluence.plugins.confluence-software-blueprints:requirements-blueprint", "com.atlassian.confluence.plugins.confluence-business-blueprints:meeting-notes-blueprint", "com.atlassian.confluence.plugins.confluence-business-blueprints:file-list-blueprint", "com.atlassian.confluence.plugins.confluence-software-blueprints:decisions-blueprint", "com.atlassian.confluence.plugins.confluence-software-blueprints:retrospectives-blueprint", "com.atlassian.confluence.plugins.confluence-software-blueprints:jira-sprints-blueprint" ], "category": "software-project" }, { "id": "2aa2a279-c037-4f7e-9411-8ece0118991f", "moduleCompleteKey": "com.atlassian.confluence.plugins.confluence-knowledge-base:kb-blueprint", "i18nNameKey": "confluence.blueprints.space.kb.name", "pluginClone": true, "homePageId": "3ae99dee-e1bc-4132-bad6-661eef8ec318", "dialogWizard": { "key": "kb-space-wizard", "pages": [ { "id": "kbSpaceId", "templateKey": "Confluence.SpaceBlueprints.KnowledgeBase.dialogForm", "titleKey": "confluence.blueprints.space.kb.dialog.create.title", "descriptionHeaderKey": "confluence.blueprints.space.kb.dialog.create.heading", "descriptionContentKey": "confluence.blueprints.space.kb.dialog.create.description", "last": true } ] }, "promotedBps": [ "com.atlassian.confluence.plugins.confluence-knowledge-base:kb-how-to-article-blueprint", "com.atlassian.confluence.plugins.confluence-knowledge-base:kb-troubleshooting-article-blueprint" ], "category": "knowledge-bases" }, { "id": "fed341f3-271d-438f-9686-d32b114bab21", "moduleCompleteKey": "com.atlassian.confluence.plugins.confluence-space-blueprints:team-space-blueprint", "i18nNameKey": "confluence.blueprints.space.team.name", "pluginClone": true, "homePageId": "7a66ffe4-474f-4875-a3c5-ee79230ec2d6", "dialogWizard": { "key": "team-space-blueprint-wizard", "pages": [ { "id": "teamSpaceId", "templateKey": "Confluence.SpaceBlueprints.Team.dialogForm", "titleKey": "confluence.blueprints.space.team.dialog.create.title", "descriptionHeaderKey": "confluence.blueprints.space.team.dialog.create.heading", "descriptionContentKey": "confluence.blueprints.space.team.dialog.create.description", "last": true } ] }, "promotedBps": [ "com.atlassian.confluence.plugins.confluence-business-blueprints:file-list-blueprint", "com.atlassian.confluence.plugins.confluence-business-blueprints:meeting-notes-blueprint", "com.atlassian.confluence.plugins.confluence-business-blueprints:decisions-blueprint", "com.atlassian.confluence.plugins.confluence-business-blueprints:sharelinks-blueprint", "com.atlassian.confluence.plugins.confluence-create-content-plugin:create-blank-page", "com.atlassian.confluence.plugins.confluence-create-content-plugin:create-blog-post" ], "category": "teams" }, { "id": "75bebe01-dcdb-4641-94c1-1777e81f4cd4", "moduleCompleteKey": "com.atlassian.confluence.plugins.confluence-space-blueprints:documentation-space-blueprint", "i18nNameKey": "confluence.blueprints.space.documentation.name", "pluginClone": true, "homePageId": "1c0743ab-32e5-4347-832b-22c918c74f5e", "dialogWizard": { "key": "documentation-space-blueprint-wizard", "pages": [ { "id": "documentationSpaceId", "templateKey": "Confluence.SpaceBlueprints.Documentation.dialogForm", "titleKey": "confluence.blueprints.space.documentation.dialog.create.title", "descriptionHeaderKey": "confluence.blueprints.space.documentation.dialog.create.heading", "descriptionContentKey": "confluence.blueprints.space.documentation.dialog.create.description", "last": true } ] }, "promotedBps": [ "com.atlassian.confluence.plugins.confluence-create-content-plugin:create-blank-page" ], "category": "documentation" }, { "id": "d80c1ad2-cf23-4f8a-b524-92e9a8badd50", "moduleCompleteKey": "com.atlassian.confluence.plugins.confluence-create-content-plugin:create-blank-space-blueprint", "i18nNameKey": "Blank space Blueprint", "pluginClone": true, "dialogWizard": { "key": "blank-space-blueprint-wizard", "pages": [ { "id": "commonPage", "templateKey": "Confluence.Templates.Blueprints.CreateSpace.createSpaceForm", "titleKey": "create.content.plugin.create.blank.space.title", "descriptionHeaderKey": "create.content.plugin.create.blank.space.desc.header", "descriptionContentKey": "create.content.plugin.create.blank.space.desc.content", "last": true } ] }, "promotedBps": [] }, { "id": "61a7c137-68e5-4de8-8764-354d9506260b", "moduleCompleteKey": "com.atlassian.confluence.plugins.confluence-create-content-plugin:create-personal-space-blueprint", "i18nNameKey": "Personal space Blueprint", "pluginClone": true, "dialogWizard": { "key": "personal-space-blueprint-wizard", "pages": [ { "id": "personal-space", "templateKey": "Confluence.Templates.Blueprints.CreateSpace.createPersonalSpaceForm", "titleKey": "create.content.plugin.create.personal.space.title", "last": true } ] }, "promotedBps": [] }
- Review the output of the first call and find the blueprint you would like to use
- Take note of the id for that blueprint
- Example for Personal space Blueprint based on the output above: 61a7c137-68e5-4de8-8764-354d9506260b
Build the BODY for the post request that will create the space, we need to set the spaceBlueprintId to the id noted on the previous step. Example:
{ "spaceKey":"PSPACE", "name":"Personal space from blueprint", "description":"", "spaceBlueprintId":"61a7c137-68e5-4de8-8764-354d9506260b", "context":{ "name":"team", "spaceKey":"TEAM", "members":"admin", "description":"describe the space", "ContentPageTitle":"team" } }
If you need integration with Jira, you can use this JSON to integrate with and Jira project:
{ "spaceKey": "PSPACE", "name": "Personal space from blueprint", "description": "", "spaceBlueprintId": "61a7c137-68e5-4de8-8764-354d9506260b", "context": { "jira-server": "de8309d4-ca60-3cfe-93b3-af7d2b541ebe", "jira-project": "10100", "name": "Personal space from blueprint", "spaceKey": "PSPACE", "description": "", "noPageTitlePrefix": "true", "atl_token": "undefined", "jira-server-id": "de8309d4-ca60-3cfe-93b3-af7d2b541ebe", "project-key": "Jira project key", "project-name": "Jira project name", "ContentPageTitle": "team" } }
Values for "jira-project" is projectid, which can be retrieved from URL in Project Settings > Description on Jira side, and "jira-server" value can be retrieved from browser URL when editing application link from Confluence.
Run a POST request to the following endpoint and the body from step 4:
/rest/create-dialog/1.0/space-blueprint/create-space
The output should look like this:
{ "key": "PSPACE", "name": "Personal space from blueprint", "description": "", "url": "http://localhost:8090/display/PSPACE" }
Notes
Please notice that each instance will have its own IDs for the blueprints. This is why we need to list them before executing the create request.