Create
Attaches an external resource to an incident.
You must provide a resource with resource_type and either external_id or url, but not both.
When providing a url, the server will create the attachment from that link for the given resource type if the integration is installed and the link is valid.
To attach an arbitrary link that isnβt backed by an integration, use the arbitrary_url resource type with a url, and optionally a title and emoji.
POST
/
v1
/
incident_attachments
Create
curl --request POST \
--url https://api.incident.io/v1/incident_attachments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"incident_id": "01FDAG4SAP5TYPT98WGR2N7W91",
"resource": {
"emoji": "rocket",
"external_id": "123",
"resource_type": "pager_duty_incident",
"title": "Impact tracking spreadsheet",
"url": "https://github.com/company/repo/pull/123"
}
}
'import requests
url = "https://api.incident.io/v1/incident_attachments"
payload = {
"incident_id": "01FDAG4SAP5TYPT98WGR2N7W91",
"resource": {
"emoji": "rocket",
"external_id": "123",
"resource_type": "pager_duty_incident",
"title": "Impact tracking spreadsheet",
"url": "https://github.com/company/repo/pull/123"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
incident_id: '01FDAG4SAP5TYPT98WGR2N7W91',
resource: {
emoji: 'rocket',
external_id: '123',
resource_type: 'pager_duty_incident',
title: 'Impact tracking spreadsheet',
url: 'https://github.com/company/repo/pull/123'
}
})
};
fetch('https://api.incident.io/v1/incident_attachments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.incident.io/v1/incident_attachments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'incident_id' => '01FDAG4SAP5TYPT98WGR2N7W91',
'resource' => [
'emoji' => 'rocket',
'external_id' => '123',
'resource_type' => 'pager_duty_incident',
'title' => 'Impact tracking spreadsheet',
'url' => 'https://github.com/company/repo/pull/123'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.incident.io/v1/incident_attachments"
payload := strings.NewReader("{\n \"incident_id\": \"01FDAG4SAP5TYPT98WGR2N7W91\",\n \"resource\": {\n \"emoji\": \"rocket\",\n \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\n \"title\": \"Impact tracking spreadsheet\",\n \"url\": \"https://github.com/company/repo/pull/123\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.incident.io/v1/incident_attachments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"incident_id\": \"01FDAG4SAP5TYPT98WGR2N7W91\",\n \"resource\": {\n \"emoji\": \"rocket\",\n \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\n \"title\": \"Impact tracking spreadsheet\",\n \"url\": \"https://github.com/company/repo/pull/123\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.incident.io/v1/incident_attachments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"incident_id\": \"01FDAG4SAP5TYPT98WGR2N7W91\",\n \"resource\": {\n \"emoji\": \"rocket\",\n \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\n \"title\": \"Impact tracking spreadsheet\",\n \"url\": \"https://github.com/company/repo/pull/123\"\n }\n}"
response = http.request(request)
puts response.read_body{
"incident_attachment": {
"id": "01FCNDV6P870EA6S7TK1DSYD5H",
"incident_id": "01FCNDV6P870EA6S7TK1DSYD5H",
"resource": {
"external_id": "123",
"permalink": "https://my.pagerduty.com/incidents/ABC",
"resource_type": "pager_duty_incident",
"title": "The database has gone down"
}
}
}π Requires the
attachments.create scope.Authorizations
API key from your incident.io dashboard (Settings β API keys)
Body
application/json
ID of the incident to add an attachment to
Example:
"01FDAG4SAP5TYPT98WGR2N7W91"
Show child attributes
Show child attributes
Example:
{
"emoji": "rocket",
"external_id": "123",
"resource_type": "pager_duty_incident",
"title": "Impact tracking spreadsheet",
"url": "https://github.com/company/repo/pull/123"
}
Response
201 - application/json
Created response.
Show child attributes
Show child attributes
Was this page helpful?
βI
Create
curl --request POST \
--url https://api.incident.io/v1/incident_attachments \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"incident_id": "01FDAG4SAP5TYPT98WGR2N7W91",
"resource": {
"emoji": "rocket",
"external_id": "123",
"resource_type": "pager_duty_incident",
"title": "Impact tracking spreadsheet",
"url": "https://github.com/company/repo/pull/123"
}
}
'import requests
url = "https://api.incident.io/v1/incident_attachments"
payload = {
"incident_id": "01FDAG4SAP5TYPT98WGR2N7W91",
"resource": {
"emoji": "rocket",
"external_id": "123",
"resource_type": "pager_duty_incident",
"title": "Impact tracking spreadsheet",
"url": "https://github.com/company/repo/pull/123"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
incident_id: '01FDAG4SAP5TYPT98WGR2N7W91',
resource: {
emoji: 'rocket',
external_id: '123',
resource_type: 'pager_duty_incident',
title: 'Impact tracking spreadsheet',
url: 'https://github.com/company/repo/pull/123'
}
})
};
fetch('https://api.incident.io/v1/incident_attachments', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.incident.io/v1/incident_attachments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'incident_id' => '01FDAG4SAP5TYPT98WGR2N7W91',
'resource' => [
'emoji' => 'rocket',
'external_id' => '123',
'resource_type' => 'pager_duty_incident',
'title' => 'Impact tracking spreadsheet',
'url' => 'https://github.com/company/repo/pull/123'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.incident.io/v1/incident_attachments"
payload := strings.NewReader("{\n \"incident_id\": \"01FDAG4SAP5TYPT98WGR2N7W91\",\n \"resource\": {\n \"emoji\": \"rocket\",\n \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\n \"title\": \"Impact tracking spreadsheet\",\n \"url\": \"https://github.com/company/repo/pull/123\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.incident.io/v1/incident_attachments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"incident_id\": \"01FDAG4SAP5TYPT98WGR2N7W91\",\n \"resource\": {\n \"emoji\": \"rocket\",\n \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\n \"title\": \"Impact tracking spreadsheet\",\n \"url\": \"https://github.com/company/repo/pull/123\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.incident.io/v1/incident_attachments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"incident_id\": \"01FDAG4SAP5TYPT98WGR2N7W91\",\n \"resource\": {\n \"emoji\": \"rocket\",\n \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\n \"title\": \"Impact tracking spreadsheet\",\n \"url\": \"https://github.com/company/repo/pull/123\"\n }\n}"
response = http.request(request)
puts response.read_body{
"incident_attachment": {
"id": "01FCNDV6P870EA6S7TK1DSYD5H",
"incident_id": "01FCNDV6P870EA6S7TK1DSYD5H",
"resource": {
"external_id": "123",
"permalink": "https://my.pagerduty.com/incidents/ABC",
"resource_type": "pager_duty_incident",
"title": "The database has gone down"
}
}
}