How to add an attachment link in a page using CLI

This article explains how to insert an attachment link in a page using Confluence Command Line Interface.


Use the modifyPage or storePage actions with the markdown parameter to add an attachment link, or, use the addAttachment action add an attachment to the Confluence page.

  • addAttachment action: 

    --action addAttachment --space "SPACEKEY" --title "PAGETITLE" --file "./src/itest/confluence/resources/testing.mp3"
  • modifyPage action: modifyPage action is used to modify the current page content by adding content before(--content) or after current content(--content2) and applying findReplace logic (based on page content XHTML source).

    --action modifyPage --space "SPACEKEY" --title "PAGETITLE" --content "[ABC](" --noConvert --markdown
  • storePage action: storePage action creates/updates a page. If the page with the mentioned title is not found then it creates a new page with the mentioned information given in the CLI command. If the page exists then it restores the page with the new information/content as per the CLI command given.

    --action storePage --space "SPACEKEY" --title "PAGETITLE" --content "[ABC](" --noConvert --markdown

In the above examples:

  • SPACEKEY is the space key and PAGETITLE is the title of the page. 
  • ./src/itest/confluence/resources/testing.mp3 is the path of the file to be attached to the page. You must change this file and path to reflect your required attachments.
  • Replace the URL with the Confluence attachment link (the URL that is displayed when you select the required attachment in Confluence attachments).
  • Replace ABC with the text that you want to display on the Confluence page for the attachment URL.
  • The output of the modifyPage and storePage examples is displayed as: