Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Content Layer
namePage Info
id821023944
classwatermark-layer
Content Column
namePage Body
width100.00002%
id821023946
Content Block
background-colortransparent
namePrompt
rich-link-hoverstrue
id821023943
classtight reference-prompt-flex

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

Content Block
nameReference
rich-link-hoverstrue
id1434454811
classpage-pattern-heading reference-reference-flex

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, 

Open Links in New Window


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

Status
colourGreen
titleStatus: 200
 - Ajax request, application/json

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

Status
colourGreen
titleStatus: 200
 - curl request, application/xml

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

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

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


Examples

Create Space (JQuery Ajax)
Code Block
languagejs
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.

Code Block
languagebash
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)
Code Block
languagejs
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)
Code Block
languagebash
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)
Code Block
languagejs
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)
Code Block
languagebash
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
Code Block
languagejs
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)
Code Block
languagebash
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)
Code Block
languagejs
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
Content Layer
background-color$lightGrayColor
nameRelated
id1407948505
Content Column
nameRelated
width100%
id1407948506
Content Block
rich-links-hide-descriptiontrue
rich-links-hide-site-namefalse
rich-link-hoverstrue
rich-links-columns4
rich-links-verticaltrue
rich-links-image-height100px
rich-links-hide-site-icontrue
rich-links-details-padding10px
nameRelated
rich-links-enabletrue
rich-links-details-alignmentleft
rich-links-margin20px 30px 0 0
id833591344
classrelated-block clean reference-related-flex