Can we create a Confluence Page from a template via REST API?

Mahima Srivastav February 3, 2021

I'm trying to use the "Send web request" option in JIRA's Project Automation to generate a Confluence Page via REST API

I'm able to use the following code but I don't know how to force Confluence to use an existing template or a global template like "Design Review" when creating the new page.

 

{
"title": "ABCD",
"type": "page",
"space": { "key": "ABC" },
"status": "current",
"body": {"storage": {"value": "Sample Text", "representation": "storage"}}
}

1 answer

1 vote
sshannon September 11, 2021

You can do this with an undocumented rest api. 

 

First create a new page using the content api as a type of draft:

POST https://company.atlassian.net/wiki/rest/api/content

```

{
    "type""page",
    "status" : "draft",
    "title""test6",
   ...

```

Use the id retreived from this page to update the draft from a template:

PUT https://company.atlassian.net/wiki/rest/api/content/content_id/instance

```

{

{"content":{"id":"content_id","type":"page","title":"employee 1","status":"draft","space":{"key":"HR"},"version":{"number":1},"ancestors":[{"id":"content_id"}]},"contentBlueprintSpec":{"contentTemplateId":"template_id","context":{"employee_name":"a","employee_type":"a"}}}

}

```

Maximilian Seidler July 20, 2022

PUT https://company.atlassian.net/wiki/rest/api/content/content_id/instance

I tried that, but that endpoint does not exist anymore.

Hauke Hörhold
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 6, 2022

Why? This would have been useful...

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events