Create spaces and pages from Blueprints programmatically using the REST API.

REST API Requirements

REST API endpoints were added to Blueprint Maker version 2.0+ to allow:

  1. creating new content using a defined blueprint (page, page tree, or space, as defined by the blueprint)
  2. updating an existing page using a defined blueprint (single page blueprints only)

These will function the same as if a creating a Blueprint from the Blueprint Maker wizard menu.


The Blueprint Maker REST API can be used in conjunction with the existing Confluence REST API. For example, 


REST API Usage

Requests
MethodEndpointAction
PUT/rest/blueprintmaker/1.0/createspacecreate new space
PUT/rest/blueprintmaker/1.0/createpagecreate new page
PUT/rest/blueprintmaker/1.0/copyspacecopy space
PUT/rest/blueprintmaker/1.0/copypagecopy page
POST/rest/blueprintmaker/1.0/updatepage/{pageid}regenerate an existing page

Note: For curl requests, you must first create a Personal Access Token. Please see the Atlassian Confluence documentation for the latest information. Once you generate a token, copy it and keep it somewhere safe. Paste this token wherever you see YOURTOKEN in the examples below.

Data

Expects a valid JSON object. Please see the examples below.

Responses

 - Ajax request, application/json

{
	"pageId" : 1234567	// page ID of single page created or updated, or root of page tree, or space home page
}

 - curl request, application/xml

<xml version="1.0" encoding="UTF-8" standalone="yes"><results><pageId>12345678</pageId></results>

 - Caller lacks permission to edit/create pages in the destination space, or a multi-page blueprint was specified (PUT request).

 - The specified blueprint, destination page (PUT request), or destination parent page doesn't exist or caller lacks view permission.


Examples

Create Space (JQuery Ajax)
var data = {
	blueprint: {
		name: "Project Space"
	},
	destination: {
		spaceKey: "sunset",
		spaceName: "Sunset Hills",
		spaceDescription: "Everything you need to know about the Sunset Hills project."
	},
	fields: [
		{
            name: "project-name",
            value: "Sunset Hills Estates"
        },
        {
            name: "location",
            value: "432 West Elm"
        }
	]
};
$.ajax({ 
	url: "/rest/blueprintmaker/1.0/createspace", 
	data : JSON.stringify(data), 
	type: "PUT", 
	success: function(r) {console.log(r);}, error: function(x,s,t) {console.log(x,s,t);}, 
	dataType: "json"
});
Create Space (curl)

Note: for all curl examples, replace YOURTOKEN with your Personal Access Token. Replace BASEURL with your server or data center base url (e.g. "https://company.wiki.com"), and PAGEID with the page ID (e.g. "12345678"), where applicable.

curl -X PUT -H "Authorization:Bearer YOURTOKEN" -H "Content-Type:application/json" -d '{ "blueprint":{"name":"Project Space", "spaceKey":"projectblueprint"}, "destination": {"spaceKey":"sunset", "spaceName":"Sunset Hills", "spaceDescription":"Everything you need to know about the Sunset Hills project."}, "fields":[{"name":"project-name", "value":"Sunset Hills Estates"}, {"name":"location", "value":"432 West Elm"}] }' BASEURL/rest/blueprintmaker/1.0/createspace


Create Page (JQuery Ajax)
var data = {
    blueprint: {
        name: "Project Page"
    },
    destination: {
        spaceKey: "project",
        pageTitle: "Project [[project-number]] - [[project-name]]",
        parentPageTitle: "Projects Home"
    },
    fields: [
        {
            name: "project-number",
            value: "23445"
        },
        {
            name: "project-name",
            value: "Sunset Hills"
        },
        {
            name: "location",
            value: "432 West Elm"
        },
        {
            name: "site-manager-name",
            value: "Susan Clarke"
        },
        {
            name: "site-manager-phone",
            value: "(123) 555-4433"
        },
        {
            name: "completion-date",
            value: "11/30/2019"
        }
    ]
};
$.ajax({
    url: "/rest/blueprintmaker/1.0/createpage",
    data : JSON.stringify(data),
    type: "PUT",
    success: function(r) {console.log(r);}, error: function(x,s,t) {console.log(x,s,t);},
    dataType: "json"
});
Create Page (curl)
curl -X PUT -H "Authorization:Bearer YOURTOKEN" -H "Content-Type:application/json" -d '{ "blueprint":{"name":"Project Page"}, "destination": {"spaceKey":"project", "pageTitle":"Project [[project-number]] - [[project-name]]", "parentPageTitle":"Projects Home"}, "fields":[{"name":"project-number", "value":"23445"}, {"name":"project-name", "value":"Sunset Hills"}, {"name":"location", "value":"432 West Elm"}, {"name":"site-manager-name", "value":"Susan Clarke"}, {"name":"site-manager-phone", "value":"(123) 555-443"}, {"name":"completion-date", "value":"11/30/2019"}] }' BASEURL/rest/blueprintmaker/1.0/createpage


Copy Space (JQuery Ajax)
var data = {
	source: {
		spaceKey: "sunset"
	},
	destination: {
		spaceKey: "seaside",
		spaceName: "Seaside Project",
		spaceDescription: "Everything you need to know about the Seaside project."
	}
};
$.ajax({ 
	url: "/rest/blueprintmaker/1.0/copyspace", 
	data : JSON.stringify(data), 
	type: "PUT", 
	success: function(r) {console.log(r);}, error: function(x,s,t) {console.log(x,s,t);}, 
	dataType: "json"
});
Copy Space (curl)
curl -X PUT -H "Authorization:Bearer YOURTOKEN" -H "Content-Type:application/json" -d '{ "source":{"spaceKey":"sunset"}, "destination": {"spaceKey":"seaside", "spaceName":"Seaside Project", "spaceDescription":"Everything you need to know about the Seaside project."} }' BASEURL/rest/blueprintmaker/1.0/copyspace


Copy Page
var data = {
	source: {
		spaceKey: "sunset",
		pageTitle: "Sunset Information"
	},
	destination: {
		spaceKey: "sunset",
		pageTitle: "Sunset Site Details"
	}
};
$.ajax({ 
	url: "/rest/blueprintmaker/1.0/copypage", 
	data : JSON.stringify(data), 
	type: "PUT", 
	success: function(r) {console.log(r);}, error: function(x,s,t) {console.log(x,s,t);}, 
	dataType: "json"
});
Copy Page (curl)
curl -X PUT -H "Authorization:Bearer YOURTOKEN" -H "Content-Type:application/json" -d '{ "source":{"spaceKey":"sunset", "pageTitle":"Sunset Information"}, "destination": {"spaceKey":"sunset", "spaceName":"Sunset Site Details"} }' BASEURL/rest/blueprintmaker/1.0/copyspace


Update Page (curl)
curl -X POST -H "Authorization:Bearer YOURTOKEN" -H "Content-Type: application/json" -d '{"blueprint":{"name":"Project Page"}, "destination":{"pageTitle":"Project [[project-number]] - [[project-name]]"}, "fields":[{"name":"project-number", "value":"23445"}, {"name":"project-name", "value":"Sunset Vista"}, {"name":"location", "value":"432 West Elm"}, {"name":"site-manager-name", "value":"Susan Hitcheson"}, {"name":"site-manager-phone", "value":"(123) 555-4433"}, {"name":"completion-date", "value":"12/31/2019"}]}' BASEURL/rest/blueprintmaker/1.0/updatepage/PAGEID