Get the Instance Id

Last modified by Vincent Massol on 2026/06/18 10:59

Content

Steps

To get the Instance id, follow these steps:

  • From a REST endpoint:
    1. Call the /instanceId endpoint. For example:
      curl -H 'Accept: text/plain' http://<domain>/xwiki/rest/instanceId
    2. You'll get a unique id returned as plain text. For example:
      c3421c30-68be-46b4-add5-c28e24099e99
  • From Java:
    1. Get the InstanceIdManager:
      @Inject
      private Provider<InstanceIdManager> idManagerProvider;

      Note the usage of a Provider. This is required only when the component in which you're injecting the Instance Id Manager is loaded before the XWiki Store has been initialized.

    2. Get the id:

      The API is:

      public interface InstanceIdManager
      {
          /**
           * @return the Instance id or null if it isn't set
           */
          InstanceId getInstanceId();
      }
  • From a script in a wiki page.
    1. Get the id (example using Velocity):
      {{velocity}}
        $services.instance.getInstanceId()
      {{/velocity}}

Get Connected