Cacheable macro parameters

I’m trying to make a dynamic macro to be cacheable.
How do I get the macro parameters?

Before I was getting the macro parameters from the url, but now I can’t. The only way I found is to use the REST call ‘Get macro body by macro ID’
Using this approach creates an error in preview mode of the macro (in view mode everything works fine), because macroId parameter is not defined.


Hi @arosati,

Thanks for posting this in the community.

I’m not sure of Confluence, but I’ll tap the right person here.

AFAIK, for cacheable app iframes, you may get the context parameters thru:

That is:

AP.context.getContext(function(context) {
  alert('The current project key is ' + context.jira.project.key);

You may find more information here: Building fast loading apps with new Connect APIs, which features cacheable iframes during Atlas Camp.

Anne Calantog


hi @acalantog,

Context parameters don’t contain macro parameters. From the context I’m able to get, content.version and the

const pageId =;
const pageVersion = context.confluence.content.version;
const macroId =;

With these variables then I’m able to call ‘Get macro body by macro ID’ REST API to get macro parameters.
This approach works in view mode, but it is causing an error in preview mode in the macro editor because the variable is not defined.


@arosati, we identified this as a gap a while back. We initially intend to support the existing API AP.confluence.getMacroData() in view mode (ACJS-1025), not only in edit mode. I will make a note on that ticket to make sure we support preview mode as well.

hi @epehrson,

so for now there are no work arounds to make the macro working in preview mode?


@arosati, I don’t think so. Not even after saving the page does the macro ID seem to be present in the context when in preview mode.

@arosati Can you share the exact error that you get when you try for the Preview mode?

@arosati Can you also confirm if you are talking about macro previews or the entire page(or content) preview?

@arosati I think AP.confluence.getMacroData only works with custom macro editor. For default editor you can get parameters from URL, for example:

                "key": "macro",
                "name": {
                    "value": "macro"
                "url": "/render?parameter={parameter_key}",
                "bodyType": "rich-text",
                "outputType": "block",
                "parameters": [
                        "identifier": "parameter_key",
                        "name": {
                            "value": "value"
                        "type": "string"


@akashyap, I see that is not working in both cases.
In a single macro preview I see the error:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>404</status-code><message>null for uri:</message></status>

As you can see from the error the macro id is not specified, because I think the macro id is still not available.

In the new editor (from a blogpost) when I load the blogpost in edit more I see this error:

{"statusCode":404,"data":{"authorized":false,"valid":true,"errors":[],"successful":false},"message":"No macro found on content id : ContentId{id=249266188} with version: 1 and macroId: 2310e8a2-91d9-4c17-862d-162df7c2122f"}

Here the macro id is specified, but still getting an error.

@rading, I cannot use the parameters from the URL because I’m using a cacheable macro.

Hi @epehrson ,

Is it still in the plans to support cachable iframes for macros? They say they support it but if macros can’t access their macro parameters, usecases are extremely limited.

Our usecase is for customers with lists of requirements: They annotate each item, which means they could have hundreds of requirements per page. If our macros are cached by the browser, displaying them is instant. If not, the browser limits to 6 concurrent requests per page, so it takes a lot of time to display many macros.

Thank you very much,


Hey Adrien,

I had the chance to talk to someone from the Confluence Cloud Ecosystem at the Atlassian Summit, because we have the same issue. He told me that accessing the macro properties will be available soon.


1 Like

This really needs to be escalated and documentation updated to reflect that this is not ready for use by macros at all.

getMacroData() doesn’t work in view, so you need to do workaround hack of getContext() and then get /rest/api/content/{id}/history/{version}/macro/id/{macroId}.

That all works across view, preview and custom editor. But when you first save/insert a new macro and run saveMacro(), your subsequent call to the workaround hack fails with the same “No macro found on content id” 404 posted above.

Back to URL params I guess.

Even though there’s been no update on, AP.confluence.getMacroData() seems to work in view mode for me now.