Update banner for multiple Confluence spaces programmatically

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

To update the space wide banner for multiple Confluence Spaces programmatically.

Solution

This KB contains customisations/scripts that are outside the scope of Atlassian Support. We recommend testing the script in a non-production environment and running it in a controlled manner for the specific number of Spaces for whom the banner needs to be updated.

  • We can update the banner for a Confluence Space following the steps mentioned in How to add a space-wide banner.

  • However, If the banner needs to be updated for multiple spaces at once, rather than updating them for each space individually, the following shell script can be used which can be run on a Linux/Unix server.

  • Save the following content into a shell script (e.g., bannerupdate.sh) on your Confluence Linux/Unix server, and ensure the appropriate permissions are set for execution.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 CONFLUENCE_BASE_URL=https://CONFLUENCE_BASE_URL ADMIN_USERNAME=ADMIN_USERNAME ADMIN_PASSWORD=ADMIN_PASSWORD NEW_SPACE_KEY=("KEY1" "KEY2") NEW_SPACE_HEADER_PANEL='{panel:borderStyle=dashed|borderColor=blue|titleBGColor=#00a400|titleColor=white|bgColor=#72bc72}This is a Test Banner{panel}' for SPACE_KEY in "${NEW_SPACE_KEY[@]}"; do # Adjust the Header curl -v -o /dev/null -X POST -u ${ADMIN_USERNAME}:${ADMIN_PASSWORD} \ ${CONFLUENCE_BASE_URL}'/spaces/docustompagecontent.action' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -H 'X-Atlassian-Token: no-check' \ -d 'sidebarText=' \ --data-urlencode headerText="${NEW_SPACE_HEADER_PANEL}" \ -d 'footerText=' \ -d 'key='${SPACE_KEY} \ -d 'confirm=Save' echo "Header updated for space: $SPACE_KEY" done

Note :

  • The CONFLUENCE_BASE_URL,ADMIN_USERNAME and ADMIN_PASSWORD needs to be updated accordingly for the environment in which Banner needs to be updated for the Spaces.

  • The list of space keys for which the banner needs to be updated should be provided in the NEW_SPACE_KEY variable, and the banner message to be applied should be specified in the NEW_SPACE_HEADER_PANEL variable.

Updated on March 13, 2025

Still need help?

The Atlassian Community is here for you.