How to distinguish between Jira Cloud and Jira Server using REST API?

I’m working on a project that needs to fetch Jira fields through the REST API. I’ve noticed that the responses from Jira Cloud and Jira Server (on-premises) are slightly different. The cloud version includes a “key” field in the response, while the server version doesn’t.

I need a reliable way to tell if I’m dealing with a cloud or server instance. Since I’m making various API calls (not just for fields, but also for creating and fetching issues), I can’t rely on checking for the “key” field every time.

Here’s a simplified example of what I’m seeing:

// Cloud response
[
  {
    "id": "taskType",
    "name": "Task Type",
    "key": "taskType",
    "custom": false
  }
]

// Server response
[
  {
    "id": "taskType",
    "name": "Task Type",
    "custom": false
  }
]

Does anyone know if there’s a specific API endpoint or method I can use to determine whether I’m interacting with Jira Cloud or Jira Server? Any help would be appreciated!

Having worked extensively with Jira integrations, I suggest an alternative method to differentiate between Cloud and Server instances. You can make a GET request to the ‘/rest/api/2/myself’ endpoint. This endpoint returns user information where the structure of the response can help you determine the instance type.

In Jira Cloud, the response includes an ‘accountId’ field, whereas Server instances usually return a ‘name’ field for the user. Additionally, the ‘self’ URL in the response can provide clues based on its pattern. This method has consistently provided clarity in distinguishing between the two environments.

I faced a similar challenge when integrating Jira with our company’s internal tools. From my experience, the most reliable way to distinguish between Jira Cloud and Server is by making a call to the ‘/serverInfo’ endpoint. This endpoint is available in both versions and provides crucial information about the Jira instance.

For Jira Cloud, you’ll see a ‘deploymentType’ field with the value ‘Cloud’. Server instances won’t have this field. Additionally, the ‘version’ field in the response can give you more insights. Cloud versions typically have a different versioning scheme compared to Server.

Here’s a quick example of how you might use this:

GET /rest/api/2/serverInfo

This approach has worked consistently for me across different Jira versions and API calls. It’s a good practice to make this check once at the beginning of your integration and then store the result for future use in your application logic.

hey there! i’ve dealt with this before. one easy way is to check the base URL of ur instance. jira cloud usually has a URL like ‘yourcompany.atlassian.net’, while server ones are often like ‘jira.yourcompany.com’. just parse the URL in ur API calls and you’ll know which is which. hope this helps!