Query the region in which the account is hosted

You should be able to query which region the monday.com account is hosted in.

My account is hosted in EU (not US or AU).

App developers should be able to query which region the account is hosted in e.g.

query account {
  account {
    region
  }
}

This can be particularly useful for developers who are migrating to monday-code multi-region.

For integration its a bit obscure. First decode the JWT, then get the shortLivedToken and decode that (without verify) - its buried in the shortLivedToken as the rgn key.

For UI its in the context.

1 Like

@codyfrisch Wow. Just wow. Yes, this is for an automation. I would not have looked in the shortLivedToken.

1 Like

When I decode the shortLivedToken, I’m seeing data like so:

{
  "shortLived": true,
  "uid": 6073...,
  "actid": 2336...,
  "aid": 1014...,
  "aai": 249...,
  "rgn": "euc1",
  "exp": ...,
  "iat": ...
}

I’m guessing that region.substring(0,2) is what I need to get au, eu, or us.

yup, but my experience is that its only three options in total.

use1 (us east 1) euc1 (eu central 1) and i believe aus1. I don’t use this info so I havent paid attention to australia precisely.

1 Like

Of course, if you’re using multi region for monday code, it’s actually easy.

The region for your app will match the region for monday.com.

The region will be in the origin:

  • https://ab123-service-123456-ab12abcd.au.monday.app
  • https://ab123-service-123456-ab12abcd.eu.monday.app
  • https://ab123-service-123456-ab12abcd.us.monday.app

Simply check for the region:

const isRegionAu = location.origin.indexOf('.au.') >= 0;
const isRegionEu = location.origin.indexOf('.eu.') >= 0;
const isRegionUs = location.origin.indexOf('.us.') >= 0;

:upside_down_face: