How to get macro id in dynamic content macro custom editor?

We have a sequence diagram macro for Confluence with a growing user base. Recently we are working on Export to PDF support.

One of the strength of our app is it doesn’t send user data outside of Confluence. We want to maintain that. To support PDF rendering, we are thinking of generating image attachment when user saves macro content. The attachment needs to be named with macro id, so that exporting to PDF can use it for static content.

After exploring the documentation we can’t find how to get macro id in a dynamic content macro. Can someone advise on this?

1 Like

I know this is old, but I just found this as a first result when googling “confluence cloud get macro id” so I thought I’d just leave this here:

AP.context.getContext(function(context) {

An alternative would be to pass the into your URL in your descriptor:

"dynamicContentMacros": [
          "url": "/your-macro?macroId={}",

The connect API returns undefined for context.confluence in the editor. Looks like getContext() only returns {license: {active: true}}.

The url parameter is also empty on the editor page.

"dynamicContentMacros": [
          "url": "...",
          "editor": {
              "url": "/your-editor?macroId={}",

Am I missing something?

That indeed is the case. Custom editor seems pretty useless without an option to get macro id.