Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create a new Macro using REST API

admin March 10, 2023

I want to create a Macro and upload it to specific page (already created) without deleting the existing content, USING Rest API. { Contains macro name and body } 

I want to know what API endpoint I should hit and what will be my payload !

2 answers

0 votes
Eric Yablonowitz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 13, 2025

With some guidance from WeWeave support, I was able to get this to work with curl and the WeWeave Mermaid Plugin.

Example Mermaid diagram source:

graph TD;
A-->B;
A-->C;
B-->D;
C-->D;

 

Example curl:

% curl --request PUT \
--url "https://$CONFLUENCE_HOSTNAME/wiki/rest/api/content/$CONFLUENCE_PAGEID" \
--user "$CONFLUENCE_USERNAME:$CONFLUENCE_API_TOKEN" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data @- <<'EOF'
{
"version": {
"number": 2
},
"title": "Mermaid Test",
"type": "page",
"body": {
"storage": {
"value": "<p>This is a test Mermaid diagram generated via api call.</p><ac:structured-macro ac:name=\"confluence-mermaid-macro\" ac:schema-version=\"1\" data-layout=\"default\" ac:local-id=\"00eae132-afb8-4cd7-94c9-3572398c2531\" ac:macro-id=\"7c6bf8b2-c833-46ae-80f8-3c504a6708c6\"><ac:parameter ac:name=\"searchText\">graph TD</ac:parameter><ac:parameter ac:name=\"download\">true</ac:parameter><ac:parameter ac:name=\"fullscreen\">true</ac:parameter><ac:parameter ac:name=\"panZoom\">true</ac:parameter><ac:parameter ac:name=\"zoom\" /><ac:parameter ac:name=\"theme\">default</ac:parameter><ac:parameter ac:name=\"disableUseMaxWidth\" /><ac:parameter ac:name=\"copy\">true</ac:parameter><ac:parameter ac:name=\"exportWidth\" /><ac:parameter ac:name=\"height\" /><ac:plain-text-body><![CDATA[graph TD;A-->B;A-->C;B-->D;C-->D;]]></ac:plain-text-body></ac:structured-macro",
"representation": "storage"
}
}
}
EOF

 

0 votes
Alex Koxaras -Relational-
Community Champion
March 10, 2023
admin March 12, 2023

Hello Alex, 

Thanks for the reply.

I guess I was not able to put my question well.

  • I am already using one application "Mermaid Diagram for confluence". (We can create diagram using code)
  • I have created multiple diagrams. (Using Mermiad Editor) 
  • I want to append all the diagram to the specific pages of specific spaces in Confluence Cloud. (Using above application)
  • But problem is, I want to do all these with REST API. As it will take more time manually.

Can you please explain the format of  API and the Payload I need to use for respective API?

Thanks !

Alex Koxaras -Relational-
Community Champion
March 13, 2023

Hi @admin 

Take a look at this http request https://developer.atlassian.com/cloud/confluence/rest/v2/api-group-custom-content/#api-custom-content-id-put

You will find all the details about the payload in many formats like cURL, node.js, java, python and php.

samods
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 30, 2025

@admin Were you able to add the mermaid diagram using REST API ? 

 

@Alex Koxaras -Relational- : How can we identify what is the custom content type or Id for mermaid diagram confluence? 

Suggest an answer

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

Atlassian Community Events