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.
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": {
"external_id": "123",
"resource_type": "pager_duty_incident",
"url": "https://github.com/company/repo/pull/123"
}
}
'import requests
url = "https://api.incident.io/v1/incident_attachments"
payload = {
"incident_id": "01FDAG4SAP5TYPT98WGR2N7W91",
"resource": {
"external_id": "123",
"resource_type": "pager_duty_incident",
"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: {
external_id: '123',
resource_type: 'pager_duty_incident',
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' => [
'external_id' => '123',
'resource_type' => 'pager_duty_incident',
'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 \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\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 \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\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 \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\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
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": {
"external_id": "123",
"resource_type": "pager_duty_incident",
"url": "https://github.com/company/repo/pull/123"
}
}
'import requests
url = "https://api.incident.io/v1/incident_attachments"
payload = {
"incident_id": "01FDAG4SAP5TYPT98WGR2N7W91",
"resource": {
"external_id": "123",
"resource_type": "pager_duty_incident",
"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: {
external_id: '123',
resource_type: 'pager_duty_incident',
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' => [
'external_id' => '123',
'resource_type' => 'pager_duty_incident',
'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 \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\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 \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\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 \"external_id\": \"123\",\n \"resource_type\": \"pager_duty_incident\",\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"
}
}
}