How to identify the original "Epic" type via the REST API

James Sear June 24, 2019

I was wondering if anyone knows whether it's possible to identify the original special "Epic" issue type via the REST API.

I've found that it's possible to rename Epic to something else, meaning that via the API, I can't identify which issue type is the original "Epic" type.

I have tried the following APIs:

  • Get all issue types (/rest/api/3/issuetype)
  • Get all projects (/rest/api/3/project/search)
  • Get issue type (/rest/api/3/issuetype/{id})

Each provides the same issue schema back:

{
"self": "https://api.atlassian.com/ex/jira/262560a0-5ce0-4e72-990e-62464cbb26e6/rest/api/3/issuetype/10000",
"id": "10000",
"description": "A big user story that needs to be broken down. Created by Jira Software - do not edit or delete.",
"iconUrl": "https://jpsear1.atlassian.net/images/icons/issuetypes/epic.svg",
"name": "Renamed Epic",
"subtask": false
}

 

Unfortunately, there is no where to tell this is a core "Epic" type. Any ideas?

2 answers

2 votes
Thomas Eriksson January 28, 2020

You can query fields (/rest/api/3/field) and look for fields with

schema.custom = "com.pyxis.greenhopper.jira:gh-epic-label"

Grab the field id and query its contexts (/rest/api/3/field/<fieldId>/contexts) and look for

associatedIssueTypes
James Sear January 29, 2020

Hey Thomas, 

Thanks for the reply, I will give this a go as soon as I get a chance and report back!

James

Riz July 5, 2021

Hello Thomas,

After getting frustrated searching for a way to do this and looking at deprecated APIs for hierarchy; am quite glad I found your answer. This method is a lifesaver. Although, I must state that https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-fields/#api-rest-api-3-field-fieldid-contexts-get - the getContexts method has been marked as deprecated. :P 

/riz

Riz July 5, 2021

Ok, so this does not work on Next-gen projects. The getContext API always returns 10000 issue as epic but my project has it as 10002. 

Evgen Kyselgov October 12, 2023

As I know Greenhopper API is depricated. Agile API (https://developer.atlassian.com/cloud/jira/software/rest/intro/#introduction) is introduced instead, but i don't see method from this API that can answer on the question.

0 votes
Petter Gonçalves
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 25, 2019

Hello James,

Indeed, I was not able to find any information returned in the REST API to confirm that an issue type is an Epic, however, you can use the Epic Name field to identify which issues are "real" Epics.

This would be the query to return all epic issues:

https://pettertest7.atlassian.net/rest/api/3/search?jql=%22Epic%20Name%22+is+not+empty

Additionally, you can check both links below for more details about REST APIs and search examples:

JIRA REST API Examples

JIRA REST API Reference

If this query does not help, please give us more information about your final goal so we can give you further options to achieve your need. :)

James Sear June 26, 2019

Thanks for the reply @Petter Gonçalves

Unfortunately, searching for issues filtering for the "Epic Name" field is problematic, as Jira Cloud next-gen projects don't use this and there is the possibility that the project does not contain any epic type issues yet — in which case the query will return 0 issues.

As far as I can tell, this is not possible :(

Petter Gonçalves
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 26, 2019

Hello James,

I agree with you that the mentioned solution would not work if you have:

- Renamed Epic + The Epic is from a next-gen project

OR 

- Renamed Epic + There is no Classic Epic issues in the instance

It's indeed a limitation of JIRA REST API. You must collect in the UI the original EPIC ID to properly return the "real Epic" through REST API, independent of its name or project type.

That been said, I would really appreciate if you could provide us more details about what kind of limitations it is causing in your scenario, so we can talk with our internal teams and further investigate if we can provide any options to meet your needs.

James Sear June 26, 2019

Hey @Petter Gonçalves

I am integrating an external tool with a user's Jira instance. I am giving the user the choice of how to map certain issue types. Therefore, I need to be able to identify the epic issue type. Obviously if this has been renamed, this is going to be inconsistent.

Just a quick tweak in the REST API response for issue types would be the perfect solution :)

Considering there is currently:

  "subtask": false

Then, you could go as simple as:

  "epic": false

Of course, I don't know the internal mechanisms and potential complications that could be lurking!

Like Evgen Kyselgov likes this

Suggest an answer

Log in or Sign up to answer