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:
- Call the /instanceId endpoint. For example:
curl -H 'Accept: text/plain' http://<domain>/xwiki/rest/instanceId - You'll get a unique id returned as plain text. For example:
c3421c30-68be-46b4-add5-c28e24099e99
- Call the /instanceId endpoint. For example:
- From Java:
- 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.
- Get the id:
The API is:
public interface InstanceIdManager { /** * @return the Instance id or null if it isn't set */ InstanceId getInstanceId(); }
- Get the InstanceIdManager:
- From a script in a wiki page.
- Get the id (example using Velocity):
{{velocity}} $services.instance.getInstanceId() {{/velocity}}
- Get the id (example using Velocity):