Menu
Grafana Cloud

Note: This feature is currently experimental or under active development. Some details may change when the feature is released.

Go (golang) reference

This page describes the entire API surface in detail.

Get started

We’re not ready yet, we’ll update this section soon. If you’d like early access, please reach out through our grafana/incident-community repo.

Services

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

  • IncidentsService - IncidentsService provides the ability to query, get, declare (create), update, and manage Incidents programatically. You can also manage roles and labels.
  • TasksService - TasksService provides methods for managing tasks relating to Incidents.

IncidentsService

IncidentsService provides the ability to query, get, declare (create), update, and manage Incidents programatically. You can also manage roles and 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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	addLabelResp, err := incidentsService.AddLabel(ctx, incident.AddLabelRequest{
		IncidentID: "incident-123",
		Label: incident.IncidentLabel{
			Label: "high-latency",
			Description: "High latency in web requests",
			ColorHex: "#ff0000",
		},
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	fmt.Fprintf(os.Stdout, "Incident= %+v", addLabelResp.Incident)
	fmt.Fprintf(os.Stdout, "Error= %+v", addLabelResp.Error)
	
}

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.

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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	assignRoleResp, err := incidentsService.AssignRole(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "Incident= %+v", assignRoleResp.Incident)
	fmt.Fprintf(os.Stdout, "DidChange= %+v", assignRoleResp.DidChange)
	fmt.Fprintf(os.Stdout, "Error= %+v", assignRoleResp.Error)
	
}

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.

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.
  • 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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	createIncidentResp, err := incidentsService.CreateIncident(ctx, incident.CreateIncidentRequest{
		Title: "High latency in web requests",
		Severity: "minor",
		Labels: incident.IncidentLabel{
			Label: "high-latency",
			Description: "High latency in web requests",
			ColorHex: "#ff0000",
		},
		RoomPrefix: "incident_",
		IsDrill: false,
		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...
	fmt.Fprintf(os.Stdout, "Incident= %+v", createIncidentResp.Incident)
	fmt.Fprintf(os.Stdout, "Error= %+v", createIncidentResp.Error)
	
}

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.

GetIncident

GetIncident gets an existing Incident by ID.

GetIncidentRequest

  • incidentID - string - IncidentID is the identifier.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	getIncidentResp, err := incidentsService.GetIncident(ctx, incident.GetIncidentRequest{
		IncidentID: "incident-123",
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	fmt.Fprintf(os.Stdout, "Incident= %+v", getIncidentResp.Incident)
	fmt.Fprintf(os.Stdout, "Error= %+v", getIncidentResp.Error)
	
}

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.

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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	queryIncidentsResp, err := incidentsService.QueryIncidents(ctx, incident.QueryIncidentsRequest{
		Query: incident.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: incident.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...
	fmt.Fprintf(os.Stdout, "Incidents= %+v", queryIncidentsResp.Incidents)
	fmt.Fprintf(os.Stdout, "Query= %+v", queryIncidentsResp.Query)
	fmt.Fprintf(os.Stdout, "Cursor= %+v", queryIncidentsResp.Cursor)
	fmt.Fprintf(os.Stdout, "Error= %+v", queryIncidentsResp.Error)
	
}

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.

RemoveLabel

RemoveLabel removes a label from the Incident.

RemoveLabelRequest

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

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	removeLabelResp, err := incidentsService.RemoveLabel(ctx, incident.RemoveLabelRequest{
		IncidentID: "incident-123",
		Label: incident.IncidentLabel{
			Label: "high-latency",
			Description: "High latency in web requests",
			ColorHex: "#ff0000",
		},
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	fmt.Fprintf(os.Stdout, "Incident= %+v", removeLabelResp.Incident)
	fmt.Fprintf(os.Stdout, "Error= %+v", removeLabelResp.Error)
	
}

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.

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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	unassignRoleResp, err := incidentsService.UnassignRole(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "Incident= %+v", unassignRoleResp.Incident)
	fmt.Fprintf(os.Stdout, "DidChange= %+v", unassignRoleResp.DidChange)
	fmt.Fprintf(os.Stdout, "Error= %+v", unassignRoleResp.Error)
	
}

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.

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 IncidentEnd or IncidentStart.
  • activityItemKind - string - options: "incidentEnd" "incidentStart" - ActivityItemKind is either the IncidentEnd or incidentStart time.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	updateIncidentEventTimeResp, err := incidentsService.UpdateIncidentEventTime(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "Error= %+v", updateIncidentEventTimeResp.Error)
	
}

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.

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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	updateIncidentIsDrillResp, err := incidentsService.UpdateIncidentIsDrill(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "Incident= %+v", updateIncidentIsDrillResp.Incident)
	fmt.Fprintf(os.Stdout, "Error= %+v", updateIncidentIsDrillResp.Error)
	
}

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.

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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	updateSeverityResp, err := incidentsService.UpdateSeverity(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "Incident= %+v", updateSeverityResp.Incident)
	fmt.Fprintf(os.Stdout, "Error= %+v", updateSeverityResp.Error)
	
}

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.

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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	updateStatusResp, err := incidentsService.UpdateStatus(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "Incident= %+v", updateStatusResp.Incident)
	fmt.Fprintf(os.Stdout, "Error= %+v", updateStatusResp.Error)
	
}

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.

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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	incidentsService := incident.NewIncidentsService(client)
	// make the request...
	updateTitleResp, err := incidentsService.UpdateTitle(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "Incident= %+v", updateTitleResp.Incident)
	fmt.Fprintf(os.Stdout, "Error= %+v", updateTitleResp.Error)
	
}

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.

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

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	tasksService := incident.NewTasksService(client)
	// make the request...
	addTaskResp, err := tasksService.AddTask(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "IncidentID= %+v", addTaskResp.IncidentID)
	fmt.Fprintf(os.Stdout, "Task= %+v", addTaskResp.Task)
	fmt.Fprintf(os.Stdout, "TaskList= %+v", addTaskResp.TaskList)
	fmt.Fprintf(os.Stdout, "Error= %+v", addTaskResp.Error)
	
}

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.

DeleteTask

DeleteTask deletes a task.

DeleteTaskRequest

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

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	tasksService := incident.NewTasksService(client)
	// make the request...
	deleteTaskResp, err := tasksService.DeleteTask(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "IncidentID= %+v", deleteTaskResp.IncidentID)
	fmt.Fprintf(os.Stdout, "TaskList= %+v", deleteTaskResp.TaskList)
	fmt.Fprintf(os.Stdout, "Error= %+v", deleteTaskResp.Error)
	
}

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.

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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	tasksService := incident.NewTasksService(client)
	// make the request...
	updateTaskStatusResp, err := tasksService.UpdateTaskStatus(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "IncidentID= %+v", updateTaskStatusResp.IncidentID)
	fmt.Fprintf(os.Stdout, "Task= %+v", updateTaskStatusResp.Task)
	fmt.Fprintf(os.Stdout, "TaskList= %+v", updateTaskStatusResp.TaskList)
	fmt.Fprintf(os.Stdout, "Error= %+v", updateTaskStatusResp.Error)
	
}

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.

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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	tasksService := incident.NewTasksService(client)
	// make the request...
	updateTaskTextResp, err := tasksService.UpdateTaskText(ctx, incident.UpdateTaskTextRequest{
		IncidentID: "incident-123456",
		TaskID: "task-123456",
		Text: null,
	})
	if err != nil {
		// something went wrong
		fmt.Errorf(os.Stderr, "%s\n", err)
		os.Exit(1)
	}
	// use the output fields...
	fmt.Fprintf(os.Stdout, "IncidentID= %+v", updateTaskTextResp.IncidentID)
	fmt.Fprintf(os.Stdout, "Task= %+v", updateTaskTextResp.Task)
	fmt.Fprintf(os.Stdout, "TaskList= %+v", updateTaskTextResp.TaskList)
	fmt.Fprintf(os.Stdout, "Error= %+v", updateTaskTextResp.Error)
	
}

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.

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.

Choose language:  cURL   Go   JSON 

package main

import (
	"context"
	"fmt"
	"os"

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

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/experimental", serviceAccountToken)
	tasksService := incident.NewTasksService(client)
	// make the request...
	updateTaskUserResp, err := tasksService.UpdateTaskUser(ctx, incident.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...
	fmt.Fprintf(os.Stdout, "IncidentID= %+v", updateTaskUserResp.IncidentID)
	fmt.Fprintf(os.Stdout, "Task= %+v", updateTaskUserResp.Task)
	fmt.Fprintf(os.Stdout, "TaskList= %+v", updateTaskUserResp.TaskList)
	fmt.Fprintf(os.Stdout, "Error= %+v", updateTaskUserResp.Error)
	
}

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.

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.

  • 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 call.
  • GetHomescreenVersionResponse - GetHomescreenVersionResponse is the response for the GetHomescreenVersion call.
  • GetIncidentVersionRequest - GetIncidentVersionRequest is the request for the GetIncidentVersion call.
  • GetIncidentVersionResponse - GetIncidentVersionResponse is the response for the GetIncidentVersion call.
  • Incident - Incident is a single incident.
  • IncidentLabel - IncidentLabel is a label associated with an Incident.
  • IncidentRole - IncidentRole represents a person involved in an Incident.
  • IncidentsQuery - IncidentsQuery is the query for the QueryIncidentsRequest.
  • OutgoingWebhookPayload - OutgoingWebhookPayload represents the webhook HTTP POST body and contains metadata for the webhook.
  • 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.

AddLabelRequest

AddLabelRequest is the request for the AddLabel call.

  • 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 call.

  • 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

  • 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

  • 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.

AssignRoleRequest

AssignRoleRequest is the request for the AssignRole call.

  • 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 call.

  • 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.

CreateIncidentRequest

CreateIncidentRequest is the request for the CreateIncident call.

  • 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.
  • 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 call.

  • incident - Incident - Incident is the Incident that was created.
  • 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.

DeleteTaskRequest

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

DeleteTaskResponse

  • 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 call.

  • No fields

GetHomescreenVersionResponse

GetHomescreenVersionResponse is the response for the GetHomescreenVersion call.

  • 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.

GetIncidentRequest

GetIncidentRequest is the request for the GetIncident call.

  • incidentID - string - IncidentID is the identifier.

GetIncidentResponse

GetIncidentResponse is the response for the GetIncident call.

  • 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 call.

  • 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 call.

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

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.
  • modifiedTime - string - ModifiedTime is when the Incident was last modified.
  • createdByUser - UserPreview - CreatedByUser is the UserPreview that created the Incident.
  • closedTime - string - ClosedTime is when the Incident was closed.
  • 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.
  • 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.
  • incidentEnd - string - IncidentEnd is when the Incident ended.

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.

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.

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.

QueryIncidentsRequest

QueryIncidentsRequest is the request for the QueryIncidents call.

  • 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 call.

  • 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.

RemoveLabelRequest

RemoveLabelRequest is the request for the RemoveLabel call.

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

RemoveLabelResponse

RemoveLabelResponse is the response for the RemoveLabel call.

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

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.

UnassignRoleRequest

UnassignRoleRequest is the request for the UnassignRole call.

  • 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 call.

  • 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.

UpdateIncidentEventTimeRequest

UpdateIncidentEventTimeRequest is the request for the UpdateIncidentEventTime call.

  • incidentID - string - IncidentID is the identifier of the Incident.
  • eventTime - string - EventTime is the new time for IncidentEnd or IncidentStart.
  • activityItemKind - string - options: "incidentEnd" "incidentStart" - ActivityItemKind is either the IncidentEnd or incidentStart time.

UpdateIncidentEventTimeResponse

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

UpdateIncidentIsDrillRequest

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

UpdateIncidentIsDrillResponse

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

UpdateSeverityRequest

UpdateSeverityRequest is the request for the UpdateSeverity call.

  • 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 call.

  • 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 call.

  • 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 call.

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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 call.

  • 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 call.

  • 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.