Cannot modify incident details on incident update

I am developing an application that creates PagerDuty incidents, and important information is put into the “details” of the body of the incident. This when I send this information in a request using POST to initially create the incident, everything works fine. But when I modify the information and send it in a request using PUT, the details are not updated. Comparing the API docs for these two endpoints, it appears the latter endpoint for updating an incident does not support/expect the body/details field.

Is there a technical reason why we can not update incident details after creating them? If not, it would be great if this endpoint could be updated to support this use case, especially since my project really needs this.

Hello @feldman.michael!

When an incident is created, those body details get added to the log entry for the incident. When using the API, they are found under the first_trigger_log_entry under channel.details. You just need to include first_trigger_log_entry in your request.

Example Request

curl --request GET \ 
--url 'https://api.pagerduty.com/incidents/R2ACS5PFLPB6CCXFLA8D44JBSV?include%5B%5D=first_trigger_log_entries' \
--header 'Accept: application/json' \
--header 'Authorization: Token token=YOUR_TOKEN' \
--header 'Content-Type: application/json'

Example Response

{
"incident": {
  "id": "PT4KHLK",
  "type": "incident",
  "summary": "[#1234] The server is on fire.",
  "self": "https://api.pagerduty.com/incidents/PT4KHLK",
  "html_url": "https://subdomain.pagerduty.com/incidents/PT4KHLK",
  "incident_number": 1234,
  "title": "The server is on fire.",
  "created_at": "2015-10-06T21:30:42Z",
  ...
  "first_trigger_log_entry": {
    "id": "Q02JTSNZWHSEKV",
    "type": "trigger_log_entry_reference",
    "summary": "Triggered through the API",
    "self": "https://api.pagerduty.com/log_entries/Q02JTSNZWHSEKV?incident_id=PT4KHLK",
    "html_url": "https://subdomain.pagerduty.com/incidents/PT4KHLK/log_entries/Q02JTSNZWHSEKV"
    }
  }
}

To update this log entry you need to use the update log entry operation. This should do what you are looking for.

One other thing to consider for your workflow is to use the custom fields instead of the log entry. If you are trying to standardise on certain fields for all incidents across services it might make sense and they can be updated on the incident information directly.

Note: Custom fields is available with the Business and Digital Operations pricing plans.

I hope this helps!

Thanks for getting back to me. I will test this other endpoint out and see if it fits my needs. Sorry about the duplicate post btw. I wasn’t sure if this one posted the other day.

1 Like

Let’s say I have the following incident for example:
https://api.pagerduty.com/incidents/Q2485WTS1G0YUH

I can use the “Update incident” put request to update the title of the incident fine. I am trying to follow up with another request to the “Update log entry channel information” endpoint to update the incidents details using the following URI:
https://api.pagerduty.com/log_entries/Q2485WTS1G0YUH/channel

However, I receive a 404 error in my code:
404 Not Found from PUT https://api.pagerduty.com/log_entries/Q2485WTS1G0YUH/channel

I’m still trying to investigate this, but from the URI POV, does this look like correct usage?

When calling the log_entries endpoint you need to pass the id you got from first_trigger_log_entry. Not the incident Id. I believe that’s probably why you are getting the HTTP 404 error.

One thing to take into consideration though is that this log entry is the one that triggered the incident. If you update the log entry in different stages of the incident lifecycle you might induce the incident resolver into wrong assumptions. That’s one of the reasons why I mentioned using custom fields.

I don’t have all the details on you scenario so feel free to DM me if you need more concrete help.

@tiago.barbosa Thanks for that clarification. I just tried to DM you, but I am having issues. I am going to your profile and hitting “Send Message”, but it doesn’t open up a draft with you as the recipient. It just opens up the messenger and when I try to create a draft and select you as the recipient, your name does not come up. I do see a “Message Admins” button, but clicking that does nothing. I think if I had you added as a contact that might help get your name to pop up, but I don’t see how I am supposed to add you looking at your profile.

Also, I am having gripes with the API reference as I try to explore/test this new endpoint you mentioned. My plan was to try creating an incident (or fetch an existing one), retrieve it with the first_trigger_log_entries information, find an log id of a log entry from that response, and then test out the get/update endpoints on one of those log entries using the id. I am stuck at step 1 however. I am trying to use the get incident API with an incident I have created, Q2ZYZKF9MAMNCA, with the first_trigger_log_entry search query you mentioned. I guess I should note that this incident I’ve created is related to my organization, Garmin, at https://garmin.pagerduty.com/incidents/Q2ZYZKF9MAMNCA instead of https://api.pagerduty.com/incidents/Q2ZYZKF9MAMNCA. So I did not really expect it to work, and I got a “Incident not found error”.

So that got me thinking, is there a test incident we can use for the API reference or is there an easy way for me to create one either through the web UI or the API reference? I tried using the “Create Incident” endpoint in the API reference - the only info I needed to supply there was the email/“from” field. I supplied the email that I use to successfully create incidents under there Garmin domain. But I receive a 403 error in that case. Is there a test email I can use in that case?

Just to make sure we are on the same page, my goal here is to modify these details presented in the web UI:

@tiago.barbosa Are you able to assist with any of the issues above? The TLDR is that I am wondering - can you successfully create an incident using API reference and then use that incident to test out some of the other APIs you mentioned? Or is there an existing/sample incident that I can use to test out those APIs in the reference? In order to test them, I need an incident to work from.

I also shared more details on my use case and wanted to double check if what you suggested would actually work for what I’m trying to do.