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?

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={}",
1 Like