How to retrieve the actual Jira instance I am in?

Perhaps it is the easiest thing to do but I stumbled into this. Looked inside context, issue data, UI Kit hooks, Javascript API and came empty-handed.

I can get some Ids but I really need the domain like there.

Maybe there is a way to access the current URL?

1 Like

Hello @RichardVencu.

You can get the instance URL from the context using “xdm_e” as stated in Context guide - Context parameters ( .

Also, you can get the URL/URI from the HTTP request itself inside the controller of the framework you use (e.g. Connect for Express or Connect for Spring ) and pass it to the UI model of the templating language you use.

Hope this can help you.

This is a forge app, I don’t think the xdm_e query string parameter is available given that it does not run in an iframe (like Connect)

We asked about this in the decommissioned Forge Slack channel and got advise from the Forge team how to deduce the site information, though it turned out to be only applicable for Jira and not Confluence at the time (right now you can still apply the Jira approach on Confluence because Forge is not enabled for Confluence only sites).

Unfortunately I’ve misplaced my notes and cannot recall the details right now :man_facepalming: - will reply once more in case I find/recall those.

I do recall our workaround though, which is based on Tim Pettersen’s clever answer to Status URL for monitoring?:

There isn’t a formal status API that I’m aware of, but the AppLinks Manifest end-point is a good URL you can hit for most of our products (JIRA, Confluence, Stash, Bamboo, FishEye and Crucible). If it returns a 200, your server is probably in good shape.

It does not require authentication and is available at:


in all products.




This still seems to work fine on Atlassian Cloud, though you need to parse the response XML, see e.g.:


<name>Jira - Utoolity Support</name>


<name>Confluence - Utoolity Support</name>

Great! Thank you, this works well:

getInstance = async () => {
    const response = await api
    const results = await response.text();
    const jurl = /\<url\>(.*)\<\/url\>/;
    return jurl.exec(results)[1];

I can jump in on that - the Jira only, slightly more explicit approach uses the baseUrl entry from /rest/api/3/serverInfo, e.g.:

export const getEnvironmentBaseUrl = async () => {
  let result;
  // NOTE/KLUDGE: We have no proper approach for Confluence so far, but can currently rely on a Confluence instance always having a
  // corresponding Jira instance, hence using the respective Jira pproach only for starters:
  //const hostProduct = getHostProduct();
  const hostProduct = "jira";
  if (hostProduct === "jira") {
    result = await api
    const serverInfo = await result.json();
    result = serverInfo.baseUrl;
  // TODO: Add Confluence specific version, once available
  return result;

(left the preparation and notes on the Confluence topic, easy to shorten for a Jira only situation, of course)


Hey @RichardVencu,

Would you mind describing a little about what you need this for? That way I can take it back to my team. We are still working on Forge context so any input is valuable :slight_smile:

Yes. I want to send to a backend system information about work logs. But the same organization might use several instances of jira cloud so I want to identify the remote worklog (i.e. Jira worklog) by: instance, issue, so I can send back API requests to alter these work logs if the backend system finds incompatibilities with org rules.

I assume that this system would be your own external API? Could you use another identifier like installationContext for that? I’m curious to understand why it needs to be the site URL itself given that it is not required for calling the APIs from Forge?

Because I needed to go async at my external app, I have to return some confirmation after I finish processing the job. I am returning this via API directly to Jira cloud (skipping the Forge app completely) from my own external app, hence I need the full URL.


Another as of yet undocumented and thus possibly unsupported option:

I recently noticed that the GraphQL Gateway provides a tenantContexts GraphQL query which can be used to infer the site URL from the cloudId and vice versa, and it works for both Jira and Confluence:

A Jira or Confluence cloud instance, such as has a backing cloud ID such as 0ee6b491-5425-4f19-a71e-2486784ad694

This field allows you to look up the cloud IDs or host names of tenanted applications such as Jira or Confluence.

You MUST provide a list of cloud IDs or a list of host names to look up but not both otherwise an error will be returned

Here’s an example query:

query tenantContexts($cloudIds: [ID!]) {
  tenantContexts(cloudIds: $cloudIds) {

Providing a cloud ID from the useProductContext() hook yields e.g.:

  "data": {
    "tenantContexts": [
        "cloudId": "2ef567f6-17c6-421f-a6cc-2fb075be8be6",
        "hostName": ""

@danielwinterw - I realize that the GraphQL API is not yet officially supported, but given Forge uses it heavily and the product fetch API just gaining a (so far undocumented) requestGraph() method, can you maybe sneak peek indicate whether this might be a stable approach already? :slight_smile:


This is actually a pretty awesome find. Using a graphql client like “graphql-request” it is possible to fetch an instances hostName by providing its cloudId which is available via forgeContext.

import {request, gql} from 'graphql-request';

const query = gql`
            query hostNameForCloudId {
                tenantContexts(cloudIds: ["${forgeContext.cloudId}"]) {
const {tenantContexts} = await request("", query);
// tenantContexts contains cloudId and hostName
1 Like