Markdown docs
Markdown written by AI agents and scripts
AI agents and scripts can publish Markdown too. The macro needs only the Markdown text — no rendering, no extra data.
AI agents that edit Confluence pages — for example Claude, Rovo or ChatGPT through Atlassian’s MCP server, or scripts using the Confluence REST API — can add Markdown macros. A macro’s only required setting is the Markdown itself. The app renders it when the page is viewed, exported to PDF or Word, or opened in the editor, and Confluence search finds its text.
Rules for agents
- Read and write the page as HTML (or ADF), not Markdown. Confluence leaves app elements out of its Markdown format, for every app. An agent that reads a page as Markdown and writes it back deletes the macros. If that happens, restore the previous version from the page history.
- Insert the Markdown macro. Markdown pasted into the page body as plain text stays plain text: the app never rewrites your pages.
- Copy the snippet exactly, including the long key. Only change the Markdown.
- Use real line breaks. In JSON, a line break is
\n. Don’t escape it twice (\\n). - End the Markdown with a line break. Then search also finds the last word.
Snippet: HTML
Use this with Atlassian’s MCP server and other tools that write Confluence pages as HTML. The Markdown sits in JSON inside data-parameters, so line breaks are \n, quotes are \" and backslashes are doubled.
<div data-type="extension"
data-extension-type="com.atlassian.ecosystem"
data-extension-key="fcfb9c83-050f-46c7-ad86-3b3f5e54d11a/0e8e53fc-a72e-4509-a786-26ffa3c249cd/static/markdown"
data-layout="default"
data-parameters='{"layout":"extension","guestParams":{"markdown":"# Release notes\n\nThe **new** feature is live.\n"},"forgeEnvironment":"PRODUCTION","extensionId":"ari:cloud:ecosystem::extension/fcfb9c83-050f-46c7-ad86-3b3f5e54d11a/0e8e53fc-a72e-4509-a786-26ffa3c249cd/static/markdown","extensionTitle":"Markdown"}'>Markdown</div>
Snippet: ADF (REST API)
For the Confluence REST API with the atlas_doc_format body (POST /wiki/api/v2/pages or PUT /wiki/api/v2/pages/{id}):
{
"type": "extension",
"attrs": {
"extensionType": "com.atlassian.ecosystem",
"extensionKey": "fcfb9c83-050f-46c7-ad86-3b3f5e54d11a/0e8e53fc-a72e-4509-a786-26ffa3c249cd/static/markdown",
"layout": "default",
"parameters": {
"layout": "extension",
"guestParams": { "markdown": "# Release notes\n\nThe **new** feature is live.\n" },
"forgeEnvironment": "PRODUCTION",
"extensionId": "ari:cloud:ecosystem::extension/fcfb9c83-050f-46c7-ad86-3b3f5e54d11a/0e8e53fc-a72e-4509-a786-26ffa3c249cd/static/markdown",
"extensionTitle": "Markdown"
}
}
}
Optional settings
Add these next to markdown in guestParams. Anything left out uses the default.
| Setting | Values | Default |
|---|---|---|
source | body — show markdown; attachment — show an attached .md file | body |
attachmentName | File name of the .md attachment, with source: attachment | — |
attachmentPageId | ID of the page that holds the file | the current page |
Updating a macro
Change only guestParams.markdown of the existing macro and keep everything else as it is. If the macro also has a diagrams setting, remove it: it holds the export pictures of the old Mermaid diagrams, and the editor draws new ones the next time someone saves the macro.
Instructions to give your agent
Paste this into your agent’s instructions, or into a page the agent reads:
When you publish Markdown on Confluence pages, use the Markdown app's macro.
Read and update pages as HTML, never as Markdown: Markdown drops the macros.
Macro: <div data-type="extension" data-extension-type="com.atlassian.ecosystem" data-extension-key="fcfb9c83-050f-46c7-ad86-3b3f5e54d11a/0e8e53fc-a72e-4509-a786-26ffa3c249cd/static/markdown" data-layout="default" data-parameters='{"layout":"extension","guestParams":{"markdown":"MARKDOWN"},"forgeEnvironment":"PRODUCTION","extensionId":"ari:cloud:ecosystem::extension/fcfb9c83-050f-46c7-ad86-3b3f5e54d11a/0e8e53fc-a72e-4509-a786-26ffa3c249cd/static/markdown","extensionTitle":"Markdown"}'>Markdown</div>
Replace MARKDOWN with the Markdown, escaped for JSON (line breaks as \n, quotes as \", backslashes doubled), ending with \n.
One macro holds up to 1,000,000 characters; split longer documents across several macros.
Reading Markdown
In HTML, the Markdown is in the macro’s data-parameters, under guestParams.markdown. In ADF it’s attrs.parameters.guestParams.markdown. Agents that read pages as Markdown don’t see the macro at all — see rule 1.