Obtain the orgId or canonicalOrgId

Hi!

how can we get the orgId or canonicalOrgId where a forge app with module “jiraServiceManagement:assetsImportType” is installed ( using the cloudId or other parameter) during the app installation lifecycle or other momment ( f.e. import config )?

Thank you very much,

Luis

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"
      }
    ]
  },
[...]
}