Find the post-mortem assocaied with an incident via API
Asked by Wolfgang Kandek:

I would like to find the post-mortem associated with an incident via the API, but I cannot find the post-mortem reference in the the Incident itself.  

There is an incident in the post-mortem API, but there seems no also seems no way to list post-mortems.  

My purpose is to ensure that P1/P2 incidents have a post-mortem and that it follows out format and agreements (for example - a Jira ticket is needed for each Action item). The initial ideas was to list Incidents that are closed/resolved and see whether they have a post-mortem. If so get the post-mortem and review the content for format and ticket links. If not, create post-mortem in our format and notify the incident owner that a post-mortem skeleton had been created.


Answers:
author: Darryl Lee
body: Hi [@Wolfgang Kandek](/t5/user/viewprofilepage/user-id/5100956),

This is Darryl. I am here to help. ?

Understand that you would like to leverage Opsgenie Incident API to list out the Opsgenie Incidents which don't have a Postmortem yet.

#### The endpoint {#toc-hId-201868915}

```
https://api.opsgenie.com/v1/incidents?query=postmortemStatus%3Ano-postmortem
```

#### Reference {#toc-hId--1605585548}

We recommend tailoring the \`query\` inline parameter in the URL when making the API request.

The List Incident API documentation is -\> <https://docs.opsgenie.com/docs/incident-api#list-incidents>

The Search Syntax for Incidents documentation is a great reference for you to adjust your query -\> <https://support.atlassian.com/opsgenie/docs/search-syntax-for-incidents/>

Last, please encode the URL with the reference -\> <https://www.w3schools.com/tags/ref_urlencode.ASP>

*** ** * ** ***

Hope this helps.

Kind regards,   
Darryl Lee  
Support Engineer, Atlassian

comments: author: Wolfgang Kandek
body: Daryl, that helps with one of my issues, i.e. an incident that does not have a post-mortem.  

But I would also like to access the incidents that have a post-mortem and verify the format used:  

- Sections that we have as mandatory  
- Jira tickets for action items  
- etc


author: John M
body: Hi [@Wolfgang Kandek](/t5/user/viewprofilepage/user-id/5100956),

You can use the following query parameters for postmortemStatus:

* no-postmortem
* published
* in-review
* draft

If you want to only include incidents that have a published postmortem, you can use the following endpoint with 'published' as the value for the 'postmortemStatus' query parameter:  
'<https://api.opsgenie.com/v1/incidents?query=postmortemStatus%3Apublished>'


author: Wolfgang Kandek
body: From those queries that return incidents how do I find the associated post-mortem?


author: John M
body: [@Wolfgang Kandek](/t5/user/viewprofilepage/user-id/5100956) You would need to use the Get Postmortem Request API, using the incident ID returned from the List Incidents endpoint.

<https://docs.opsgenie.com/docs/postmortem-api#get-postmortem-request>


author: Wolfgang Kandek
body: John, that requires the postmortemid? Where do I get it from?


author: John M
body: It looks like right now the only way to get the postmortemid is to create a postmortem via the API (in which case it will return the id) or in the UI, go to Analytics \>\> postmortem reports (id is in the URL)

I have found that there is a feature request to add this functionality to the API:

<https://jira.atlassian.com/browse/OPSGENIE-41>


author: Jazz Tong
body: hi,

We have a similar use case as well, what is the workaround at this moment, Is the UI seen as able to provide the association, and what is the equivalent to API?


Tags: api

cloud

incident

post-mortem