How to identify jira cloud instance or jira server(on prem) instance from url?

Can we identify whether it is a Jira cloud instance or a Jira server(on-prem) instance from the URL itself? What I am assuming is a URL that ends with atlassian.net (e.g. xxx.atlassian.net) is a Jira cloud instance. If the URL is not of the above type (e.g. jira.xxx.com) then I’m guessing that this is a Jira Server or Data Centre installation. Can someone please confirm it? Or Is there a way to know about the Jira instance(e.g Rest API)?

I would not draw any conclusions based on the base URL of an instance. Not only did Atlassian use different domains in the past for Cloud instances prior to settling with xxx.atlassian.net (with some legacy sites still using them), they are also in the process of enabling custom domains ([CLOUD-6999] Allow custom domains for Cloud apps - Create and track feature requests for Atlassian products.)

Perhaps you can explain a bit more about how you are receiving the requests, as the architectures for both Server and Cloud are vastly different.

Thanks for your quick response @remie. As per this thread, the accountId field is not returned in the response to the Rest API of the On-Prem version of Jira instance instead it returns the key field. That accountId field is returned by Jira Cloud Rest API only. The mentioned field is the primary key of response. And customer providing base_url, username, and password. So, if I can get to know about the type of Jira instance from the given credentials, then I can configure the dynamic primary key. So, is there any way by which I can identify the Jira instance?

If I understand your use case, you are allowing customers to fill in their Jira base URL and their credentials, and from there you are doing a request to the Jira REST API of the given base URL using the user credentials.

The problem that you are facing is that the Jira REST API of on-prem is returning a different result from Jira REST API of Cloud? So you want to know the host type in order to know how to parse the results, correct?

That’s correct @remie. I found Rest API which return deploymentType field. I think that’s should work here, right? Can you please confirm it?

@PrijenKhokhani,

Remie has already said what I would. Don’t rely on the URL pattern. And to elaborate on this point:

They are diverging.

To help your client know the difference, you can get Jira instance info with GET /rest/api/3/serverInfo. One thing to note is the example response seems to be wrong (the ServerInfo object specification is correct). On Cloud, there is always a deploymentType indicating Cloud. My instance returns:

{
	"baseUrl": "https://devpartisan.atlassian.net",
	"version": "1001.0.0-SNAPSHOT",
	"versionNumbers": [
		1001,
		0,
		0
	],
	"deploymentType": "Cloud",
	"buildNumber": 100194,
	"buildDate": "2022-03-02T06:13:42.000-0600",
	"serverTime": "2022-03-03T05:31:05.400-0600",
	"scmInfo": "7e40d9e2ca7e298c42d8139537082efe748037d3",
	"serverTitle": "JIRA",
	"defaultLocale": {
		"locale": "en_US"
	}
}

(If only this included my cloudId.)

Thanks a lot for your quick response @remie @ibuchanan. I got my answer.

@remie @ibuchanan Does Jira REST API(Get users from group) return a key field in the response for all versions of on-prem, or it is just for a specific version of on-prem? For other versions, does API response return the accountId field instead of the key field?

@PrijenKhokhani,

I don’t know “for all versions”, but key is still there for 8.22.2. I’m not aware of any on-prem versions that respond with accountId. As you have already observed, that’s a cloud concept.

Thanks, @ibuchanan. And one more query that for all cloud version API will return accountId? @remie Is there any document by which we can get an exact answer for “for all versions”?

@PrijenKhokhani,

How about “for all versions” under active support by Atlassian? It is certainly true for that scope.

To be clear about Jira Cloud, this is not just a “hosted version” of Jira Server/DC. There is only 1 version of the Jira Cloud REST API for all customers. That version returns accountId.