{"id":15178489,"url":"https://github.com/grafana/incident-go","last_synced_at":"2025-12-15T08:11:08.034Z","repository":{"id":142544733,"uuid":"605747397","full_name":"grafana/incident-go","owner":"grafana","description":"Clients, scripts and examples for using the Grafana Incident API","archived":false,"fork":false,"pushed_at":"2025-02-07T12:08:52.000Z","size":130,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-02-07T13:24:22.817Z","etag":null,"topics":["keep"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grafana.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-23T20:17:56.000Z","updated_at":"2025-01-15T16:52:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"d00ed2b5-9460-42a6-a4f9-07b457a51f2d","html_url":"https://github.com/grafana/incident-go","commit_stats":null,"previous_names":["grafana/incident-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fincident-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fincident-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fincident-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grafana%2Fincident-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grafana","download_url":"https://codeload.github.com/grafana/incident-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247092372,"owners_count":20882218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["keep"],"created_at":"2024-09-27T15:04:03.359Z","updated_at":"2025-12-15T08:11:07.963Z","avatar_url":"https://github.com/grafana.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grafana Incident API - Go client library\n\nThe Grafana Incident Go client library allows you to access the Grafana Incident API from your Go code.\n\n- Get started with the [Grafana Incident API documentation](https://grafana.com/docs/grafana-cloud/incident/api/)\n- Or dive deep into the [Go reference docs](https://grafana.com/docs/grafana-cloud/incident/api/reference/go/)\n\n## Get started\n\nImport the package:\n\n```\ngo get github.com/grafana/incident-go@latest\n```\n\n## Make calls to the API\n\nIn this example, we will use the [IncidentsService.CreateIncident() method](https://grafana.com/docs/grafana-cloud/incident/api/experimental/reference/go/#createincident) to declare an Incident, and print its ID.\n\n```go\n// create a client, and the services you need\nserviceAccountToken := os.Getenv(\"SERVICE_ACCOUNT_TOKEN\")\nclient := incident.NewClient(\"https://your-api-endpoint/api\", serviceAccountToken)\nincidentsService := incident.NewIncidentsService(client)\n\n// declare an incident\ncreateIncidentResp, err := incidentsService.CreateIncident(ctx, incident.CreateIncidentRequest{\n\tTitle: \"short description explaining what's going wrong\",\n\tSeverity: incident.Options.IncidentSeverity.Minor,\n})\nif err != nil {\n\t// if something goes wrong, the error will help you\n\treturn fmt.Errorf(\"create incident: %w\", err)\n}\n// success, get the details from the createIncidentResp object\nfmt.Println(\"declared Incident\", createIncidentResp.Incident.IncidentID)\n```\n\n## Handle webhooks from Grafana Incident\n\nYou can use the [Outgoing Webhook integration](https://grafana.com/docs/grafana-cloud/incident/integrations/configure-outgoing-webhooks/) to get Grafana Incident to POST a request on specific events.\n\nIf you are consuming that event in Go, you can use the `incident.ParseWebhook` helper:\n\n```go\nimport (\n\tincident \"github.com/grafana/incident-go\"\n)\n\n// handleIncidentWebhook gets a handler that processes webhooks from\n// Grafana Incident.\n// The secret should be safely injected (avoid committing it to source control).\n// Secrets can be created in the web interface when configuring the Outgoing Webhook integration.\nfunc handleIncidentWebhook(secret string) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t// incident.ParseWebhook will verify the signature and decode\n\t\t// the body into the incident.OutgoingWebhookPayload type.\n\t\tpayload, err := incident.ParseWebhook(r, secret)\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tswitch payload.Event {\n\t\tcase \"grafana.incident.created\":\n\t\t\tfmt.Printf(\"Incident declared: %s\\n\", payload.Incident.Title)\n\t\tdefault:\n\t\t\tfmt.Printf(\"Unknown event: %s\\n\", payload.Event)\n\t\t}\n\t}))\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fincident-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrafana%2Fincident-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrafana%2Fincident-go/lists"}