How to create spaces with blueprints through the Confluence REST API

Still need help?

The Atlassian Community is here for you.

Ask the community

This article only applies to the Atlassian server platform. Learn more about the differences between cloud and server.

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

  1. Identify the ID of each blueprint with the following endpoint (GET request):

    /rest/create-dialog/1.0/space-blueprint/list
    1. 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": []
        }
  2. Review the output of the first call and find the blueprint you would like to use
  3. Take note of the id for that blueprint
    1. Example for Personal space Blueprint based on the output above: 61a7c137-68e5-4de8-8764-354d9506260b
  4. 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"
       }
    }
  5. Run a POST request to the following endpoint and the body from step 4:

    /rest/create-dialog/1.0/space-blueprint/create-space
  6. 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.

DescriptionHow to create spaces using blueprints through the Confluence REST API
ProductConfluence
Last modified on Nov 22, 2019

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.