Blueprint Maker REST API
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:
- creating new content using a defined blueprint (page, page tree, or space, as defined by the blueprint)
- 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
PUT /rest/blueprintmaker/1.0/createspace (create new space) PUT /rest/blueprintmaker/1.0/createpage (create new page) POST /rest/blueprintmaker/1.0/updatepage/{pageid} (recreate an existing page) PUT /rest/blueprintmaker/1.0/copyspace (copy space) PUT /rest/blueprintmaker/1.0/copypage (copy page)
Data
{ "blueprint" : { "name" : "Blueprint name" // not required for copyspace and copypage }, "source" : { // only for copypage and copyspace "spaceKey" : "sourceSpaceKey", "pageTitle" : "Source Page Title" // only for copypage }, "destination" : { // if not specified for copypage, new page will be a sibling to the source page "pageId" : "1234567", // if specified, spaceKey and pageTitle will be ignore for calculating destination page // ignored for updatepage "spaceKey" : "destinationSpaceKey", "spaceName" : "New Space Name", // required for createspace and copyspace "spaceDescription" : "Space Blurb", // optional, only for createspace and copyspace "pageTitle" : "Destination Page Title", "parentPageTitleId" : "1234567" // optional: defaults to destination space home page for createpage "parentPageTitle" : "Parent Page" // optional: defaults to destination space home page for createpage // defaults to parent of source page for copypage // ignored if parentPageTitleId is specified }, "fields" : [ // values to substitute for blueprint fields "field1" : "value", "field2" : "value" ] }
Responses
STATUS: 200 - application/json
{ "pageId" : 1234567 // page ID of single page created or updated, or root of page tree, or space home page }
STATUS: 403 - Caller lacks permission to edit/create pages in the destination space, or a multi-page blueprint was specified (PUT request)
STATUS: 404 - The specified blueprint, destination page (PUT request), or destination parent page doesn't exist or caller lacks view permission
JavaScript Examples (jQuery)
Create Space
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" }, { 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 Page
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" });
Update Page
curl -u admin:admin -X POST -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"}]}' http://localhost:8090/rest/blueprintmaker/1.0/updatepage/139526161
Copy Space
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 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" });