How to use fetch with siteUrl for REST calls within a Forge App?

I’m building a Forge app that integrates with Teams.

There only appears to be a REST API available to create a Team (https://developer.atlassian.com/platform/teams/rest/v1/api-group-teams-public-api/#api-group-teams-public-api) - the GraphQL endpoint does not include a mutation for creating a team.

Unfortunately the only way to access the REST API from within an app (that I know of) is using the “siteUrl”, ie. “mycustomer.atlassian.net/gateway/api/v4/teams/…”

However in order to call this endpoint from within a Forge app, the remote must be specifically declared in the manifest.yaml file. But since the siteUrl is unknown until a customer installs the app, it cannot be declared in the manifest.

So if the siteUrl can’t be added to the manifest, and any REST endpoints must be declared in the manifest in order to be used by a Forge app, how do developers interact with these APIs? Note that .requestJira, .requestConfluence, etc are not applicable as they have no support for Teams.

One alternative is the GraphQL api which can be accessed using the .requestGraph method, however there are no mutations to create or update Teams via GraphQL, so the only option is to use the REST API.

Thanks for any suggestions you have!

One option I’ve considered is using a remote backend (https://developer.atlassian.com/platform/forge/remote/calling-from-function/) - because then I could specify one domain in the manifest, and send my REST calls there, however this would:

a) Decrease security by sending data to a non-atlassian domain
b) Only be used for the purpose of calling back in to Atlassian APIs
c) Basically be a recreation of Atlassian’s REST API in a separate service

So to create a Team, for example, you:

  • Define https://atlassianproxy.mydomain.com as the remote in the manifest.yaml
  • Call fetch('https://atlassianproxy.mydomain.com/createTeam'), with the siteUrl and API key that is needed for the current installation
  • The proxy calls back with fetch('https://siteUrl.atlassian.net/gateway/v4/teams/etc') to perform whatever action needs to be taken.

Clearly this is a pretty roundabout and unattractive workaround for what should be a direct call to the API from a forge app :frowning: so I’m not excited about pursuing this approach.