Script Console

The script console is a place to run scripts. Using the script console, you can copy and paste or write a script to run in Confluence. You can experiment with the Cloud REST APIs, or you can run one-time scripts. Code run from the script console can make requests back to Confluence using either the ScriptRunner add-on user or the current user.

You find a script editor, similar to the the script console, anywhere you choose to use a custom script option (for example, when adding a listener or scheduled job).

The script console is useful for testing scripts or performing operations that you only want to do once. So if you want a list of all the spaces on your instance and some details about them, you can run a script for that. Or if you want to delete all spaces that were created by a certain person, you can do that. You can also run maintenance scripts that modify something on your instance.

You can perform a lot of these same tasks in different parts of ScriptRunner.

Like all coding fields in ScriptRunner for Confluence Cloud, the script console uses the Monaco editor. Learn more in the Code Editor documentation. The editor has autocomplete for the following code: 

  • Groovy
  • Atlassian REST API
  • Automatically available variables

You can see autocomplete in the following screenshot: 

Use the Script Console 

To use the script console, follow these steps: 

  1. Navigate to Confluence Administration by selecting the Cog button at the top right of the screen. 


  2. Select Script Console, under ScriptRunner.


  3. Enter the script you want.

    Tips for using the Script Console

    • Some example scripts can be found below the editor box (click one to auto-fill), but you can also write and run your own.
    • Use the Expand button () to have more room for scripting. 
    • To exit the full screen, press F11 or Esc twice when the cursor is in the editor. 
  4. Choose the user you want to run the script for Run As

    Script console can make requests back to Confluence using either the ScriptRunner add-on user or the user that performed the action to cause the event to be fired. Therefore, you can choose whether the creator of a specific action is the current user or a generic ScriptRunner add-on user using the Run As field. 

  5. Select Run.

Built-in examples

ScriptRunner has a number of built-in example scripts that you can use or update to fit your needs. You can select the example under the Script field.

Create Page In Space

Create Page in Space creates a page with a title in a space that you pick. 

Create Space

Create Space creates a space with a space name, key and a description. This can be used rapidly create a number of spaces for different teams during your Confluence setup.

Delete Space

Delete Space deletes a space with a certain key. This could be used to rapidly delete multiple old irrelevant spaces, or to periodically delete a space that has been used for archiving.

Get All Spaces

Get All Spaces fetches and displays all spaces from an instance. This can be used as a starting point for an automation. An example of why you would want to use Get Spaces is if you want to delete all spaces that are older than a specific date.

Get Template Blueprints

Get Template Blueprints fetches a template blueprint so that you can automate off it. Combined with the Create Page example, you can create a page with a specific template.

On this page