Menu
Grafana Cloud

Reference

This page describes the entire API surface in detail.

Services

The Grafana Incident JSON/HTTP RPC API is made up of the following services:

  • ActivityService - ActivityService provides access to incident activity. You can post notes to the timeline, and query and update the individual timeline items.
  • IncidentsService - IncidentsService provides the ability to query, get, declare (create), update, and manage Incidents programatically. You can also assign roles and update labels.
  • RolesService - RolesService defines the interface for interacting with roles, providing CRUD operations and more fatures related to roles.
  • TasksService - TasksService provides methods for managing tasks relating to Incidents.

ActivityService

ActivityService provides access to incident activity. You can post notes to the timeline, and query and update the individual timeline items.

AddActivity

AddActivity posts an activity item to an Incident.

AddActivityRequest

  • incidentID - string - IncidentID is the unique identifier of the Incident.
  • activityKind - string - options: "userNote" - ActivityKind is the type of activity this item represents.
  • body - string - Body is a human readable description of the ActivityItem. URLs mentioned will be parsed and attached as context.
  • eventTime - string - EventTime is the time when the event occurred. If empty, the current time is used. The string value format should follow RFC 3339.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/ActivityService.AddActivity" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"activityKind": "userNote",
	"body": "Some interesting insights from a third-party system",
	"eventTime": "2021-08-07T11:58:23Z",
	"incidentID": "incident-123"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	activityService := incident.NewActivityService(client)
	// make the request...
	addActivityResp, err := activityService.AddActivity(ctx, main.AddActivityRequest{
		IncidentID: "incident-123",
		ActivityKind: "userNote",
		Body: "Some interesting insights from a third-party system",
		EventTime: "2021-08-07T11:58:23Z",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("ActivityItem: %+v\n", addActivityResp.ActivityItem)
	log.Printf("Error: %+v\n", addActivityResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/ActivityService.AddActivity
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"activityKind": "userNote",
	"body": "Some interesting insights from a third-party system",
	"eventTime": "2021-08-07T11:58:23Z",
	"incidentID": "incident-123"
}
JavaScript
import { GrafanaIncidentClient, ActivityService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const activityService = new ActivityService(client);

// AddActivity posts an activity item to an Incident.
const activityServiceResp = await activityService.addActivity({
	"activityKind": "userNote",
	"body": "Some interesting insights from a third-party system",
	"eventTime": "2021-08-07T11:58:23Z",
	"incidentID": "incident-123"
});

if (!activityServiceResp.success) {
  // handle the error
  throw new Error(activityServiceResp.error);
}

// access the fields of the response
console.info({"activityItem", activityServiceResp.data.activityItem});

AddActivityResponse

A 200 response with an empty error field indicates that the request was successful.

  • activityItem - ActivityItem - ActivityItem is the newly created ActivityItem.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"activityItem": {
		"activityItemID": "activity-item-123",
		"activityKind": "incidentCreated",
		"attachments": [
			{
				"attachedByUserID": "user-123",
				"attachmentErr": "file too large",
				"attachmentID": "attachment-123",
				"contentLength": 123456,
				"contentType": "image/jpeg",
				"deletedTime": "2019-01-01T00:00:00Z",
				"displayType": "list",
				"downloadURL": "https://somewhere.com/path/to/filename.jpg",
				"ext": ".jpg",
				"fileType": "image",
				"hasThumbnail": true,
				"path": "filename.jpg",
				"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
				"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
				"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
				"uploadTime": "2019-01-01T00:00:00Z",
				"useSourceURL": true
			},
			{
				"attachedByUserID": "user-123",
				"attachmentErr": "file too large",
				"attachmentID": "attachment-123",
				"contentLength": 123456,
				"contentType": "image/jpeg",
				"deletedTime": "2019-01-01T00:00:00Z",
				"displayType": "list",
				"downloadURL": "https://somewhere.com/path/to/filename.jpg",
				"ext": ".jpg",
				"fileType": "image",
				"hasThumbnail": true,
				"path": "filename.jpg",
				"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
				"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
				"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
				"uploadTime": "2019-01-01T00:00:00Z",
				"useSourceURL": true
			}
		],
		"body": "The incident was created by user-123",
		"createdTime": "2021-08-07T11:58:23Z",
		"eventTime": "2021-08-07T11:58:23Z",
		"fieldValues": {
			"something-else": true,
			"title": "new title"
		},
		"immutable": true,
		"incidentID": "incident-123",
		"subjectUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"tags": [
			"important"
		],
		"url": "https://meet.google.com/my-incident-room",
		"user": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		}
	},
	"error": "something went wrong"
}

QueryActivity

QueryActivity gets a selection of activity items.

QueryActivityRequest

  • query - ActivityQuery - Query describes the query to make.
  • cursor - Cursor - Cursor is used to page through results. Empty for the first page. For subsequent pages, use previously returned Cursor values.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/ActivityService.QueryActivity" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"cursor": {
		"hasMore": true,
		"nextValue": "aaaabbbbccccddddeeeeffffgggg"
	},
	"query": {
		"activityKind": [
			"incidentCreated"
		],
		"incidentID": "incident-123",
		"limit": 10,
		"orderDirection": "ASC",
		"tag": "important"
	}
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	activityService := incident.NewActivityService(client)
	// make the request...
	queryActivityResp, err := activityService.QueryActivity(ctx, main.QueryActivityRequest{
		Query: main.ActivityQuery{
			IncidentID: "incident-123",
			Limit: 10,
			Tag: "important",
			OrderDirection: "ASC",
			ActivityKind: ["incidentCreated"],
		},
		Cursor: main.Cursor{
			NextValue: "aaaabbbbccccddddeeeeffffgggg",
			HasMore: true,
		},
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("ActivityItems: %+v\n", queryActivityResp.ActivityItems)
	log.Printf("Query: %+v\n", queryActivityResp.Query)
	log.Printf("Cursor: %+v\n", queryActivityResp.Cursor)
	log.Printf("Error: %+v\n", queryActivityResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/ActivityService.QueryActivity
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"cursor": {
		"hasMore": true,
		"nextValue": "aaaabbbbccccddddeeeeffffgggg"
	},
	"query": {
		"activityKind": [
			"incidentCreated"
		],
		"incidentID": "incident-123",
		"limit": 10,
		"orderDirection": "ASC",
		"tag": "important"
	}
}
JavaScript
import { GrafanaIncidentClient, ActivityService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const activityService = new ActivityService(client);

// QueryActivity gets a selection of activity items.
const activityServiceResp = await activityService.queryActivity({
	"cursor": {
		"hasMore": true,
		"nextValue": "aaaabbbbccccddddeeeeffffgggg"
	},
	"query": {
		"activityKind": [
			"incidentCreated"
		],
		"incidentID": "incident-123",
		"limit": 10,
		"orderDirection": "ASC",
		"tag": "important"
	}
});

if (!activityServiceResp.success) {
  // handle the error
  throw new Error(activityServiceResp.error);
}

// access the fields of the response
console.info({"activityItems", activityServiceResp.data.activityItems});
console.info({"query", activityServiceResp.data.query});
console.info({"cursor", activityServiceResp.data.cursor});

QueryActivityResponse

A 200 response with an empty error field indicates that the request was successful.

  • activityItems - array of ActivityItem - ActivityItems is the list of items.
  • query - ActivityQuery - Query is the query that was used to generate the response.
  • cursor - Cursor - Cursor is used to page through results. Empty for the first page. For subsequent pages, use previously returned Cursor values.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"activityItems": [
		{
			"activityItemID": "activity-item-123",
			"activityKind": "incidentCreated",
			"attachments": [
				{
					"attachedByUserID": "user-123",
					"attachmentErr": "file too large",
					"attachmentID": "attachment-123",
					"contentLength": 123456,
					"contentType": "image/jpeg",
					"deletedTime": "2019-01-01T00:00:00Z",
					"displayType": "list",
					"downloadURL": "https://somewhere.com/path/to/filename.jpg",
					"ext": ".jpg",
					"fileType": "image",
					"hasThumbnail": true,
					"path": "filename.jpg",
					"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
					"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
					"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
					"uploadTime": "2019-01-01T00:00:00Z",
					"useSourceURL": true
				},
				{
					"attachedByUserID": "user-123",
					"attachmentErr": "file too large",
					"attachmentID": "attachment-123",
					"contentLength": 123456,
					"contentType": "image/jpeg",
					"deletedTime": "2019-01-01T00:00:00Z",
					"displayType": "list",
					"downloadURL": "https://somewhere.com/path/to/filename.jpg",
					"ext": ".jpg",
					"fileType": "image",
					"hasThumbnail": true,
					"path": "filename.jpg",
					"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
					"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
					"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
					"uploadTime": "2019-01-01T00:00:00Z",
					"useSourceURL": true
				}
			],
			"body": "The incident was created by user-123",
			"createdTime": "2021-08-07T11:58:23Z",
			"eventTime": "2021-08-07T11:58:23Z",
			"fieldValues": {
				"something-else": true,
				"title": "new title"
			},
			"immutable": true,
			"incidentID": "incident-123",
			"subjectUser": {
				"name": "Morty Smith",
				"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
				"userID": "user-123"
			},
			"tags": [
				"important"
			],
			"url": "https://meet.google.com/my-incident-room",
			"user": {
				"name": "Morty Smith",
				"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
				"userID": "user-123"
			}
		},
		{
			"activityItemID": "activity-item-123",
			"activityKind": "incidentCreated",
			"attachments": [
				{
					"attachedByUserID": "user-123",
					"attachmentErr": "file too large",
					"attachmentID": "attachment-123",
					"contentLength": 123456,
					"contentType": "image/jpeg",
					"deletedTime": "2019-01-01T00:00:00Z",
					"displayType": "list",
					"downloadURL": "https://somewhere.com/path/to/filename.jpg",
					"ext": ".jpg",
					"fileType": "image",
					"hasThumbnail": true,
					"path": "filename.jpg",
					"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
					"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
					"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
					"uploadTime": "2019-01-01T00:00:00Z",
					"useSourceURL": true
				},
				{
					"attachedByUserID": "user-123",
					"attachmentErr": "file too large",
					"attachmentID": "attachment-123",
					"contentLength": 123456,
					"contentType": "image/jpeg",
					"deletedTime": "2019-01-01T00:00:00Z",
					"displayType": "list",
					"downloadURL": "https://somewhere.com/path/to/filename.jpg",
					"ext": ".jpg",
					"fileType": "image",
					"hasThumbnail": true,
					"path": "filename.jpg",
					"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
					"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
					"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
					"uploadTime": "2019-01-01T00:00:00Z",
					"useSourceURL": true
				}
			],
			"body": "The incident was created by user-123",
			"createdTime": "2021-08-07T11:58:23Z",
			"eventTime": "2021-08-07T11:58:23Z",
			"fieldValues": {
				"something-else": true,
				"title": "new title"
			},
			"immutable": true,
			"incidentID": "incident-123",
			"subjectUser": {
				"name": "Morty Smith",
				"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
				"userID": "user-123"
			},
			"tags": [
				"important"
			],
			"url": "https://meet.google.com/my-incident-room",
			"user": {
				"name": "Morty Smith",
				"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
				"userID": "user-123"
			}
		}
	],
	"cursor": {
		"hasMore": true,
		"nextValue": "aaaabbbbccccddddeeeeffffgggg"
	},
	"error": "something went wrong",
	"query": {
		"activityKind": [
			"incidentCreated"
		],
		"incidentID": "incident-123",
		"limit": 10,
		"orderDirection": "ASC",
		"tag": "important"
	}
}

RemoveActivity

RemoveActivity removes an activity item.

RemoveActivityRequest

  • incidentID - string - IncidentID is the identifier.
  • activityItemID - string - ActivityItemID is the unique identifier of the ActivityItem.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/ActivityService.RemoveActivity" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"activityItemID": "activity-item-123",
	"incidentID": "incident-123"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	activityService := incident.NewActivityService(client)
	// make the request...
	removeActivityResp, err := activityService.RemoveActivity(ctx, main.RemoveActivityRequest{
		IncidentID: "incident-123",
		ActivityItemID: "activity-item-123",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("ActivityItem: %+v\n", removeActivityResp.ActivityItem)
	log.Printf("Error: %+v\n", removeActivityResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/ActivityService.RemoveActivity
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"activityItemID": "activity-item-123",
	"incidentID": "incident-123"
}
JavaScript
import { GrafanaIncidentClient, ActivityService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const activityService = new ActivityService(client);

// RemoveActivity removes an activity item.
const activityServiceResp = await activityService.removeActivity({
	"activityItemID": "activity-item-123",
	"incidentID": "incident-123"
});

if (!activityServiceResp.success) {
  // handle the error
  throw new Error(activityServiceResp.error);
}

// access the fields of the response
console.info({"activityItem", activityServiceResp.data.activityItem});

RemoveActivityResponse

A 200 response with an empty error field indicates that the request was successful.

  • activityItem - ActivityItem - ActivityItem is the updated ActivityItem.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"activityItem": {
		"activityItemID": "activity-item-123",
		"activityKind": "incidentCreated",
		"attachments": [
			{
				"attachedByUserID": "user-123",
				"attachmentErr": "file too large",
				"attachmentID": "attachment-123",
				"contentLength": 123456,
				"contentType": "image/jpeg",
				"deletedTime": "2019-01-01T00:00:00Z",
				"displayType": "list",
				"downloadURL": "https://somewhere.com/path/to/filename.jpg",
				"ext": ".jpg",
				"fileType": "image",
				"hasThumbnail": true,
				"path": "filename.jpg",
				"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
				"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
				"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
				"uploadTime": "2019-01-01T00:00:00Z",
				"useSourceURL": true
			},
			{
				"attachedByUserID": "user-123",
				"attachmentErr": "file too large",
				"attachmentID": "attachment-123",
				"contentLength": 123456,
				"contentType": "image/jpeg",
				"deletedTime": "2019-01-01T00:00:00Z",
				"displayType": "list",
				"downloadURL": "https://somewhere.com/path/to/filename.jpg",
				"ext": ".jpg",
				"fileType": "image",
				"hasThumbnail": true,
				"path": "filename.jpg",
				"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
				"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
				"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
				"uploadTime": "2019-01-01T00:00:00Z",
				"useSourceURL": true
			}
		],
		"body": "The incident was created by user-123",
		"createdTime": "2021-08-07T11:58:23Z",
		"eventTime": "2021-08-07T11:58:23Z",
		"fieldValues": {
			"something-else": true,
			"title": "new title"
		},
		"immutable": true,
		"incidentID": "incident-123",
		"subjectUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"tags": [
			"important"
		],
		"url": "https://meet.google.com/my-incident-room",
		"user": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		}
	},
	"error": "something went wrong"
}

UpdateActivityBody

UpdateActivityBody updates the body of a specific activity item.

UpdateActivityBodyRequest

  • incidentID - string - IncidentID is the identifier.
  • activityItemID - string - ActivityItemID is the unique identifier of the ActivityItem.
  • body - string - Body is the new body to use for the given activity item
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/ActivityService.UpdateActivityBody" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"activityItemID": "activity-item-123",
	"body": "New contents",
	"incidentID": "incident-123"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	activityService := incident.NewActivityService(client)
	// make the request...
	updateActivityBodyResp, err := activityService.UpdateActivityBody(ctx, main.UpdateActivityBodyRequest{
		IncidentID: "incident-123",
		ActivityItemID: "activity-item-123",
		Body: "New contents",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("ActivityItem: %+v\n", updateActivityBodyResp.ActivityItem)
	log.Printf("Error: %+v\n", updateActivityBodyResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/ActivityService.UpdateActivityBody
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"activityItemID": "activity-item-123",
	"body": "New contents",
	"incidentID": "incident-123"
}
JavaScript
import { GrafanaIncidentClient, ActivityService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const activityService = new ActivityService(client);

// UpdateActivityBody updates the body of a specific activity item.
const activityServiceResp = await activityService.updateActivityBody({
	"activityItemID": "activity-item-123",
	"body": "New contents",
	"incidentID": "incident-123"
});

if (!activityServiceResp.success) {
  // handle the error
  throw new Error(activityServiceResp.error);
}

// access the fields of the response
console.info({"activityItem", activityServiceResp.data.activityItem});

UpdateActivityBodyResponse

A 200 response with an empty error field indicates that the request was successful.

  • activityItem - ActivityItem - ActivityItem is the updated ActivityItem.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"activityItem": {
		"activityItemID": "activity-item-123",
		"activityKind": "incidentCreated",
		"attachments": [
			{
				"attachedByUserID": "user-123",
				"attachmentErr": "file too large",
				"attachmentID": "attachment-123",
				"contentLength": 123456,
				"contentType": "image/jpeg",
				"deletedTime": "2019-01-01T00:00:00Z",
				"displayType": "list",
				"downloadURL": "https://somewhere.com/path/to/filename.jpg",
				"ext": ".jpg",
				"fileType": "image",
				"hasThumbnail": true,
				"path": "filename.jpg",
				"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
				"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
				"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
				"uploadTime": "2019-01-01T00:00:00Z",
				"useSourceURL": true
			},
			{
				"attachedByUserID": "user-123",
				"attachmentErr": "file too large",
				"attachmentID": "attachment-123",
				"contentLength": 123456,
				"contentType": "image/jpeg",
				"deletedTime": "2019-01-01T00:00:00Z",
				"displayType": "list",
				"downloadURL": "https://somewhere.com/path/to/filename.jpg",
				"ext": ".jpg",
				"fileType": "image",
				"hasThumbnail": true,
				"path": "filename.jpg",
				"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
				"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
				"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
				"uploadTime": "2019-01-01T00:00:00Z",
				"useSourceURL": true
			}
		],
		"body": "The incident was created by user-123",
		"createdTime": "2021-08-07T11:58:23Z",
		"eventTime": "2021-08-07T11:58:23Z",
		"fieldValues": {
			"something-else": true,
			"title": "new title"
		},
		"immutable": true,
		"incidentID": "incident-123",
		"subjectUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"tags": [
			"important"
		],
		"url": "https://meet.google.com/my-incident-room",
		"user": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		}
	},
	"error": "something went wrong"
}

UpdateActivityEventTime

UpdateActivityEventTime updates the event time of a specific activity item.

UpdateActivityEventTimeRequest

  • incidentID - string - IncidentID is the identifier.
  • activityItemID - string - ActivityItemID is the unique identifier of the ActivityItem.
  • eventTime - string - EventTime is the time when the event occurred. If empty, the created time of the activity item is used. The string value format should follow RFC 3339.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/ActivityService.UpdateActivityEventTime" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"activityItemID": "activity-item-123",
	"eventTime": "2021-08-07T11:58:23Z",
	"incidentID": "incident-123"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	activityService := incident.NewActivityService(client)
	// make the request...
	updateActivityEventTimeResp, err := activityService.UpdateActivityEventTime(ctx, main.UpdateActivityEventTimeRequest{
		IncidentID: "incident-123",
		ActivityItemID: "activity-item-123",
		EventTime: "2021-08-07T11:58:23Z",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("ActivityItem: %+v\n", updateActivityEventTimeResp.ActivityItem)
	log.Printf("Error: %+v\n", updateActivityEventTimeResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/ActivityService.UpdateActivityEventTime
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"activityItemID": "activity-item-123",
	"eventTime": "2021-08-07T11:58:23Z",
	"incidentID": "incident-123"
}
JavaScript
import { GrafanaIncidentClient, ActivityService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const activityService = new ActivityService(client);

// UpdateActivityEventTime updates the event time of a specific activity item.
const activityServiceResp = await activityService.updateActivityEventTime({
	"activityItemID": "activity-item-123",
	"eventTime": "2021-08-07T11:58:23Z",
	"incidentID": "incident-123"
});

if (!activityServiceResp.success) {
  // handle the error
  throw new Error(activityServiceResp.error);
}

// access the fields of the response
console.info({"activityItem", activityServiceResp.data.activityItem});

UpdateActivityEventTimeResponse

A 200 response with an empty error field indicates that the request was successful.

  • activityItem - ActivityItem - ActivityItem is the updated ActivityItem.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"activityItem": {
		"activityItemID": "activity-item-123",
		"activityKind": "incidentCreated",
		"attachments": [
			{
				"attachedByUserID": "user-123",
				"attachmentErr": "file too large",
				"attachmentID": "attachment-123",
				"contentLength": 123456,
				"contentType": "image/jpeg",
				"deletedTime": "2019-01-01T00:00:00Z",
				"displayType": "list",
				"downloadURL": "https://somewhere.com/path/to/filename.jpg",
				"ext": ".jpg",
				"fileType": "image",
				"hasThumbnail": true,
				"path": "filename.jpg",
				"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
				"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
				"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
				"uploadTime": "2019-01-01T00:00:00Z",
				"useSourceURL": true
			},
			{
				"attachedByUserID": "user-123",
				"attachmentErr": "file too large",
				"attachmentID": "attachment-123",
				"contentLength": 123456,
				"contentType": "image/jpeg",
				"deletedTime": "2019-01-01T00:00:00Z",
				"displayType": "list",
				"downloadURL": "https://somewhere.com/path/to/filename.jpg",
				"ext": ".jpg",
				"fileType": "image",
				"hasThumbnail": true,
				"path": "filename.jpg",
				"sHA512": "327232b67c88cba87c0a85a32bb192df527c21854d6515144d691f8cf1554f8e9969eed443b85e00d5ea21628c0ca4b6bbc9f26c837815fad6e9b3881cbb5cfd",
				"sourceURL": "https://somewhere-like-slack.com/path/to/filename.jpg",
				"thumbnailURL": "https://somewhere.com/path/to/thumbnail.jpg",
				"uploadTime": "2019-01-01T00:00:00Z",
				"useSourceURL": true
			}
		],
		"body": "The incident was created by user-123",
		"createdTime": "2021-08-07T11:58:23Z",
		"eventTime": "2021-08-07T11:58:23Z",
		"fieldValues": {
			"something-else": true,
			"title": "new title"
		},
		"immutable": true,
		"incidentID": "incident-123",
		"subjectUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"tags": [
			"important"
		],
		"url": "https://meet.google.com/my-incident-room",
		"user": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		}
	},
	"error": "something went wrong"
}

IncidentsService

IncidentsService provides the ability to query, get, declare (create), update, and manage Incidents programatically. You can also assign roles and update labels.

AddLabel

AddLabel adds a label to the Incident.

AddLabelRequest

  • incidentID - string - IncidentID is the identifier of the Incident.
  • label - IncidentLabel - Label is the new label of the Incident.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.AddLabel" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123",
	"label": {
		"colorHex": "#ff0000",
		"description": "Customers are affected by this incident.",
		"label": "customers-affected"
	}
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	addLabelResp, err := incidentsService.AddLabel(ctx, main.AddLabelRequest{
		IncidentID: "incident-123",
		Label: main.IncidentLabel{
			Label: "customers-affected",
			Description: "Customers are affected by this incident.",
			ColorHex: "#ff0000",
		},
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incident: %+v\n", addLabelResp.Incident)
	log.Printf("Error: %+v\n", addLabelResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.AddLabel
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123",
	"label": {
		"colorHex": "#ff0000",
		"description": "Customers are affected by this incident.",
		"label": "customers-affected"
	}
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// AddLabel adds a label to the Incident.
const incidentsServiceResp = await incidentsService.addLabel({
	"incidentID": "incident-123",
	"label": {
		"colorHex": "#ff0000",
		"description": "Customers are affected by this incident.",
		"label": "customers-affected"
	}
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incident", incidentsServiceResp.data.incident});

AddLabelResponse

A 200 response with an empty error field indicates that the request was successful.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incident": {
		"closedTime": "2021-08-07T11:58:23Z",
		"createdByUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2021-08-07T11:58:23Z",
		"durationSeconds": 60,
		"heroImagePath": "/relative/path/to/hero/image.png",
		"incidentEnd": "2022-02-11 00:50:20.574137",
		"incidentID": "incident-123",
		"incidentMembership": {
			"assignments": [
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"totalAssignments": 5,
			"totalParticipants": 3
		},
		"incidentStart": "2022-02-11 00:50:20.574137",
		"isDrill": true,
		"labels": [
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			},
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			}
		],
		"modifiedTime": "2021-08-07T11:58:23Z",
		"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
		"roles": [
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			},
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			}
		],
		"severity": "minor",
		"status": "active",
		"summary": "Something happened, we found out something interesting, then we fixed it.",
		"taskList": {
			"doneCount": 8,
			"tasks": [
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				},
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				}
			],
			"todoCount": 5
		},
		"title": "high latency in web requests"
	}
}

AssignRole

AssignRole assigns a role to a user.

AssignRoleRequest

  • incidentID - string - IncidentID is the identifier.
  • userID - string - UserID is the identifier of the person to assign the role to.
  • role - string - options: "commander" "investigator" "observer" - Role is the role of this person.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.AssignRole" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123",
	"role": "commander",
	"userID": "grafana-incident:user-123"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	assignRoleResp, err := incidentsService.AssignRole(ctx, main.AssignRoleRequest{
		IncidentID: "incident-123",
		UserID: "grafana-incident:user-123",
		Role: "commander",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incident: %+v\n", assignRoleResp.Incident)
	log.Printf("DidChange: %+v\n", assignRoleResp.DidChange)
	log.Printf("Error: %+v\n", assignRoleResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.AssignRole
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123",
	"role": "commander",
	"userID": "grafana-incident:user-123"
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// AssignRole assigns a role to a user.
const incidentsServiceResp = await incidentsService.assignRole({
	"incidentID": "incident-123",
	"role": "commander",
	"userID": "grafana-incident:user-123"
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incident", incidentsServiceResp.data.incident});
console.info({"didChange", incidentsServiceResp.data.didChange});

AssignRoleResponse

A 200 response with an empty error field indicates that the request was successful.

  • incident - Incident - Incident is the Incident that was just updated.
  • didChange - boolean - DidChange indicates if the role was changed or not. If the role was already assigned, this will be false.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"didChange": true,
	"error": "something went wrong",
	"incident": {
		"closedTime": "2021-08-07T11:58:23Z",
		"createdByUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2021-08-07T11:58:23Z",
		"durationSeconds": 60,
		"heroImagePath": "/relative/path/to/hero/image.png",
		"incidentEnd": "2022-02-11 00:50:20.574137",
		"incidentID": "incident-123",
		"incidentMembership": {
			"assignments": [
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"totalAssignments": 5,
			"totalParticipants": 3
		},
		"incidentStart": "2022-02-11 00:50:20.574137",
		"isDrill": true,
		"labels": [
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			},
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			}
		],
		"modifiedTime": "2021-08-07T11:58:23Z",
		"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
		"roles": [
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			},
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			}
		],
		"severity": "minor",
		"status": "active",
		"summary": "Something happened, we found out something interesting, then we fixed it.",
		"taskList": {
			"doneCount": 8,
			"tasks": [
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				},
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				}
			],
			"todoCount": 5
		},
		"title": "high latency in web requests"
	}
}

CreateIncident

CreateIncident creates a new Incident.

CreateIncidentRequest

  • title - string - Title is the headline title of the Incident. Shorter the better, but should contain enough information to be able to identify and refer to this issue.
  • severity - string - options: "pending" "minor" "major" "critical" - Severity expresses how bad the Incident is.
  • labels - array of IncidentLabel - Labels are the labels associated with the Incident. Only the Label string is processed, the other fields are ignored.
  • roomPrefix - string - RoomPrefix is the prefix that will be used to create the Incident room.
  • isDrill - boolean - IsDrill indicates if the Incident is a drill or not. Incidents that are drills do not show up in the dashboards, and may behave subtly differently in other ways too. For example, during drills, more help might be offered to users.
  • status - string - options: "active" "resolved" - Status is the starting status of the Incident. Use “resolved” to open a retrospective incident.
  • attachCaption - string - AttachCaption is the title of associated URL.
  • attachURL - string - AttachURLis the associated URL.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.CreateIncident" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"attachCaption": "Grafana Incident: Powerful incident management, built on top of Grafana",
	"attachURL": "https://grafana.com/products/incident",
	"isDrill": true,
	"labels": [
		{
			"colorHex": "#ff0000",
			"description": "Customers are affected by this incident.",
			"label": "customers-affected"
		},
		{
			"colorHex": "#ff0000",
			"description": "Customers are affected by this incident.",
			"label": "customers-affected"
		}
	],
	"roomPrefix": "incident",
	"severity": "minor",
	"status": "active",
	"title": "High latency in web requests"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	createIncidentResp, err := incidentsService.CreateIncident(ctx, main.CreateIncidentRequest{
		Title: "High latency in web requests",
		Severity: "minor",
		Labels: main.IncidentLabel{
			Label: "customers-affected",
			Description: "Customers are affected by this incident.",
			ColorHex: "#ff0000",
		},
		RoomPrefix: "incident",
		IsDrill: true,
		Status: "active",
		AttachCaption: "Grafana Incident: Powerful incident management, built on top of Grafana",
		AttachURL: "https://grafana.com/products/incident",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incident: %+v\n", createIncidentResp.Incident)
	log.Printf("Error: %+v\n", createIncidentResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.CreateIncident
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"attachCaption": "Grafana Incident: Powerful incident management, built on top of Grafana",
	"attachURL": "https://grafana.com/products/incident",
	"isDrill": true,
	"labels": [
		{
			"colorHex": "#ff0000",
			"description": "Customers are affected by this incident.",
			"label": "customers-affected"
		},
		{
			"colorHex": "#ff0000",
			"description": "Customers are affected by this incident.",
			"label": "customers-affected"
		}
	],
	"roomPrefix": "incident",
	"severity": "minor",
	"status": "active",
	"title": "High latency in web requests"
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// CreateIncident creates a new Incident.
const incidentsServiceResp = await incidentsService.createIncident({
	"attachCaption": "Grafana Incident: Powerful incident management, built on top of Grafana",
	"attachURL": "https://grafana.com/products/incident",
	"isDrill": true,
	"labels": [
		{
			"colorHex": "#ff0000",
			"description": "Customers are affected by this incident.",
			"label": "customers-affected"
		},
		{
			"colorHex": "#ff0000",
			"description": "Customers are affected by this incident.",
			"label": "customers-affected"
		}
	],
	"roomPrefix": "incident",
	"severity": "minor",
	"status": "active",
	"title": "High latency in web requests"
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incident", incidentsServiceResp.data.incident});

CreateIncidentResponse

A 200 response with an empty error field indicates that the request was successful.

  • incident - Incident - Incident is the Incident that was created.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incident": {
		"closedTime": "2021-08-07T11:58:23Z",
		"createdByUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2021-08-07T11:58:23Z",
		"durationSeconds": 60,
		"heroImagePath": "/relative/path/to/hero/image.png",
		"incidentEnd": "2022-02-11 00:50:20.574137",
		"incidentID": "incident-123",
		"incidentMembership": {
			"assignments": [
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"totalAssignments": 5,
			"totalParticipants": 3
		},
		"incidentStart": "2022-02-11 00:50:20.574137",
		"isDrill": true,
		"labels": [
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			},
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			}
		],
		"modifiedTime": "2021-08-07T11:58:23Z",
		"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
		"roles": [
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			},
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			}
		],
		"severity": "minor",
		"status": "active",
		"summary": "Something happened, we found out something interesting, then we fixed it.",
		"taskList": {
			"doneCount": 8,
			"tasks": [
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				},
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				}
			],
			"todoCount": 5
		},
		"title": "high latency in web requests"
	}
}

GetIncident

GetIncident gets an existing Incident by ID.

GetIncidentRequest

  • incidentID - string - IncidentID is the identifier.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.GetIncident" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	getIncidentResp, err := incidentsService.GetIncident(ctx, main.GetIncidentRequest{
		IncidentID: "incident-123",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incident: %+v\n", getIncidentResp.Incident)
	log.Printf("Error: %+v\n", getIncidentResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.GetIncident
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123"
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// GetIncident gets an existing Incident by ID.
const incidentsServiceResp = await incidentsService.getIncident({
	"incidentID": "incident-123"
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incident", incidentsServiceResp.data.incident});

GetIncidentResponse

A 200 response with an empty error field indicates that the request was successful.

  • incident - Incident - Incident is the Incident.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incident": {
		"closedTime": "2021-08-07T11:58:23Z",
		"createdByUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2021-08-07T11:58:23Z",
		"durationSeconds": 60,
		"heroImagePath": "/relative/path/to/hero/image.png",
		"incidentEnd": "2022-02-11 00:50:20.574137",
		"incidentID": "incident-123",
		"incidentMembership": {
			"assignments": [
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"totalAssignments": 5,
			"totalParticipants": 3
		},
		"incidentStart": "2022-02-11 00:50:20.574137",
		"isDrill": true,
		"labels": [
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			},
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			}
		],
		"modifiedTime": "2021-08-07T11:58:23Z",
		"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
		"roles": [
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			},
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			}
		],
		"severity": "minor",
		"status": "active",
		"summary": "Something happened, we found out something interesting, then we fixed it.",
		"taskList": {
			"doneCount": 8,
			"tasks": [
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				},
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				}
			],
			"todoCount": 5
		},
		"title": "high latency in web requests"
	}
}

GetIncidentMembership

GetIncidentMembership will return the full list of people involved in an incident

GetIncidentMembershipRequest

  • incidentID - string - IncidentID is the identifier of the Incident.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.GetIncidentMembership" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "1"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	getIncidentMembershipResp, err := incidentsService.GetIncidentMembership(ctx, main.GetIncidentMembershipRequest{
		IncidentID: "1",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Assignments: %+v\n", getIncidentMembershipResp.Assignments)
	log.Printf("Error: %+v\n", getIncidentMembershipResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.GetIncidentMembership
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "1"
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// GetIncidentMembership will return the full list of people involved in an incident
const incidentsServiceResp = await incidentsService.getIncidentMembership({
	"incidentID": "1"
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"assignments", incidentsServiceResp.data.assignments});

GetIncidentMembershipResponse

A 200 response with an empty error field indicates that the request was successful.

  • assignments - array of Assignment - IncidentMembership is the list of people involved in an incident
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"assignments": [
		{
			"role": {
				"archived": true,
				"createdAt": "2020-01-01T00:00:00Z",
				"description": "The commander is the incident commander.",
				"important": true,
				"mandatory": true,
				"name": "commander",
				"orgID": "org-1",
				"roleID": 1,
				"updatedAt": "2020-01-01T00:00:00Z"
			},
			"user": {
				"name": "Morty Smith",
				"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
				"userID": "user-123"
			}
		},
		{
			"role": {
				"archived": true,
				"createdAt": "2020-01-01T00:00:00Z",
				"description": "The commander is the incident commander.",
				"important": true,
				"mandatory": true,
				"name": "commander",
				"orgID": "org-1",
				"roleID": 1,
				"updatedAt": "2020-01-01T00:00:00Z"
			},
			"user": {
				"name": "Morty Smith",
				"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
				"userID": "user-123"
			}
		}
	],
	"error": "something went wrong"
}

QueryIncidents

QueryIncidents gets a list of Incidents.

QueryIncidentsRequest

  • query - IncidentsQuery - Query describes the query to make.
  • cursor - Cursor - Cursor is used to page through results. Empty for the first page. For subsequent pages, use previously returned Cursor values.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.QueryIncidents" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"cursor": {
		"hasMore": true,
		"nextValue": "aaaabbbbccccddddeeeeffffgggg"
	},
	"query": {
		"dateFrom": "2021-01-01T02:07:14+00:00",
		"dateTo": "2021-01-01T02:07:14+00:00",
		"excludeStatuses": [
			"closed"
		],
		"incidentLabels": [
			"security",
			"customersaffected"
		],
		"includeStatuses": [
			"active"
		],
		"limit": 10,
		"onlyDrills": true,
		"orderDirection": "ASC",
		"queryString": "isdrill:false any(label:security label:important)",
		"severity": "major"
	}
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	queryIncidentsResp, err := incidentsService.QueryIncidents(ctx, main.QueryIncidentsRequest{
		Query: main.IncidentsQuery{
			Limit: 10,
			IncludeStatuses: ["active"],
			ExcludeStatuses: ["closed"],
			IncidentLabels: ["security","customersaffected"],
			DateFrom: "2021-01-01T02:07:14+00:00",
			DateTo: "2021-01-01T02:07:14+00:00",
			OnlyDrills: true,
			OrderDirection: "ASC",
			Severity: "major",
			QueryString: "isdrill:false any(label:security label:important)",
		},
		Cursor: main.Cursor{
			NextValue: "aaaabbbbccccddddeeeeffffgggg",
			HasMore: true,
		},
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incidents: %+v\n", queryIncidentsResp.Incidents)
	log.Printf("Query: %+v\n", queryIncidentsResp.Query)
	log.Printf("Cursor: %+v\n", queryIncidentsResp.Cursor)
	log.Printf("Error: %+v\n", queryIncidentsResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.QueryIncidents
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"cursor": {
		"hasMore": true,
		"nextValue": "aaaabbbbccccddddeeeeffffgggg"
	},
	"query": {
		"dateFrom": "2021-01-01T02:07:14+00:00",
		"dateTo": "2021-01-01T02:07:14+00:00",
		"excludeStatuses": [
			"closed"
		],
		"incidentLabels": [
			"security",
			"customersaffected"
		],
		"includeStatuses": [
			"active"
		],
		"limit": 10,
		"onlyDrills": true,
		"orderDirection": "ASC",
		"queryString": "isdrill:false any(label:security label:important)",
		"severity": "major"
	}
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// QueryIncidents gets a list of Incidents.
const incidentsServiceResp = await incidentsService.queryIncidents({
	"cursor": {
		"hasMore": true,
		"nextValue": "aaaabbbbccccddddeeeeffffgggg"
	},
	"query": {
		"dateFrom": "2021-01-01T02:07:14+00:00",
		"dateTo": "2021-01-01T02:07:14+00:00",
		"excludeStatuses": [
			"closed"
		],
		"incidentLabels": [
			"security",
			"customersaffected"
		],
		"includeStatuses": [
			"active"
		],
		"limit": 10,
		"onlyDrills": true,
		"orderDirection": "ASC",
		"queryString": "isdrill:false any(label:security label:important)",
		"severity": "major"
	}
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incidents", incidentsServiceResp.data.incidents});
console.info({"query", incidentsServiceResp.data.query});
console.info({"cursor", incidentsServiceResp.data.cursor});

QueryIncidentsResponse

A 200 response with an empty error field indicates that the request was successful.

  • incidents - array of Incident - Incidents is a list of Incidents.
  • query - IncidentsQuery - Query is the query that was used to generate this response.
  • cursor - Cursor - Cursor should be passed back to get the next page of results.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"cursor": {
		"hasMore": true,
		"nextValue": "aaaabbbbccccddddeeeeffffgggg"
	},
	"error": "something went wrong",
	"incidents": [
		{
			"closedTime": "2021-08-07T11:58:23Z",
			"createdByUser": {
				"name": "Morty Smith",
				"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
				"userID": "user-123"
			},
			"createdTime": "2021-08-07T11:58:23Z",
			"durationSeconds": 60,
			"heroImagePath": "/relative/path/to/hero/image.png",
			"incidentEnd": "2022-02-11 00:50:20.574137",
			"incidentID": "incident-123",
			"incidentMembership": {
				"assignments": [
					{
						"role": {
							"archived": true,
							"createdAt": "2020-01-01T00:00:00Z",
							"description": "The commander is the incident commander.",
							"important": true,
							"mandatory": true,
							"name": "commander",
							"orgID": "org-1",
							"roleID": 1,
							"updatedAt": "2020-01-01T00:00:00Z"
						},
						"user": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						}
					},
					{
						"role": {
							"archived": true,
							"createdAt": "2020-01-01T00:00:00Z",
							"description": "The commander is the incident commander.",
							"important": true,
							"mandatory": true,
							"name": "commander",
							"orgID": "org-1",
							"roleID": 1,
							"updatedAt": "2020-01-01T00:00:00Z"
						},
						"user": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						}
					}
				],
				"totalAssignments": 5,
				"totalParticipants": 3
			},
			"incidentStart": "2022-02-11 00:50:20.574137",
			"isDrill": true,
			"labels": [
				{
					"colorHex": "#ff0000",
					"description": "Customers are affected by this incident.",
					"label": "customers-affected"
				},
				{
					"colorHex": "#ff0000",
					"description": "Customers are affected by this incident.",
					"label": "customers-affected"
				}
			],
			"modifiedTime": "2021-08-07T11:58:23Z",
			"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
			"roles": [
				{
					"description": "Investigator searches for the problem and reports back.",
					"important": true,
					"mandatory": true,
					"maxPeople": 1,
					"role": "investigator",
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"description": "Investigator searches for the problem and reports back.",
					"important": true,
					"mandatory": true,
					"maxPeople": 1,
					"role": "investigator",
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"severity": "minor",
			"status": "active",
			"summary": "Something happened, we found out something interesting, then we fixed it.",
			"taskList": {
				"doneCount": 8,
				"tasks": [
					{
						"assignedUser": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						},
						"authorUser": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						},
						"createdTime": "2018-01-01T00:00:00Z",
						"immutable": true,
						"modifiedTime": "2018-01-01T00:00:00Z",
						"status": "todo",
						"taskID": "task-123456",
						"text": "Assign an investigator"
					},
					{
						"assignedUser": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						},
						"authorUser": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						},
						"createdTime": "2018-01-01T00:00:00Z",
						"immutable": true,
						"modifiedTime": "2018-01-01T00:00:00Z",
						"status": "todo",
						"taskID": "task-123456",
						"text": "Assign an investigator"
					}
				],
				"todoCount": 5
			},
			"title": "high latency in web requests"
		},
		{
			"closedTime": "2021-08-07T11:58:23Z",
			"createdByUser": {
				"name": "Morty Smith",
				"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
				"userID": "user-123"
			},
			"createdTime": "2021-08-07T11:58:23Z",
			"durationSeconds": 60,
			"heroImagePath": "/relative/path/to/hero/image.png",
			"incidentEnd": "2022-02-11 00:50:20.574137",
			"incidentID": "incident-123",
			"incidentMembership": {
				"assignments": [
					{
						"role": {
							"archived": true,
							"createdAt": "2020-01-01T00:00:00Z",
							"description": "The commander is the incident commander.",
							"important": true,
							"mandatory": true,
							"name": "commander",
							"orgID": "org-1",
							"roleID": 1,
							"updatedAt": "2020-01-01T00:00:00Z"
						},
						"user": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						}
					},
					{
						"role": {
							"archived": true,
							"createdAt": "2020-01-01T00:00:00Z",
							"description": "The commander is the incident commander.",
							"important": true,
							"mandatory": true,
							"name": "commander",
							"orgID": "org-1",
							"roleID": 1,
							"updatedAt": "2020-01-01T00:00:00Z"
						},
						"user": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						}
					}
				],
				"totalAssignments": 5,
				"totalParticipants": 3
			},
			"incidentStart": "2022-02-11 00:50:20.574137",
			"isDrill": true,
			"labels": [
				{
					"colorHex": "#ff0000",
					"description": "Customers are affected by this incident.",
					"label": "customers-affected"
				},
				{
					"colorHex": "#ff0000",
					"description": "Customers are affected by this incident.",
					"label": "customers-affected"
				}
			],
			"modifiedTime": "2021-08-07T11:58:23Z",
			"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
			"roles": [
				{
					"description": "Investigator searches for the problem and reports back.",
					"important": true,
					"mandatory": true,
					"maxPeople": 1,
					"role": "investigator",
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"description": "Investigator searches for the problem and reports back.",
					"important": true,
					"mandatory": true,
					"maxPeople": 1,
					"role": "investigator",
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"severity": "minor",
			"status": "active",
			"summary": "Something happened, we found out something interesting, then we fixed it.",
			"taskList": {
				"doneCount": 8,
				"tasks": [
					{
						"assignedUser": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						},
						"authorUser": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						},
						"createdTime": "2018-01-01T00:00:00Z",
						"immutable": true,
						"modifiedTime": "2018-01-01T00:00:00Z",
						"status": "todo",
						"taskID": "task-123456",
						"text": "Assign an investigator"
					},
					{
						"assignedUser": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						},
						"authorUser": {
							"name": "Morty Smith",
							"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
							"userID": "user-123"
						},
						"createdTime": "2018-01-01T00:00:00Z",
						"immutable": true,
						"modifiedTime": "2018-01-01T00:00:00Z",
						"status": "todo",
						"taskID": "task-123456",
						"text": "Assign an investigator"
					}
				],
				"todoCount": 5
			},
			"title": "high latency in web requests"
		}
	],
	"query": {
		"dateFrom": "2021-01-01T02:07:14+00:00",
		"dateTo": "2021-01-01T02:07:14+00:00",
		"excludeStatuses": [
			"closed"
		],
		"incidentLabels": [
			"security",
			"customersaffected"
		],
		"includeStatuses": [
			"active"
		],
		"limit": 10,
		"onlyDrills": true,
		"orderDirection": "ASC",
		"queryString": "isdrill:false any(label:security label:important)",
		"severity": "major"
	}
}

RemoveLabel

RemoveLabel removes a label from the Incident.

RemoveLabelRequest

  • incidentID - string - IncidentID is the identifier of the Incident.
  • label - string - Label is the label to remove from the Incident.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.RemoveLabel" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123",
	"label": "customers-affected"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	removeLabelResp, err := incidentsService.RemoveLabel(ctx, main.RemoveLabelRequest{
		IncidentID: "incident-123",
		Label: "customers-affected",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incident: %+v\n", removeLabelResp.Incident)
	log.Printf("Error: %+v\n", removeLabelResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.RemoveLabel
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123",
	"label": "customers-affected"
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// RemoveLabel removes a label from the Incident.
const incidentsServiceResp = await incidentsService.removeLabel({
	"incidentID": "incident-123",
	"label": "customers-affected"
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incident", incidentsServiceResp.data.incident});

RemoveLabelResponse

A 200 response with an empty error field indicates that the request was successful.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incident": {
		"closedTime": "2021-08-07T11:58:23Z",
		"createdByUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2021-08-07T11:58:23Z",
		"durationSeconds": 60,
		"heroImagePath": "/relative/path/to/hero/image.png",
		"incidentEnd": "2022-02-11 00:50:20.574137",
		"incidentID": "incident-123",
		"incidentMembership": {
			"assignments": [
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"totalAssignments": 5,
			"totalParticipants": 3
		},
		"incidentStart": "2022-02-11 00:50:20.574137",
		"isDrill": true,
		"labels": [
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			},
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			}
		],
		"modifiedTime": "2021-08-07T11:58:23Z",
		"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
		"roles": [
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			},
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			}
		],
		"severity": "minor",
		"status": "active",
		"summary": "Something happened, we found out something interesting, then we fixed it.",
		"taskList": {
			"doneCount": 8,
			"tasks": [
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				},
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				}
			],
			"todoCount": 5
		},
		"title": "high latency in web requests"
	}
}

UnassignRole

UnassignRole removes a role assignment from a user.

UnassignRoleRequest

  • incidentID - string - IncidentID is the identifier.
  • userID - string - UserID is the identifier of the person to assign the role to.
  • role - string - options: "commander" "investigator" "observer" - Role is the role of this person.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UnassignRole" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123",
	"role": "commander",
	"userID": "grafana-incident:user-123"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	unassignRoleResp, err := incidentsService.UnassignRole(ctx, main.UnassignRoleRequest{
		IncidentID: "incident-123",
		UserID: "grafana-incident:user-123",
		Role: "commander",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incident: %+v\n", unassignRoleResp.Incident)
	log.Printf("DidChange: %+v\n", unassignRoleResp.DidChange)
	log.Printf("Error: %+v\n", unassignRoleResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UnassignRole
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123",
	"role": "commander",
	"userID": "grafana-incident:user-123"
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// UnassignRole removes a role assignment from a user.
const incidentsServiceResp = await incidentsService.unassignRole({
	"incidentID": "incident-123",
	"role": "commander",
	"userID": "grafana-incident:user-123"
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incident", incidentsServiceResp.data.incident});
console.info({"didChange", incidentsServiceResp.data.didChange});

UnassignRoleResponse

A 200 response with an empty error field indicates that the request was successful.

  • incident - Incident - Incident is the Incident that was just updated.
  • didChange - boolean - DidChange indicates if the role was changed or not. If the role was not assigned, this will be false.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"didChange": true,
	"error": "something went wrong",
	"incident": {
		"closedTime": "2021-08-07T11:58:23Z",
		"createdByUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2021-08-07T11:58:23Z",
		"durationSeconds": 60,
		"heroImagePath": "/relative/path/to/hero/image.png",
		"incidentEnd": "2022-02-11 00:50:20.574137",
		"incidentID": "incident-123",
		"incidentMembership": {
			"assignments": [
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"totalAssignments": 5,
			"totalParticipants": 3
		},
		"incidentStart": "2022-02-11 00:50:20.574137",
		"isDrill": true,
		"labels": [
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			},
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			}
		],
		"modifiedTime": "2021-08-07T11:58:23Z",
		"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
		"roles": [
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			},
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			}
		],
		"severity": "minor",
		"status": "active",
		"summary": "Something happened, we found out something interesting, then we fixed it.",
		"taskList": {
			"doneCount": 8,
			"tasks": [
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				},
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				}
			],
			"todoCount": 5
		},
		"title": "high latency in web requests"
	}
}

UpdateIncidentEventTime

UpdateIncidentEventTime updates the start or end times of an Incident.

UpdateIncidentEventTimeRequest

  • incidentID - string - IncidentID is the identifier of the Incident.
  • eventTime - string - EventTime is the new time for the start or end of the incident. The string value format should follow RFC 3339.
  • activityItemKind - string - options: "incidentEnd" "incidentStart" - ActivityItemKind is either the start or end of the incident.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UpdateIncidentEventTime" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"activityItemKind": "incidentEnd",
	"eventTime": "2022-02-11 00:50:20.574137",
	"incidentID": "1"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	updateIncidentEventTimeResp, err := incidentsService.UpdateIncidentEventTime(ctx, main.UpdateIncidentEventTimeRequest{
		IncidentID: "1",
		EventTime: "2022-02-11 00:50:20.574137",
		ActivityItemKind: "incidentEnd",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Error: %+v\n", updateIncidentEventTimeResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UpdateIncidentEventTime
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"activityItemKind": "incidentEnd",
	"eventTime": "2022-02-11 00:50:20.574137",
	"incidentID": "1"
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient('https://your-stack.grafana.net', serviceAccountToken);
const incidentsService = new IncidentsService(client);

// UpdateIncidentEventTime updates the start or end times of an Incident.
const incidentsServiceResp = await incidentsService.updateIncidentEventTime({
  activityItemKind: 'incidentEnd',
  eventTime: '2022-02-11 00:50:20.574137',
  incidentID: '1',
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response

UpdateIncidentEventTimeResponse

A 200 response with an empty error field indicates that the request was successful.

  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong"
}

UpdateIncidentIsDrill

UpdateIncidentIsDrill changes whether an Incident is a drill or not.

UpdateIncidentIsDrillRequest

  • incidentID - string - IncidentID is the identifier of the Incident.
  • isDrill - boolean - IsDrill indicates whether the Incident is a drill or not.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UpdateIncidentIsDrill" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123",
	"isDrill": true
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	updateIncidentIsDrillResp, err := incidentsService.UpdateIncidentIsDrill(ctx, main.UpdateIncidentIsDrillRequest{
		IncidentID: "incident-123",
		IsDrill: true,
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incident: %+v\n", updateIncidentIsDrillResp.Incident)
	log.Printf("Error: %+v\n", updateIncidentIsDrillResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UpdateIncidentIsDrill
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123",
	"isDrill": true
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// UpdateIncidentIsDrill changes whether an Incident is a drill or not.
const incidentsServiceResp = await incidentsService.updateIncidentIsDrill({
	"incidentID": "incident-123",
	"isDrill": true
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incident", incidentsServiceResp.data.incident});

UpdateIncidentIsDrillResponse

A 200 response with an empty error field indicates that the request was successful.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incident": {
		"closedTime": "2021-08-07T11:58:23Z",
		"createdByUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2021-08-07T11:58:23Z",
		"durationSeconds": 60,
		"heroImagePath": "/relative/path/to/hero/image.png",
		"incidentEnd": "2022-02-11 00:50:20.574137",
		"incidentID": "incident-123",
		"incidentMembership": {
			"assignments": [
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"totalAssignments": 5,
			"totalParticipants": 3
		},
		"incidentStart": "2022-02-11 00:50:20.574137",
		"isDrill": true,
		"labels": [
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			},
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			}
		],
		"modifiedTime": "2021-08-07T11:58:23Z",
		"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
		"roles": [
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			},
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			}
		],
		"severity": "minor",
		"status": "active",
		"summary": "Something happened, we found out something interesting, then we fixed it.",
		"taskList": {
			"doneCount": 8,
			"tasks": [
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				},
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				}
			],
			"todoCount": 5
		},
		"title": "high latency in web requests"
	}
}

UpdateSeverity

UpdateSeverity updates the severity of an Incident.

UpdateSeverityRequest

  • incidentID - string - IncidentID is the identifier of the Incident.
  • severity - string - options: "pending" "minor" "major" "critical" - Severity expresses how bad the Incident is.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UpdateSeverity" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123",
	"severity": "minor"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	updateSeverityResp, err := incidentsService.UpdateSeverity(ctx, main.UpdateSeverityRequest{
		IncidentID: "incident-123",
		Severity: "minor",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incident: %+v\n", updateSeverityResp.Incident)
	log.Printf("Error: %+v\n", updateSeverityResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UpdateSeverity
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123",
	"severity": "minor"
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// UpdateSeverity updates the severity of an Incident.
const incidentsServiceResp = await incidentsService.updateSeverity({
	"incidentID": "incident-123",
	"severity": "minor"
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incident", incidentsServiceResp.data.incident});

UpdateSeverityResponse

A 200 response with an empty error field indicates that the request was successful.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incident": {
		"closedTime": "2021-08-07T11:58:23Z",
		"createdByUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2021-08-07T11:58:23Z",
		"durationSeconds": 60,
		"heroImagePath": "/relative/path/to/hero/image.png",
		"incidentEnd": "2022-02-11 00:50:20.574137",
		"incidentID": "incident-123",
		"incidentMembership": {
			"assignments": [
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"totalAssignments": 5,
			"totalParticipants": 3
		},
		"incidentStart": "2022-02-11 00:50:20.574137",
		"isDrill": true,
		"labels": [
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			},
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			}
		],
		"modifiedTime": "2021-08-07T11:58:23Z",
		"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
		"roles": [
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			},
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			}
		],
		"severity": "minor",
		"status": "active",
		"summary": "Something happened, we found out something interesting, then we fixed it.",
		"taskList": {
			"doneCount": 8,
			"tasks": [
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				},
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				}
			],
			"todoCount": 5
		},
		"title": "high latency in web requests"
	}
}

UpdateStatus

UpdateStatus updates the status of an Incident.

UpdateStatusRequest

  • incidentID - string - IncidentID is the identifier of the Incident.
  • status - string - options: "active" "resolved" - Status is the new status of the Incident.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UpdateStatus" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123",
	"status": "resolved"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	updateStatusResp, err := incidentsService.UpdateStatus(ctx, main.UpdateStatusRequest{
		IncidentID: "incident-123",
		Status: "resolved",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incident: %+v\n", updateStatusResp.Incident)
	log.Printf("Error: %+v\n", updateStatusResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UpdateStatus
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123",
	"status": "resolved"
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// UpdateStatus updates the status of an Incident.
const incidentsServiceResp = await incidentsService.updateStatus({
	"incidentID": "incident-123",
	"status": "resolved"
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incident", incidentsServiceResp.data.incident});

UpdateStatusResponse

A 200 response with an empty error field indicates that the request was successful.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incident": {
		"closedTime": "2021-08-07T11:58:23Z",
		"createdByUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2021-08-07T11:58:23Z",
		"durationSeconds": 60,
		"heroImagePath": "/relative/path/to/hero/image.png",
		"incidentEnd": "2022-02-11 00:50:20.574137",
		"incidentID": "incident-123",
		"incidentMembership": {
			"assignments": [
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"totalAssignments": 5,
			"totalParticipants": 3
		},
		"incidentStart": "2022-02-11 00:50:20.574137",
		"isDrill": true,
		"labels": [
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			},
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			}
		],
		"modifiedTime": "2021-08-07T11:58:23Z",
		"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
		"roles": [
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			},
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			}
		],
		"severity": "minor",
		"status": "active",
		"summary": "Something happened, we found out something interesting, then we fixed it.",
		"taskList": {
			"doneCount": 8,
			"tasks": [
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				},
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				}
			],
			"todoCount": 5
		},
		"title": "high latency in web requests"
	}
}

UpdateTitle

UpdateTitle updates the title of an Incident.

UpdateTitleRequest

  • incidentID - string - IncidentID is the identifier of the Incident.
  • title - string - Title is the new title of the Incident.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UpdateTitle" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123",
	"title": "High latency in web requests"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	updateTitleResp, err := incidentsService.UpdateTitle(ctx, main.UpdateTitleRequest{
		IncidentID: "incident-123",
		Title: "High latency in web requests",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Incident: %+v\n", updateTitleResp.Incident)
	log.Printf("Error: %+v\n", updateTitleResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/IncidentsService.UpdateTitle
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123",
	"title": "High latency in web requests"
}
JavaScript
import { GrafanaIncidentClient, IncidentsService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const incidentsService = new IncidentsService(client);

// UpdateTitle updates the title of an Incident.
const incidentsServiceResp = await incidentsService.updateTitle({
	"incidentID": "incident-123",
	"title": "High latency in web requests"
});

if (!incidentsServiceResp.success) {
  // handle the error
  throw new Error(incidentsServiceResp.error);
}

// access the fields of the response
console.info({"incident", incidentsServiceResp.data.incident});

UpdateTitleResponse

A 200 response with an empty error field indicates that the request was successful.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incident": {
		"closedTime": "2021-08-07T11:58:23Z",
		"createdByUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2021-08-07T11:58:23Z",
		"durationSeconds": 60,
		"heroImagePath": "/relative/path/to/hero/image.png",
		"incidentEnd": "2022-02-11 00:50:20.574137",
		"incidentID": "incident-123",
		"incidentMembership": {
			"assignments": [
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				},
				{
					"role": {
						"archived": true,
						"createdAt": "2020-01-01T00:00:00Z",
						"description": "The commander is the incident commander.",
						"important": true,
						"mandatory": true,
						"name": "commander",
						"orgID": "org-1",
						"roleID": 1,
						"updatedAt": "2020-01-01T00:00:00Z"
					},
					"user": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					}
				}
			],
			"totalAssignments": 5,
			"totalParticipants": 3
		},
		"incidentStart": "2022-02-11 00:50:20.574137",
		"isDrill": true,
		"labels": [
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			},
			{
				"colorHex": "#ff0000",
				"description": "Customers are affected by this incident.",
				"label": "customers-affected"
			}
		],
		"modifiedTime": "2021-08-07T11:58:23Z",
		"overviewURL": "/a/grafana-incident-app/incidents/incident-123/title",
		"roles": [
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			},
			{
				"description": "Investigator searches for the problem and reports back.",
				"important": true,
				"mandatory": true,
				"maxPeople": 1,
				"role": "investigator",
				"user": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				}
			}
		],
		"severity": "minor",
		"status": "active",
		"summary": "Something happened, we found out something interesting, then we fixed it.",
		"taskList": {
			"doneCount": 8,
			"tasks": [
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				},
				{
					"assignedUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"authorUser": {
						"name": "Morty Smith",
						"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
						"userID": "user-123"
					},
					"createdTime": "2018-01-01T00:00:00Z",
					"immutable": true,
					"modifiedTime": "2018-01-01T00:00:00Z",
					"status": "todo",
					"taskID": "task-123456",
					"text": "Assign an investigator"
				}
			],
			"todoCount": 5
		},
		"title": "high latency in web requests"
	}
}

RolesService

RolesService defines the interface for interacting with roles, providing CRUD operations and more fatures related to roles.

ArchiveRole

ArchiveRole archives a role.

ArchiveRoleRequest

  • roleID - number - Role to be archived to the organization
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.ArchiveRole" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"roleID": 1
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	rolesService := incident.NewRolesService(client)
	// make the request...
	archiveRoleResp, err := rolesService.ArchiveRole(ctx, main.ArchiveRoleRequest{
		RoleID: 1,
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Error: %+v\n", archiveRoleResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.ArchiveRole
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"roleID": 1
}
JavaScript
import { GrafanaIncidentClient, RolesService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient('https://your-stack.grafana.net', serviceAccountToken);
const rolesService = new RolesService(client);

// ArchiveRole archives a role.
const rolesServiceResp = await rolesService.archiveRole({
  roleID: 1,
});

if (!rolesServiceResp.success) {
  // handle the error
  throw new Error(rolesServiceResp.error);
}

// access the fields of the response

ArchiveRoleResponse

A 200 response with an empty error field indicates that the request was successful.

  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong"
}

CreateRole

CreateRole creates a role.

CreateRoleRequest

  • role - Role - Role to be created to the organization
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.CreateRole" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"role": {
		"archived": true,
		"createdAt": "2020-01-01T00:00:00Z",
		"description": "The commander is the incident commander.",
		"important": true,
		"mandatory": true,
		"name": "commander",
		"orgID": "org-1",
		"roleID": 1,
		"updatedAt": "2020-01-01T00:00:00Z"
	}
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	rolesService := incident.NewRolesService(client)
	// make the request...
	createRoleResp, err := rolesService.CreateRole(ctx, main.CreateRoleRequest{
		Role: main.Role{
			RoleID: 1,
			OrgID: "org-1",
			Name: "commander",
			Description: "The commander is the incident commander.",
			Important: true,
			Mandatory: true,
			Archived: true,
			CreatedAt: "2020-01-01T00:00:00Z",
			UpdatedAt: "2020-01-01T00:00:00Z",
		},
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Role: %+v\n", createRoleResp.Role)
	log.Printf("Error: %+v\n", createRoleResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.CreateRole
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"role": {
		"archived": true,
		"createdAt": "2020-01-01T00:00:00Z",
		"description": "The commander is the incident commander.",
		"important": true,
		"mandatory": true,
		"name": "commander",
		"orgID": "org-1",
		"roleID": 1,
		"updatedAt": "2020-01-01T00:00:00Z"
	}
}
JavaScript
import { GrafanaIncidentClient, RolesService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const rolesService = new RolesService(client);

// CreateRole creates a role.
const rolesServiceResp = await rolesService.createRole({
	"role": {
		"archived": true,
		"createdAt": "2020-01-01T00:00:00Z",
		"description": "The commander is the incident commander.",
		"important": true,
		"mandatory": true,
		"name": "commander",
		"orgID": "org-1",
		"roleID": 1,
		"updatedAt": "2020-01-01T00:00:00Z"
	}
});

if (!rolesServiceResp.success) {
  // handle the error
  throw new Error(rolesServiceResp.error);
}

// access the fields of the response
console.info({"role", rolesServiceResp.data.role});

CreateRoleResponse

A 200 response with an empty error field indicates that the request was successful.

  • role - Role - Role is the newly created role.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"role": {
		"archived": true,
		"createdAt": "2020-01-01T00:00:00Z",
		"description": "The commander is the incident commander.",
		"important": true,
		"mandatory": true,
		"name": "commander",
		"orgID": "org-1",
		"roleID": 1,
		"updatedAt": "2020-01-01T00:00:00Z"
	}
}

DeleteRole

DeleteRole deletes a role.

DeleteRoleRequest

  • roleID - number - Role to be deleted to the organization
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.DeleteRole" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"roleID": 1
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	rolesService := incident.NewRolesService(client)
	// make the request...
	deleteRoleResp, err := rolesService.DeleteRole(ctx, main.DeleteRoleRequest{
		RoleID: 1,
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Error: %+v\n", deleteRoleResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.DeleteRole
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"roleID": 1
}
JavaScript
import { GrafanaIncidentClient, RolesService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient('https://your-stack.grafana.net', serviceAccountToken);
const rolesService = new RolesService(client);

// DeleteRole deletes a role.
const rolesServiceResp = await rolesService.deleteRole({
  roleID: 1,
});

if (!rolesServiceResp.success) {
  // handle the error
  throw new Error(rolesServiceResp.error);
}

// access the fields of the response

DeleteRoleResponse

A 200 response with an empty error field indicates that the request was successful.

  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong"
}

GetRoles

GetRoles gets all roles.

GetRolesRequest

  • No fields
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.GetRoles" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	rolesService := incident.NewRolesService(client)
	// make the request...
	getRolesResp, err := rolesService.GetRoles(ctx, main.GetRolesRequest{
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Roles: %+v\n", getRolesResp.Roles)
	log.Printf("Error: %+v\n", getRolesResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.GetRoles
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{}
JavaScript
import { GrafanaIncidentClient, RolesService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const rolesService = new RolesService(client);

// GetRoles gets all roles.
const rolesServiceResp = await rolesService.getRoles({});

if (!rolesServiceResp.success) {
  // handle the error
  throw new Error(rolesServiceResp.error);
}

// access the fields of the response
console.info({"roles", rolesServiceResp.data.roles});

GetRolesResponse

A 200 response with an empty error field indicates that the request was successful.

  • roles - array of Role - Roles is the list of roles.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"roles": [
		{
			"archived": true,
			"createdAt": "2020-01-01T00:00:00Z",
			"description": "The commander is the incident commander.",
			"important": true,
			"mandatory": true,
			"name": "commander",
			"orgID": "org-1",
			"roleID": 1,
			"updatedAt": "2020-01-01T00:00:00Z"
		},
		{
			"archived": true,
			"createdAt": "2020-01-01T00:00:00Z",
			"description": "The commander is the incident commander.",
			"important": true,
			"mandatory": true,
			"name": "commander",
			"orgID": "org-1",
			"roleID": 1,
			"updatedAt": "2020-01-01T00:00:00Z"
		}
	]
}

UnarchiveRole

UnarchiveRole unarchives a role.

UnarchiveRoleRequest

  • roleID - number - Role to be unarchived to the organization
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.UnarchiveRole" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"roleID": 1
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	rolesService := incident.NewRolesService(client)
	// make the request...
	unarchiveRoleResp, err := rolesService.UnarchiveRole(ctx, main.UnarchiveRoleRequest{
		RoleID: 1,
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Error: %+v\n", unarchiveRoleResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.UnarchiveRole
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"roleID": 1
}
JavaScript
import { GrafanaIncidentClient, RolesService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient('https://your-stack.grafana.net', serviceAccountToken);
const rolesService = new RolesService(client);

// UnarchiveRole unarchives a role.
const rolesServiceResp = await rolesService.unarchiveRole({
  roleID: 1,
});

if (!rolesServiceResp.success) {
  // handle the error
  throw new Error(rolesServiceResp.error);
}

// access the fields of the response

UnarchiveRoleResponse

A 200 response with an empty error field indicates that the request was successful.

  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong"
}

UpdateRole

UpdateRole updates a role.

UpdateRoleRequest

  • role - Role - Role to be updated to the organization
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.UpdateRole" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"role": {
		"archived": true,
		"createdAt": "2020-01-01T00:00:00Z",
		"description": "The commander is the incident commander.",
		"important": true,
		"mandatory": true,
		"name": "commander",
		"orgID": "org-1",
		"roleID": 1,
		"updatedAt": "2020-01-01T00:00:00Z"
	}
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	rolesService := incident.NewRolesService(client)
	// make the request...
	updateRoleResp, err := rolesService.UpdateRole(ctx, main.UpdateRoleRequest{
		Role: main.Role{
			RoleID: 1,
			OrgID: "org-1",
			Name: "commander",
			Description: "The commander is the incident commander.",
			Important: true,
			Mandatory: true,
			Archived: true,
			CreatedAt: "2020-01-01T00:00:00Z",
			UpdatedAt: "2020-01-01T00:00:00Z",
		},
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("Role: %+v\n", updateRoleResp.Role)
	log.Printf("Error: %+v\n", updateRoleResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/RolesService.UpdateRole
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"role": {
		"archived": true,
		"createdAt": "2020-01-01T00:00:00Z",
		"description": "The commander is the incident commander.",
		"important": true,
		"mandatory": true,
		"name": "commander",
		"orgID": "org-1",
		"roleID": 1,
		"updatedAt": "2020-01-01T00:00:00Z"
	}
}
JavaScript
import { GrafanaIncidentClient, RolesService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const rolesService = new RolesService(client);

// UpdateRole updates a role.
const rolesServiceResp = await rolesService.updateRole({
	"role": {
		"archived": true,
		"createdAt": "2020-01-01T00:00:00Z",
		"description": "The commander is the incident commander.",
		"important": true,
		"mandatory": true,
		"name": "commander",
		"orgID": "org-1",
		"roleID": 1,
		"updatedAt": "2020-01-01T00:00:00Z"
	}
});

if (!rolesServiceResp.success) {
  // handle the error
  throw new Error(rolesServiceResp.error);
}

// access the fields of the response
console.info({"role", rolesServiceResp.data.role});

UpdateRoleResponse

A 200 response with an empty error field indicates that the request was successful.

  • role - Role - Role is the newly updated role.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"role": {
		"archived": true,
		"createdAt": "2020-01-01T00:00:00Z",
		"description": "The commander is the incident commander.",
		"important": true,
		"mandatory": true,
		"name": "commander",
		"orgID": "org-1",
		"roleID": 1,
		"updatedAt": "2020-01-01T00:00:00Z"
	}
}

TasksService

TasksService provides methods for managing tasks relating to Incidents.

  • AddTask - AddTask adds a task to an Incident.
  • DeleteTask - DeleteTask deletes a task.
  • UpdateTaskStatus - UpdateTaskStatus updates the task's Status.
  • UpdateTaskText - UpdateTaskText updates the task's text.
  • UpdateTaskUser - UpdateTaskUser updates the task's assigned user. Passing an empty user ID will clear the assigned user.

AddTask

AddTask adds a task to an Incident.

AddTaskRequest

  • incidentID - string - IncidentID is the ID of the Incident to add the Task to.
  • text - string - Text is the todo item.
  • assignToUserID - string - AssignToUserId is the user the task wil be assigned to
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/TasksService.AddTask" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"assignToUserID": "User123",
	"incidentID": "incident-123456",
	"text": "Assign an investigator"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	tasksService := incident.NewTasksService(client)
	// make the request...
	addTaskResp, err := tasksService.AddTask(ctx, main.AddTaskRequest{
		IncidentID: "incident-123456",
		Text: "Assign an investigator",
		AssignToUserId: "User123",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("IncidentID: %+v\n", addTaskResp.IncidentID)
	log.Printf("Task: %+v\n", addTaskResp.Task)
	log.Printf("TaskList: %+v\n", addTaskResp.TaskList)
	log.Printf("Error: %+v\n", addTaskResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/TasksService.AddTask
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"assignToUserID": "User123",
	"incidentID": "incident-123456",
	"text": "Assign an investigator"
}
JavaScript
import { GrafanaIncidentClient, TasksService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const tasksService = new TasksService(client);

// AddTask adds a task to an Incident.
const tasksServiceResp = await tasksService.addTask({
	"assignToUserID": "User123",
	"incidentID": "incident-123456",
	"text": "Assign an investigator"
});

if (!tasksServiceResp.success) {
  // handle the error
  throw new Error(tasksServiceResp.error);
}

// access the fields of the response
console.info({"incidentID", tasksServiceResp.data.incidentID});
console.info({"task", tasksServiceResp.data.task});
console.info({"taskList", tasksServiceResp.data.taskList});

AddTaskResponse

A 200 response with an empty error field indicates that the request was successful.

  • incidentID - string - IncidentID is the ID of the incident these tasks relate to.
  • task - Task - Task is the newly added Task. It will also appear in Tasks.
  • taskList - TaskList - TaskList is the tasks list.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incidentID": "incident-123456",
	"task": {
		"assignedUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"authorUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2018-01-01T00:00:00Z",
		"immutable": true,
		"modifiedTime": "2018-01-01T00:00:00Z",
		"status": "todo",
		"taskID": "task-123456",
		"text": "Assign an investigator"
	},
	"taskList": {
		"doneCount": 8,
		"tasks": [
			{
				"assignedUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"authorUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"createdTime": "2018-01-01T00:00:00Z",
				"immutable": true,
				"modifiedTime": "2018-01-01T00:00:00Z",
				"status": "todo",
				"taskID": "task-123456",
				"text": "Assign an investigator"
			},
			{
				"assignedUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"authorUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"createdTime": "2018-01-01T00:00:00Z",
				"immutable": true,
				"modifiedTime": "2018-01-01T00:00:00Z",
				"status": "todo",
				"taskID": "task-123456",
				"text": "Assign an investigator"
			}
		],
		"todoCount": 5
	}
}

DeleteTask

DeleteTask deletes a task.

DeleteTaskRequest

  • incidentID - string - IncidentID is the ID of the Incident.
  • taskID - string - TaskID is the ID of the task.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/TasksService.DeleteTask" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "inccident-123456",
	"taskID": "task-123456"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	tasksService := incident.NewTasksService(client)
	// make the request...
	deleteTaskResp, err := tasksService.DeleteTask(ctx, main.DeleteTaskRequest{
		IncidentID: "inccident-123456",
		TaskID: "task-123456",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("IncidentID: %+v\n", deleteTaskResp.IncidentID)
	log.Printf("TaskList: %+v\n", deleteTaskResp.TaskList)
	log.Printf("Error: %+v\n", deleteTaskResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/TasksService.DeleteTask
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "inccident-123456",
	"taskID": "task-123456"
}
JavaScript
import { GrafanaIncidentClient, TasksService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const tasksService = new TasksService(client);

// DeleteTask deletes a task.
const tasksServiceResp = await tasksService.deleteTask({
	"incidentID": "inccident-123456",
	"taskID": "task-123456"
});

if (!tasksServiceResp.success) {
  // handle the error
  throw new Error(tasksServiceResp.error);
}

// access the fields of the response
console.info({"incidentID", tasksServiceResp.data.incidentID});
console.info({"taskList", tasksServiceResp.data.taskList});

DeleteTaskResponse

A 200 response with an empty error field indicates that the request was successful.

  • incidentID - string - IncidentID is the ID of the incident these tasks relate to.
  • taskList - TaskList - TaskList is the tasks list.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incidentID": "incident-123456",
	"taskList": {
		"doneCount": 8,
		"tasks": [
			{
				"assignedUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"authorUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"createdTime": "2018-01-01T00:00:00Z",
				"immutable": true,
				"modifiedTime": "2018-01-01T00:00:00Z",
				"status": "todo",
				"taskID": "task-123456",
				"text": "Assign an investigator"
			},
			{
				"assignedUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"authorUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"createdTime": "2018-01-01T00:00:00Z",
				"immutable": true,
				"modifiedTime": "2018-01-01T00:00:00Z",
				"status": "todo",
				"taskID": "task-123456",
				"text": "Assign an investigator"
			}
		],
		"todoCount": 5
	}
}

UpdateTaskStatus

UpdateTaskStatus updates the task's Status.

UpdateTaskStatusRequest

  • incidentID - string - IncidentID is the ID of the Incident to add the Task to.
  • taskID - string - TaskID is the ID of the Task to update.
  • status - string - options: "todo" "progress" "done" - Status is the new status of this task.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/TasksService.UpdateTaskStatus" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123456",
	"status": "todo",
	"taskID": "task-12345"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	tasksService := incident.NewTasksService(client)
	// make the request...
	updateTaskStatusResp, err := tasksService.UpdateTaskStatus(ctx, main.UpdateTaskStatusRequest{
		IncidentID: "incident-123456",
		TaskID: "task-12345",
		Status: "todo",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("IncidentID: %+v\n", updateTaskStatusResp.IncidentID)
	log.Printf("Task: %+v\n", updateTaskStatusResp.Task)
	log.Printf("TaskList: %+v\n", updateTaskStatusResp.TaskList)
	log.Printf("Error: %+v\n", updateTaskStatusResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/TasksService.UpdateTaskStatus
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123456",
	"status": "todo",
	"taskID": "task-12345"
}
JavaScript
import { GrafanaIncidentClient, TasksService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const tasksService = new TasksService(client);

// UpdateTaskStatus updates the task's Status.
const tasksServiceResp = await tasksService.updateTaskStatus({
	"incidentID": "incident-123456",
	"status": "todo",
	"taskID": "task-12345"
});

if (!tasksServiceResp.success) {
  // handle the error
  throw new Error(tasksServiceResp.error);
}

// access the fields of the response
console.info({"incidentID", tasksServiceResp.data.incidentID});
console.info({"task", tasksServiceResp.data.task});
console.info({"taskList", tasksServiceResp.data.taskList});

UpdateTaskStatusResponse

A 200 response with an empty error field indicates that the request was successful.

  • incidentID - string - IncidentID is the ID of the incident these tasks relate to.
  • task - Task - Task is the newly added Task. It will also appear in Tasks.
  • taskList - TaskList - TaskList is the tasks list.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incidentID": "incident-123456",
	"task": {
		"assignedUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"authorUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2018-01-01T00:00:00Z",
		"immutable": true,
		"modifiedTime": "2018-01-01T00:00:00Z",
		"status": "todo",
		"taskID": "task-123456",
		"text": "Assign an investigator"
	},
	"taskList": {
		"doneCount": 8,
		"tasks": [
			{
				"assignedUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"authorUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"createdTime": "2018-01-01T00:00:00Z",
				"immutable": true,
				"modifiedTime": "2018-01-01T00:00:00Z",
				"status": "todo",
				"taskID": "task-123456",
				"text": "Assign an investigator"
			},
			{
				"assignedUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"authorUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"createdTime": "2018-01-01T00:00:00Z",
				"immutable": true,
				"modifiedTime": "2018-01-01T00:00:00Z",
				"status": "todo",
				"taskID": "task-123456",
				"text": "Assign an investigator"
			}
		],
		"todoCount": 5
	}
}

UpdateTaskText

UpdateTaskText updates the task's text.

UpdateTaskTextRequest

  • incidentID - string - IncidentID is the ID of the Incident to add the Task to.
  • taskID - string - TaskID is the ID of the task.
  • text - string - Text is the string that describes the Task.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/TasksService.UpdateTaskText" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123456",
	"taskID": "task-123456",
	"text": "Check the logs"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	tasksService := incident.NewTasksService(client)
	// make the request...
	updateTaskTextResp, err := tasksService.UpdateTaskText(ctx, main.UpdateTaskTextRequest{
		IncidentID: "incident-123456",
		TaskID: "task-123456",
		Text: "Check the logs",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("IncidentID: %+v\n", updateTaskTextResp.IncidentID)
	log.Printf("Task: %+v\n", updateTaskTextResp.Task)
	log.Printf("TaskList: %+v\n", updateTaskTextResp.TaskList)
	log.Printf("Error: %+v\n", updateTaskTextResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/TasksService.UpdateTaskText
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123456",
	"taskID": "task-123456",
	"text": "Check the logs"
}
JavaScript
import { GrafanaIncidentClient, TasksService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const tasksService = new TasksService(client);

// UpdateTaskText updates the task's text.
const tasksServiceResp = await tasksService.updateTaskText({
	"incidentID": "incident-123456",
	"taskID": "task-123456",
	"text": "Check the logs"
});

if (!tasksServiceResp.success) {
  // handle the error
  throw new Error(tasksServiceResp.error);
}

// access the fields of the response
console.info({"incidentID", tasksServiceResp.data.incidentID});
console.info({"task", tasksServiceResp.data.task});
console.info({"taskList", tasksServiceResp.data.taskList});

UpdateTaskTextResponse

A 200 response with an empty error field indicates that the request was successful.

  • incidentID - string - IncidentID is the ID of the incident these tasks relate to.
  • task - Task - Task is the newly added Task. It will also appear in Tasks.
  • taskList - TaskList - TaskList is the tasks list.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incidentID": "incident-123456",
	"task": {
		"assignedUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"authorUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2018-01-01T00:00:00Z",
		"immutable": true,
		"modifiedTime": "2018-01-01T00:00:00Z",
		"status": "todo",
		"taskID": "task-123456",
		"text": "Assign an investigator"
	},
	"taskList": {
		"doneCount": 8,
		"tasks": [
			{
				"assignedUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"authorUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"createdTime": "2018-01-01T00:00:00Z",
				"immutable": true,
				"modifiedTime": "2018-01-01T00:00:00Z",
				"status": "todo",
				"taskID": "task-123456",
				"text": "Assign an investigator"
			},
			{
				"assignedUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"authorUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"createdTime": "2018-01-01T00:00:00Z",
				"immutable": true,
				"modifiedTime": "2018-01-01T00:00:00Z",
				"status": "todo",
				"taskID": "task-123456",
				"text": "Assign an investigator"
			}
		],
		"todoCount": 5
	}
}

UpdateTaskUser

UpdateTaskUser updates the task's assigned user. Passing an empty user ID will clear the assigned user.

UpdateTaskUserRequest

  • incidentID - string - IncidentID is the ID of the Incident to add the Task to.
  • taskID - string - TaskID is the ID of the Task to update.
  • userID - string - UserID is the ID of the User to assign to the Task.
curl
curl "https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/TasksService.UpdateTaskUser" \
  --request POST \
  --header 'Content-Type: application/json; charset=utf-8' \
  --header 'Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...' \
  --data '{
	"incidentID": "incident-123456",
	"taskID": "task-12345",
	"userID": "user-id"
}'
Go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	incident "github.com/grafana/incident-go"
)

func main() {
	ctx := context.Background()
	// create a client, and required services...
	serviceAccountToken := os.Getenv("SERVICE_ACCOUNT_TOKEN")
	client := incident.NewClient("https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1", serviceAccountToken)
	tasksService := incident.NewTasksService(client)
	// make the request...
	updateTaskUserResp, err := tasksService.UpdateTaskUser(ctx, main.UpdateTaskUserRequest{
		IncidentID: "incident-123456",
		TaskID: "task-12345",
		UserID: "user-id",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	log.Printf("IncidentID: %+v\n", updateTaskUserResp.IncidentID)
	log.Printf("Task: %+v\n", updateTaskUserResp.Task)
	log.Printf("TaskList: %+v\n", updateTaskUserResp.TaskList)
	log.Printf("Error: %+v\n", updateTaskUserResp.Error)

}
json
POST https://your-stack.grafana.net/api/plugins/grafana-incident-app/resources/api/v1/TasksService.UpdateTaskUser
Content-Type="application/json; charset=utf-8"
Authorization: Bearer glsa_HOruNAb7SOiCdshU9algkrq7F...

{
	"incidentID": "incident-123456",
	"taskID": "task-12345",
	"userID": "user-id"
}
JavaScript
import { GrafanaIncidentClient, TasksService } from '@grafana/incident-node';

// https://grafana.com/docs/grafana-cloud/incident/api/auth/#get-a-service-account-token
const serviceAccountToken = process.env.GRAFANA_CLOUD_SERVICE_ACCOUNT_TOKEN;
const client = new GrafanaIncidentClient(
  "https://your-stack.grafana.net",
  serviceAccountToken
);
const tasksService = new TasksService(client);

// UpdateTaskUser updates the task's assigned user.
Passing an empty user ID will clear the assigned user.
const tasksServiceResp = await tasksService.updateTaskUser({
	"incidentID": "incident-123456",
	"taskID": "task-12345",
	"userID": "user-id"
});

if (!tasksServiceResp.success) {
  // handle the error
  throw new Error(tasksServiceResp.error);
}

// access the fields of the response
console.info({"incidentID", tasksServiceResp.data.incidentID});
console.info({"task", tasksServiceResp.data.task});
console.info({"taskList", tasksServiceResp.data.taskList});

UpdateTaskUserResponse

A 200 response with an empty error field indicates that the request was successful.

  • incidentID - string - IncidentID is the ID of the incident these tasks relate to.
  • task - Task - Task is the newly added Task. It will also appear in Tasks.
  • taskList - TaskList - TaskList is the tasks list.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.
JSON
{
	"error": "something went wrong",
	"incidentID": "incident-123456",
	"task": {
		"assignedUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"authorUser": {
			"name": "Morty Smith",
			"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
			"userID": "user-123"
		},
		"createdTime": "2018-01-01T00:00:00Z",
		"immutable": true,
		"modifiedTime": "2018-01-01T00:00:00Z",
		"status": "todo",
		"taskID": "task-123456",
		"text": "Assign an investigator"
	},
	"taskList": {
		"doneCount": 8,
		"tasks": [
			{
				"assignedUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"authorUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"createdTime": "2018-01-01T00:00:00Z",
				"immutable": true,
				"modifiedTime": "2018-01-01T00:00:00Z",
				"status": "todo",
				"taskID": "task-123456",
				"text": "Assign an investigator"
			},
			{
				"assignedUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"authorUser": {
					"name": "Morty Smith",
					"photoURL": "https://upload.wikimedia.org/wikipedia/en/c/c3/Morty_Smith.png",
					"userID": "user-123"
				},
				"createdTime": "2018-01-01T00:00:00Z",
				"immutable": true,
				"modifiedTime": "2018-01-01T00:00:00Z",
				"status": "todo",
				"taskID": "task-123456",
				"text": "Assign an investigator"
			}
		],
		"todoCount": 5
	}
}

Objects

Various other structures (objects) are described throughtout the API reference, and a complete list of them is included here. They included the various Request and Response pairs for each method.

  • ActivityItem - ActivityItem describes an event that occurred related to an Incident.
  • ActivityQuery - ActivityQuery is the response from the QueryActivity method.
  • Assignment - Relation between a User and a Role inside the incident
  • Attachment - Attachment is a file attached to something.
  • Cursor - Cursor describes the position in a result set. It is passed back into the same API to get the next page of results.
  • GetHomescreenVersionRequest - GetHomescreenVersionRequest is the request for the GetHomescreenVersion method.
  • GetHomescreenVersionResponse - GetHomescreenVersionResponse is the response for the GetHomescreenVersion method.
  • GetIncidentVersionRequest - GetIncidentVersionRequest is the request for the GetIncidentVersion method.
  • GetIncidentVersionResponse - GetIncidentVersionResponse is the response for the GetIncidentVersion method.
  • Incident - Incident is a single incident.
  • IncidentLabel - IncidentLabel is a label associated with an Incident.
  • IncidentMembership - IncidentMembership represents a list of people involved in an Incident.
  • IncidentRole - IncidentRole represents a person involved in an Incident.
  • IncidentsQuery - IncidentsQuery is the query for the QueryIncidentsRequest.
  • IncomingWebhookResponse - IncomingWebhookResponse is the response sent back to the webhook caller when an incoming webhook has been received.
  • OutgoingWebhookPayload - OutgoingWebhookPayload represents the webhook HTTP POST body and contains metadata for the webhook.
  • Role - Role represents a role that will be used to assign people in the incident.
  • Task - Task is an individual task that somebody will do to resolve an Incident.
  • TaskList - TaskList is a list of tasks.
  • UserPreview - UserPreview is a user involved in an Incident.

ActivityItem

ActivityItem describes an event that occurred related to an Incident.

  • activityItemID - string - The unique identifier of the ActivityItem.
  • incidentID - string - IncidentID is the unique identifier of the Incident.
  • user - UserPreview - User is the person who caused the ActivityItem.
  • subjectUser - UserPreview - SubjectUser is the person who was affected by the ActivityItem (not the person who caused it).
  • createdTime - string - CreatedTime is the time when the ActivityItem was created. The string value format should follow RFC 3339.
  • eventTime - string - EventTime is the time when the event occurred. It is configurable by the user. The string value format should follow RFC 3339.
  • activityKind - string - options: "incidentUpdated" "incidentTitleChanged" "incidentStatusChanged" "incidentSeverityChanged" "incidentCreated" "incidentDeleted" "incidentClosed" "roleAssigned" "roleUnassigned" "actionRun" "userNote" "dataQuery" "hookRunMetadata" "taskAdded" "taskUpdated" "taskCompleted" "taskDeleted" "messageReaction" "contextAttached" "incidentIsDrillChanged" "incidentStart" "incidentEnd" "incidentSummary" "labelAdded" "labelRemoved" "siftResult" - ActivityKind is the type of activity this item represents.
  • body - string - Body is a human readable description of the ActivityItem.
  • url - string - URL is an url related with this activity
  • tags - array of string - options: "important" "starred" - Tags contains a list of tags associated with this activity.
  • immutable - boolean - Immutable indicates if the activity is immutable.
  • fieldValues - object - FieldValues is an object of field values associated with the ActivityItem. The structure is determined by the ActivityKind.
  • attachments - array of Attachment - Attachments is a list of files attached to this item.

ActivityQuery

ActivityQuery is the response from the QueryActivity method.

  • incidentID - string - IncidentID is the unique identifier of the Incident.
  • limit - number - Limit is the number of Incidents to return.
  • tag - string - Tag is the tag to filter by.
  • orderDirection - string - options: "ASC" "DESC" - OrderDirection is the direction to order the results.
  • activityKind - array of string - ActivityKind filters by a list of allowed ActivityKind’s.

AddActivityRequest

AddActivityRequest is the request for the AddActivity method.

  • incidentID - string - IncidentID is the unique identifier of the Incident.
  • activityKind - string - options: "userNote" - ActivityKind is the type of activity this item represents.
  • body - string - Body is a human readable description of the ActivityItem. URLs mentioned will be parsed and attached as context.
  • eventTime - string - EventTime is the time when the event occurred. If empty, the current time is used. The string value format should follow RFC 3339.

AddActivityResponse

AddActivityResponse is the response from the AddActivity method.

  • activityItem - ActivityItem - ActivityItem is the newly created ActivityItem.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

AddLabelRequest

AddLabelRequest is the request for the AddLabel method.

  • incidentID - string - IncidentID is the identifier of the Incident.
  • label - IncidentLabel - Label is the new label of the Incident.

AddLabelResponse

AddLabelResponse is the response for the AddLabel method.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

AddTaskRequest

AddTaskRequest is the request for the AddTask method.

  • incidentID - string - IncidentID is the ID of the Incident to add the Task to.
  • text - string - Text is the todo item.
  • assignToUserID - string - AssignToUserId is the user the task wil be assigned to

AddTaskResponse

AddTaskResponse is the response from the AddTask method.

  • incidentID - string - IncidentID is the ID of the incident these tasks relate to.
  • task - Task - Task is the newly added Task. It will also appear in Tasks.
  • taskList - TaskList - TaskList is the tasks list.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

ArchiveRoleRequest

ArchiveRoleRequest is the request to archive a role.

  • roleID - number - Role to be archived to the organization

ArchiveRoleResponse

ArchiveRoleResponse is the response to archive a role.

  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

AssignRoleRequest

AssignRoleRequest is the request for the AssignRole method.

  • incidentID - string - IncidentID is the identifier.
  • userID - string - UserID is the identifier of the person to assign the role to.
  • role - string - options: "commander" "investigator" "observer" - Role is the role of this person.

AssignRoleResponse

AssignRoleResponse is the response for the AssignRole method.

  • incident - Incident - Incident is the Incident that was just updated.
  • didChange - boolean - DidChange indicates if the role was changed or not. If the role was already assigned, this will be false.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

Assignment

Relation between a User and a Role inside the incident

  • user - UserPreview - User is the person who holds this role.
  • role - Role - Role is the role string.

Attachment

Attachment is a file attached to something.

  • attachmentID - string - AttachmentID is the unique ID of this attachment.
  • attachedByUserID - string - AttachedByUserID is the ID of the user who attached this.
  • sourceURL - string - SourceURL is the URL of the file.
  • useSourceURL - boolean - UseSourceURL is true if the file should be downloaded from the source URL.
  • path - string - Path is the full path of the file.
  • uploadTime - string - UploadTime is the time the file was uploaded.
  • deletedTime - string - DeletedTime is the time the file was deleted. Empty string means the file hasn’t been deleted.
  • contentType - string - ContentType is the type of the file.
  • fileType - string - options: "file" "video" "image" "audio" "screenshare" - FileType is the type of file.
  • ext - string - Ext is the file extension.
  • contentLength - number - ContentLength is the ContentLength of the file in bytes.
  • displayType - string - options: "list" "embed" - DisplayType is how the file will be displayed.
  • downloadURL - string - DownloadURL for download
  • hasThumbnail - boolean - HasThumbnail is true if the file has a thumbnail.
  • thumbnailURL - string - ThumbnailURL for previews
  • sHA512 - string - SHA512 is the hash of the file contents.
  • attachmentErr - string - AttachmentErr is a string describing an error that occurred while processing the attachment.

CreateIncidentRequest

CreateIncidentRequest is the request for the CreateIncident method.

  • title - string - Title is the headline title of the Incident. Shorter the better, but should contain enough information to be able to identify and refer to this issue.
  • severity - string - options: "pending" "minor" "major" "critical" - Severity expresses how bad the Incident is.
  • labels - array of IncidentLabel - Labels are the labels associated with the Incident. Only the Label string is processed, the other fields are ignored.
  • roomPrefix - string - RoomPrefix is the prefix that will be used to create the Incident room.
  • isDrill - boolean - IsDrill indicates if the Incident is a drill or not. Incidents that are drills do not show up in the dashboards, and may behave subtly differently in other ways too. For example, during drills, more help might be offered to users.
  • status - string - options: "active" "resolved" - Status is the starting status of the Incident. Use “resolved” to open a retrospective incident.
  • attachCaption - string - AttachCaption is the title of associated URL.
  • attachURL - string - AttachURLis the associated URL.

CreateIncidentResponse

CreateIncidentResponse is the response for the CreateIncident method.

  • incident - Incident - Incident is the Incident that was created.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

CreateRoleRequest

CreateRoleRequest is the request to create a role.

  • role - Role - Role to be created to the organization

CreateRoleResponse

CreateRoleResponse is the response to create a role.

  • role - Role - Role is the newly created role.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

Cursor

Cursor describes the position in a result set. It is passed back into the same API to get the next page of results.

  • nextValue - string - NextValue is the start position of the next set of results. The implementation may change, so clients should not rely on this value.
  • hasMore - boolean - HasMore indicates whether there are more results or not. If HasMore is true, you can make the same request again (except using this Cursor instead) to get the next page of results.

DeleteRoleRequest

DeleteRoleRequest is the request to delete a role.

  • roleID - number - Role to be deleted to the organization

DeleteRoleResponse

DeleteRoleResponse is the response to delete a role.

  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

DeleteTaskRequest

DeleteTaskRequest is the request for the DeleteTask method.

  • incidentID - string - IncidentID is the ID of the Incident.
  • taskID - string - TaskID is the ID of the task.

DeleteTaskResponse

DeleteTaskResponse is the response from the DeleteTask method.

  • incidentID - string - IncidentID is the ID of the incident these tasks relate to.
  • taskList - TaskList - TaskList is the tasks list.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

GetHomescreenVersionRequest

GetHomescreenVersionRequest is the request for the GetHomescreenVersion method.

  • No fields

GetHomescreenVersionResponse

GetHomescreenVersionResponse is the response for the GetHomescreenVersion method.

  • version - number - Version is the refresh value of the home screen. A higher value than last time indicates that the home screen should be refreshed.

GetIncidentMembershipRequest

GetIncidentMembershipRequest is the request for the GetIncidentMembership method.

  • incidentID - string - IncidentID is the identifier of the Incident.

GetIncidentMembershipResponse

GetIncidentMembershipResponse is the response for the GetIncidentMembership method.

  • assignments - array of Assignment - IncidentMembership is the list of people involved in an incident
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

GetIncidentRequest

GetIncidentRequest is the request for the GetIncident method.

  • incidentID - string - IncidentID is the identifier.

GetIncidentResponse

GetIncidentResponse is the response for the GetIncident method.

  • incident - Incident - Incident is the Incident.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

GetIncidentVersionRequest

GetIncidentVersionRequest is the request for the GetIncidentVersion method.

  • incidentID - string - IncidentID is the identifier of the Incident. A higher value than last time indicates that the dashboard should be refreshed.

GetIncidentVersionResponse

GetIncidentVersionResponse is the response for the GetIncidentVersion method.

  • version - number - Version is the refresh value of the Incident.

GetRolesRequest

GetRolesRequest is the request to get all roles.

  • No fields

GetRolesResponse

GetRolesResponse is the response to get all roles.

  • roles - array of Role - Roles is the list of roles.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

Incident

Incident is a single incident.

  • incidentID - string - IncidentID is the identifier.
  • severity - string - options: "pending" "minor" "major" "critical" - Severity expresses how bad the Incident is.
  • labels - array of IncidentLabel - Labels is a list of strings associated with this Incident.
  • isDrill - boolean - IsDrill indicates if the Incident is a drill or not. Incidents that are drills do not show up in the dashboards, and may behave subtly differently in other ways too. For example, during drills, more help might be offered to users.
  • createdTime - string - CreatedTime is when the Incident was created. The string value format should follow RFC 3339.
  • modifiedTime - string - ModifiedTime is when the Incident was last modified. The string value format should follow RFC 3339.
  • createdByUser - UserPreview - CreatedByUser is the UserPreview that created the Incident.
  • closedTime - string - ClosedTime is when the Incident was closed. The string value format should follow RFC 3339.
  • durationSeconds - number - DurationSeconds is the number of seconds this Incident was (or is) open for.
  • status - string - options: "active" "resolved" - Status is the current status of the Incident.
  • title - string - Title is the high level description of the Incident.
  • overviewURL - string - OverviewURL is the URL to the overview page for the Incident.
  • roles - array of IncidentRole - Roles describes the individuals involved in the Incident.
  • incidentMembership - IncidentMembership - Assignments describes the individuals involved in the Incident.
  • taskList - TaskList - TaskList is the list of tasks associated with the Incident.
  • summary - string - Summary is as short recap of the Incident.
  • heroImagePath - string - HeroImagePath is the path to the hero image for this Incident.
  • incidentStart - string - IncidentStart is when the Incident began. The string value format should follow RFC 3339.
  • incidentEnd - string - IncidentEnd is when the Incident ended. The string value format should follow RFC 3339.

IncidentLabel

IncidentLabel is a label associated with an Incident.

  • label - string - Label is the text of the label.
  • description - string - Description is a short explanation of the label.
  • colorHex - string - Color is the CSS hex color of the label. Labels show up in both light and dark modes, and this should be taken into consideration when selecting a color.

IncidentMembership

IncidentMembership represents a list of people involved in an Incident.

  • assignments - array of Assignment - List of all assignments done for that incident
  • totalAssignments - number - Total of assignments including hidden roles in the incident
  • totalParticipants - number - Total of participants in the incident excluding the assigned roles

IncidentRole

IncidentRole represents a person involved in an Incident.

  • role - string - options: "commander" "investigator" "observer" - Role is the unique name that describes the activity of the person.
  • description - string - Description is a short explanation of the role.
  • maxPeople - number - MaxPeople is the maximum number of people that can be assigned to this role. If zero, then there is no limit. Usually it’s 0 or 1.
  • mandatory - boolean - Mandatory indicates if a Role is mandatory or not. Users will be bugged to fill Mandatory roles.
  • important - boolean - ImportantRole indicates if a role is important or not. Users in an important role cannot be assigned to a non-important one.
  • user - UserPreview - User is the person who holds this role.

IncidentsQuery

IncidentsQuery is the query for the QueryIncidentsRequest.

  • limit - number - Limit is the number of Incidents to return.
  • includeStatuses - array of string - options: "active" "resolved" - IncludeStatuses is a list of statuses to include. Only Incidents with the listed statuses will be returned.
  • excludeStatuses - array of string - options: "active" "resolved" - ExcludeStatuses is a list of statuses to exclude. All Incidents that do not match any of these values will be returned.
  • incidentLabels - array of string - IncidentLabels is a list of labels to include. An empty list will not filter by labels.
  • dateFrom - string - DateFrom if is not empty would filter by the Incidents created since that date (time.RFC3339)
  • dateTo - string - DateTo if is not empty would filter by incidents created before that date (time.RFC3339)
  • onlyDrills - boolean - OnlyDrills if is not empty filters by whether an incident is a drill or not.
  • orderDirection - string - options: "ASC" "DESC" - OrderDirection is the direction to order the results.
  • severity - string - Severity is a list of statuses to include. Only Incidents with the listed statuses will be returned.
  • queryString - string - QueryString is the query string to search for. If provided, the query will be filtered by the query string and the other query parameters will be ignored.

IncomingWebhookResponse

IncomingWebhookResponse is the response sent back to the webhook caller when an incoming webhook has been received.

  • incident - *Incident - Incident is the newly declared incident. Only included if the incoming webhook has the include=incident URL parameter.
  • processingErrors - array of string - ProcessingErrors is a list of errors that occurred while processing the webhook. If there are items in this list it does not mean the incident wasn’t created. But you should check to make sure everything was successfully processed before shipping to production.

OutgoingWebhookPayload

OutgoingWebhookPayload represents the webhook HTTP POST body and contains metadata for the webhook.

  • version - string - Version of this structure, following semantic versioning.
  • id - string - ID of event.
  • source - string - Source is a URI that identifies the context in which an event happened.
  • time - string - Time that event was generated (RFC 3339).
  • event - string - Event describes the (namespaced) event
  • incident - *Incident - Incident is the data payload, contains details about the data that was changed.

QueryActivityRequest

QueryActivityRequest is the request for the QueryActivity method.

  • query - ActivityQuery - Query describes the query to make.
  • cursor - Cursor - Cursor is used to page through results. Empty for the first page. For subsequent pages, use previously returned Cursor values.

QueryActivityResponse

QueryActivityResponse is the response from the QueryActivity method.

  • activityItems - array of ActivityItem - ActivityItems is the list of items.
  • query - ActivityQuery - Query is the query that was used to generate the response.
  • cursor - Cursor - Cursor is used to page through results. Empty for the first page. For subsequent pages, use previously returned Cursor values.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

QueryIncidentsRequest

QueryIncidentsRequest is the request for the QueryIncidents method.

  • query - IncidentsQuery - Query describes the query to make.
  • cursor - Cursor - Cursor is used to page through results. Empty for the first page. For subsequent pages, use previously returned Cursor values.

QueryIncidentsResponse

QueryIncidentsResponse is the response for the QueryIncidents method.

  • incidents - array of Incident - Incidents is a list of Incidents.
  • query - IncidentsQuery - Query is the query that was used to generate this response.
  • cursor - Cursor - Cursor should be passed back to get the next page of results.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

RemoveActivityRequest

RemoveActivityRequest is the request for the RemoveActivity method.

  • incidentID - string - IncidentID is the identifier.
  • activityItemID - string - ActivityItemID is the unique identifier of the ActivityItem.

RemoveActivityResponse

RemoveActivityResponse is the response from the RemoveActivity method.

  • activityItem - ActivityItem - ActivityItem is the updated ActivityItem.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

RemoveLabelRequest

RemoveLabelRequest is the request for the RemoveLabel method.

  • incidentID - string - IncidentID is the identifier of the Incident.
  • label - string - Label is the label to remove from the Incident.

RemoveLabelResponse

RemoveLabelResponse is the response for the RemoveLabel method.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

Role

Role represents a role that will be used to assign people in the incident.

  • roleID - number - RoleID is the unique ID of this role.
  • orgID - string - OrgID is the unique ID of the organization this role belongs to.
  • name - string - Name is the name of the role.
  • description - string - Description is the description of the role.
  • important - boolean - Important is whether this role is important.
  • mandatory - boolean - Mandatory is whether this role is mandatory.
  • archived - boolean - Archived is whether this role is archived. Archived roles are not allowed to be assigned to people in the new incidents. But the historical data is still kept.
  • createdAt - string - CreatedAt is the time this role was created at.
  • updatedAt - string - UpdatedAt is the time this role was updated at.

Task

Task is an individual task that somebody will do to resolve an Incident.

  • taskID - string - TaskID is the ID of the task.
  • immutable - boolean - Immutable is true if the task cannot be changed. Used for tasks created and maintained by the system (like role assignment tasks).
  • createdTime - string - CreatedTime is the time the task was created.
  • modifiedTime - string - ModifiedTime is the time
  • text - string - Text is the string that describes the Task.
  • status - string - options: "todo" "progress" "done" - Status os the status of this task.
  • authorUser - *UserPreview - AuthorUser is the person who created this task.
  • assignedUser - *UserPreview - AssignedUser is the person this task is assigned to.

TaskList

TaskList is a list of tasks.

  • tasks - array of Task - Tasks is a list of tasks.
  • todoCount - number - TodoCount is the number of items in the list that are not yet done.
  • doneCount - number - DoneCount is the number of items in the list that are done.

UnarchiveRoleRequest

UnarchiveRoleRequest is the request to unarchive a role.

  • roleID - number - Role to be unarchived to the organization

UnarchiveRoleResponse

UnarchiveRoleResponse is the response to unarchive a role.

  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UnassignRoleRequest

UnassignRoleRequest is the request for the UnassignRole method.

  • incidentID - string - IncidentID is the identifier.
  • userID - string - UserID is the identifier of the person to assign the role to.
  • role - string - options: "commander" "investigator" "observer" - Role is the role of this person.

UnassignRoleResponse

UnassignRoleResponse is the response for the UnassignRole method.

  • incident - Incident - Incident is the Incident that was just updated.
  • didChange - boolean - DidChange indicates if the role was changed or not. If the role was not assigned, this will be false.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateActivityBodyRequest

UpdateActivityBodyRequest is the request for the UpdateActivityBody method.

  • incidentID - string - IncidentID is the identifier.
  • activityItemID - string - ActivityItemID is the unique identifier of the ActivityItem.
  • body - string - Body is the new body to use for the given activity item

UpdateActivityBodyResponse

UpdateActivityBodyResponse is the response from the UpdateActivityBody method.

  • activityItem - ActivityItem - ActivityItem is the updated ActivityItem.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateActivityEventTimeRequest

UpdateActivityEventTimeRequest is the request for the UpdateActivityEventTime method.

  • incidentID - string - IncidentID is the identifier.
  • activityItemID - string - ActivityItemID is the unique identifier of the ActivityItem.
  • eventTime - string - EventTime is the time when the event occurred. If empty, the created time of the activity item is used. The string value format should follow RFC 3339.

UpdateActivityEventTimeResponse

UpdateActivityEventTimeResponse is the response from the UpdateActivityEventTime method.

  • activityItem - ActivityItem - ActivityItem is the updated ActivityItem.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateIncidentEventTimeRequest

UpdateIncidentEventTimeRequest is the request for the UpdateIncidentEventTime method.

  • incidentID - string - IncidentID is the identifier of the Incident.
  • eventTime - string - EventTime is the new time for the start or end of the incident. The string value format should follow RFC 3339.
  • activityItemKind - string - options: "incidentEnd" "incidentStart" - ActivityItemKind is either the start or end of the incident.

UpdateIncidentEventTimeResponse

UpdateIncidentEventTimeResponse is the response for the UpdateIncidentEventTime method.

  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateIncidentIsDrillRequest

UpdateIncidentIsDrillRequest is the request for the UpdateIncidentIsDrill method.

  • incidentID - string - IncidentID is the identifier of the Incident.
  • isDrill - boolean - IsDrill indicates whether the Incident is a drill or not.

UpdateIncidentIsDrillResponse

UpdateIncidentIsDrillResponse is the response for the UpdateIncidentIsDrill method.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateRoleRequest

UpdateRoleRequest is the request to update a role.

  • role - Role - Role to be updated to the organization

UpdateRoleResponse

UpdateRoleResponse is the response to update a role.

  • role - Role - Role is the newly updated role.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateSeverityRequest

UpdateSeverityRequest is the request for the UpdateSeverity method.

  • incidentID - string - IncidentID is the identifier of the Incident.
  • severity - string - options: "pending" "minor" "major" "critical" - Severity expresses how bad the Incident is.

UpdateSeverityResponse

UpdateSeverityResponse is the response for the UpdateSeverity method.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateStatusRequest

UpdateStatusRequest is the request for the UpdateStatus method.

  • incidentID - string - IncidentID is the identifier of the Incident.
  • status - string - options: "active" "resolved" - Status is the new status of the Incident.

UpdateStatusResponse

UpdateStatusResponse is the response for the UpdateStatus method.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateTaskStatusRequest

UpdateTaskStatusRequest is the request for the UpdateTaskStatus method.

  • incidentID - string - IncidentID is the ID of the Incident to add the Task to.
  • taskID - string - TaskID is the ID of the Task to update.
  • status - string - options: "todo" "progress" "done" - Status is the new status of this task.

UpdateTaskStatusResponse

UpdateTaskStatusResponse is the response from the UpdateTaskStatus method.

  • incidentID - string - IncidentID is the ID of the incident these tasks relate to.
  • task - Task - Task is the newly added Task. It will also appear in Tasks.
  • taskList - TaskList - TaskList is the tasks list.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateTaskTextRequest

UpdateTaskTextRequest is the request for the UpdateTaskText method.

  • incidentID - string - IncidentID is the ID of the Incident to add the Task to.
  • taskID - string - TaskID is the ID of the task.
  • text - string - Text is the string that describes the Task.

UpdateTaskTextResponse

UpdateTaskTextResponse is the response from the UpdateTaskText method.

  • incidentID - string - IncidentID is the ID of the incident these tasks relate to.
  • task - Task - Task is the newly added Task. It will also appear in Tasks.
  • taskList - TaskList - TaskList is the tasks list.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateTaskUserRequest

UpdateTaskUserRequest is the request for the UpdateTaskUser method.

  • incidentID - string - IncidentID is the ID of the Incident to add the Task to.
  • taskID - string - TaskID is the ID of the Task to update.
  • userID - string - UserID is the ID of the User to assign to the Task.

UpdateTaskUserResponse

UpdateTaskUserResponse is the response from the UpdateTaskUser method.

  • incidentID - string - IncidentID is the ID of the incident these tasks relate to.
  • task - Task - Task is the newly added Task. It will also appear in Tasks.
  • taskList - TaskList - TaskList is the tasks list.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UpdateTitleRequest

UpdateTitleRequest is the request for the UpdateTitle method.

  • incidentID - string - IncidentID is the identifier of the Incident.
  • title - string - Title is the new title of the Incident.

UpdateTitleResponse

UpdateTitleResponse is the response for the UpdateTitle method.

  • incident - Incident - Incident is the Incident that was just modified.
  • error - string - Error is string explaining what went wrong. Empty if everything was fine.

UserPreview

UserPreview is a user involved in an Incident.

  • userID - string - UserID is the identifier for the user.
  • name - string - Name is a human readable string that represents the user.
  • photoURL - string - PhotoURL is the URL to the profile picture of the user.

This documentation was dynamically generated, please report any issues.