Date: Thu, 28 Mar 2024 17:55:52 +0000 (UTC) Message-ID: <413513210.115.1711648552019@ip-10-0-1-24.us-west-2.compute.internal> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_114_672440550.1711648552016" ------=_Part_114_672440550.1711648552016 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Create spaces and pages from Blueprints programmatically using the REST = API.
REST API endpoints were added to Blueprint Maker version 2.0+ to allow:
These will function the same as if a creating a Blueprint from the Bluep= rint Maker wizard menu.
The Blueprint Maker REST API can be used in conjunction with the existin= g Confluence REST API. For example,
Method | Endpoint | Action |
---|---|---|
PUT | /rest/blueprintmaker/1.0/createspace | create new space |
PUT | /rest/blueprintmaker/1.0/createpage | create new page |
PUT | /rest/blueprintmaker/1.0/copyspace | copy space |
PUT | /rest/blueprintmaker/1.0/copypage | copy 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<= /a> 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 exam= ples below.
Expects a valid JSON object. Please see the examples below.
STATUS: 200= - Ajax request, application/json
{ =09"pageId" : 1234567=09// page ID of single page created or updated, or ro= ot of page tree, or space home page }
STATUS: 200= - curl request, application/xml
<xml = version=3D"1.0" encoding=3D"UTF-8" standalone=3D"yes"><results><= ;pageId>12345678</pageId></results>
STATUS: 403 - Caller lacks permission= to edit/create pages in the destination space, or a multi-page blueprint w= as specified (PUT request).
STATUS: 404= span> - The specified blueprint, destination page (PUT request), or de= stination parent page doesn't exist or caller lacks view permission.
var data = =3D { =09blueprint: { =09=09name: "Project Space" =09}, =09destination: { =09=09spaceKey: "sunset", =09=09spaceName: "Sunset Hills", =09=09spaceDescription: "Everything you need to know about the Sunset Hills= project." =09}, =09fields: [ =09=09{ name: "project-name", value: "Sunset Hills Estates" }, { name: "location", value: "432 West Elm" } =09] }; $.ajax({=20 =09url: "/rest/blueprintmaker/1.0/createspace",=20 =09data : JSON.stringify(data),=20 =09type: "PUT",=20 =09success: function(r) {console.log(r);}, error: function(x,s,t) {console.= log(x,s,t);},=20 =09dataType: "json" });
Note: for all curl examples, replace YOURTOKEN with you= r Personal Access Token. Replace BASEURL with your server or data center ba= se 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", "spaceDes= cription":"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/crea= tespace
var data = =3D { 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" });
curl -X= PUT -H "Authorization:Bearer YOURTOKEN" -H "Content-Type:application/json"= -d '{ "blueprint":{"name":"Project Page"}, "destination": {"spaceKey":"pro= ject", "pageTitle":"Project [[project-number]] - [[project-name]]", "parent= PageTitle":"Projects Home"}, "fields":[{"name":"project-number", "value":"2= 3445"}, {"name":"project-name", "value":"Sunset Hills"}, {"name":"location"= , "value":"432 West Elm"}, {"name":"site-manager-name", "value":"Susan Clar= ke"}, {"name":"site-manager-phone", "value":"(123) 555-443"}, {"name":"comp= letion-date", "value":"11/30/2019"}] }' BASEURL/rest/blueprintmaker/1.0/cre= atepage
var data = =3D { =09source: { =09=09spaceKey: "sunset" =09}, =09destination: { =09=09spaceKey: "seaside", =09=09spaceName: "Seaside Project", =09=09spaceDescription: "Everything you need to know about the Seaside proj= ect." =09} }; $.ajax({=20 =09url: "/rest/blueprintmaker/1.0/copyspace",=20 =09data : JSON.stringify(data),=20 =09type: "PUT",=20 =09success: function(r) {console.log(r);}, error: function(x,s,t) {console.= log(x,s,t);},=20 =09dataType: "json" });
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/copys= pace
var data = =3D { =09source: { =09=09spaceKey: "sunset", =09=09pageTitle: "Sunset Information" =09}, =09destination: { =09=09spaceKey: "sunset", =09=09pageTitle: "Sunset Site Details" =09} }; $.ajax({=20 =09url: "/rest/blueprintmaker/1.0/copypage",=20 =09data : JSON.stringify(data),=20 =09type: "PUT",=20 =09success: function(r) {console.log(r);}, error: function(x,s,t) {console.= log(x,s,t);},=20 =09dataType: "json" });
curl -X= PUT -H "Authorization:Bearer YOURTOKEN" -H "Content-Type:application/json"= -d '{ "source":{"spaceKey":"sunset", "pageTitle":"Sunset Information"}, "d= estination": {"spaceKey":"sunset", "spaceName":"Sunset Site Details"} }' BA= SEURL/rest/blueprintmaker/1.0/copyspace
curl -X P= OST -H "Authorization:Bearer YOURTOKEN" -H "Content-Type: application/json"= -d '{"blueprint":{"name":"Project Page"}, "destination":{"pageTitle":"Proj= ect [[project-number]] - [[project-name]]"}, "fields":[{"name":"project-num= ber", "value":"23445"}, {"name":"project-name", "value":"Sunset Vista"}, {"= name":"location", "value":"432 West Elm"}, {"name":"site-manager-name", "va= lue":"Susan Hitcheson"}, {"name":"site-manager-phone", "value":"(123) 555-4= 433"}, {"name":"completion-date", "value":"12/31/2019"}]}' BASEURL/rest/blu= eprintmaker/1.0/updatepage/PAGEID