Obtain the orgId or canonicalOrgId

You can often use the Atlassian platform GraphQL API to get this kind of data, e.g. the tenantContext query provides the orgId (you can use requestGraph() at runtime):

Query

query getTenantContextsByCloudId($cloudIds: [ID!]) {
  tenantContexts(cloudIds: $cloudIds) {
    cloudId
    cloudUrl
    hostName
    orgId
  }
}

Variables

{
  "cloudIds": [
    "2ef567f6-17c6-421f-a6cc-2fb075be8be6"
  ]
}

Response

{
  "data": {
    "tenantContexts": [
      {
        "cloudId": "2ef567f6-17c6-421f-a6cc-2fb075be8be6",
        "cloudUrl": "https://utoolity.atlassian.net",
        "hostName": "utoolity.atlassian.net",
        "orgId": "0e136cb4-07f7-483e-a77a-519f8f3cf971"
      }
    ]
  },
[...]
}
3 Likes