2022-06-09 10:08:07 +01:00
|
|
|
---
|
2022-10-26 12:32:47 -04:00
|
|
|
canonical: https://grafana.com/docs/oncall/latest/oncall-api-reference/outgoing_webhooks/
|
2024-06-17 11:31:35 -04:00
|
|
|
title: Outgoing webhooks HTTP API
|
2024-08-15 15:29:56 -04:00
|
|
|
weight: 0
|
2024-07-29 15:13:24 +01:00
|
|
|
refs:
|
|
|
|
|
outgoing-webhooks:
|
|
|
|
|
- pattern: /docs/oncall/
|
|
|
|
|
destination: /docs/oncall/<ONCALL_VERSION>/configure/integrations/outgoing-webhooks/
|
|
|
|
|
- pattern: /docs/grafana-cloud/
|
|
|
|
|
destination: /docs/grafana-cloud/alerting-and-irm/oncall/configure/integrations/outgoing-webhooks/
|
|
|
|
|
event-types:
|
|
|
|
|
- pattern: /docs/oncall/
|
|
|
|
|
destination: /docs/oncall/<ONCALL_VERSION>/configure/integrations/outgoing-webhooks/#event-types
|
|
|
|
|
- pattern: /docs/grafana-cloud/
|
|
|
|
|
destination: /docs/grafana-cloud/alerting-and-irm/oncall/configure/integrations/outgoing-webhooks/#event-types
|
2024-08-09 15:24:24 +01:00
|
|
|
pagination:
|
|
|
|
|
- pattern: /docs/oncall/
|
|
|
|
|
destination: /docs/oncall/<ONCALL_VERSION>/oncall-api-reference/#pagination
|
|
|
|
|
- pattern: /docs/grafana-cloud/
|
|
|
|
|
destination: /docs/grafana-cloud/alerting-and-irm/oncall/oncall-api-reference/#pagination
|
2022-06-09 10:08:07 +01:00
|
|
|
---
|
2022-06-03 08:09:47 -06:00
|
|
|
|
2024-06-17 11:31:35 -04:00
|
|
|
# Outgoing webhooks
|
2022-06-03 08:09:47 -06:00
|
|
|
|
2023-08-22 14:05:52 -06:00
|
|
|
> ⚠️ A note about actions: Before version **v1.3.11** webhooks existed as actions within the API, the /actions
|
|
|
|
|
> endpoint remains available and is compatible with previous callers but under the hood it will interact with the
|
|
|
|
|
> new webhooks objects. It is recommended to use the /webhooks endpoint going forward which has more features.
|
2022-06-03 08:09:47 -06:00
|
|
|
|
2024-07-29 15:13:24 +01:00
|
|
|
For more details about specific fields of a webhook, refer to [Outgoing webhooks](ref:outgoing-webhooks).
|
2023-08-22 14:05:52 -06:00
|
|
|
|
|
|
|
|
## List webhooks
|
2022-06-03 08:09:47 -06:00
|
|
|
|
2024-12-11 08:54:00 -03:00
|
|
|
**Required permission**: `grafana-oncall-app.outgoing-webhooks:read`
|
|
|
|
|
|
2022-06-03 08:09:47 -06:00
|
|
|
```shell
|
2023-08-22 14:05:52 -06:00
|
|
|
curl "{{API_URL}}/api/v1/webhooks/" \
|
2022-06-03 08:09:47 -06:00
|
|
|
--request GET \
|
|
|
|
|
--header "Authorization: meowmeowmeow" \
|
2022-06-09 10:08:07 +01:00
|
|
|
--header "Content-Type: application/json"
|
2022-06-03 08:09:47 -06:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The above command returns JSON structured in the following way:
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
2022-06-09 10:08:07 +01:00
|
|
|
"next": null,
|
|
|
|
|
"previous": null,
|
|
|
|
|
"results": [
|
|
|
|
|
{
|
2023-08-22 14:05:52 -06:00
|
|
|
"id": "{{WEBHOOK_UID}}",
|
|
|
|
|
"name": "Demo Webhook",
|
|
|
|
|
"is_webhook_enabled": true,
|
|
|
|
|
"team": null,
|
|
|
|
|
"data": "{\"labels\" : {{ alert_payload.commonLabels | tojson()}}}",
|
|
|
|
|
"username": null,
|
|
|
|
|
"password": null,
|
|
|
|
|
"authorization_header": "****************",
|
|
|
|
|
"trigger_template": null,
|
|
|
|
|
"headers": null,
|
|
|
|
|
"url": "https://example.com",
|
|
|
|
|
"forward_all": false,
|
|
|
|
|
"http_method": "POST",
|
|
|
|
|
"trigger_type": "acknowledge",
|
|
|
|
|
"integration_filter": [
|
|
|
|
|
"CRV8A5MXC751A"
|
|
|
|
|
]
|
2022-06-09 10:08:07 +01:00
|
|
|
}
|
augment API response pagination attributes (#2471)
# What this PR does
This PR:
- adds a few attributes to paginated API responses
- removes channel filter "send demo alert" internal API endpoint + tests
(this endpoint was marked as deprecated + not consumed by the web UI)
With the new paginated API response schema, the web UI will no longer
need to:
- hardcode `ITEMS_PER_PAGE` for each table
- manually calculate total number of pages
(these two things ☝️ will be done in
https://github.com/grafana/oncall/issues/2476)
For `GET /api/internal/v1/alertgroups` the response will now look like
this:
```diff
{
"next": <url> | None,
"previous": <url> | None,
"results": [],
++ "page_size": <int>
}
```
For all other paginated API responses, the response will now look like:
```diff
{
"count": <int>,
"next": <url> | None,
"previous": <url> | None,
"results": [],
++ "page_size": <int>,
++ "current_page_number": <int>,
++ "total_pages": <int>
}
```
## TODO
- [x] update public API docs to include these new attributes
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-14 17:19:40 +02:00
|
|
|
],
|
|
|
|
|
"page_size": 50,
|
2023-08-22 14:05:52 -06:00
|
|
|
"count": 1,
|
|
|
|
|
"current_page_number": 1,
|
augment API response pagination attributes (#2471)
# What this PR does
This PR:
- adds a few attributes to paginated API responses
- removes channel filter "send demo alert" internal API endpoint + tests
(this endpoint was marked as deprecated + not consumed by the web UI)
With the new paginated API response schema, the web UI will no longer
need to:
- hardcode `ITEMS_PER_PAGE` for each table
- manually calculate total number of pages
(these two things ☝️ will be done in
https://github.com/grafana/oncall/issues/2476)
For `GET /api/internal/v1/alertgroups` the response will now look like
this:
```diff
{
"next": <url> | None,
"previous": <url> | None,
"results": [],
++ "page_size": <int>
}
```
For all other paginated API responses, the response will now look like:
```diff
{
"count": <int>,
"next": <url> | None,
"previous": <url> | None,
"results": [],
++ "page_size": <int>,
++ "current_page_number": <int>,
++ "total_pages": <int>
}
```
## TODO
- [x] update public API docs to include these new attributes
## Checklist
- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-14 17:19:40 +02:00
|
|
|
"total_pages": 1
|
2022-06-03 08:09:47 -06:00
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2024-08-09 15:24:24 +01:00
|
|
|
> **Note**: The response is [paginated](ref:pagination). You may need to make multiple requests to get all records.
|
|
|
|
|
|
2023-08-22 14:05:52 -06:00
|
|
|
## Get webhook
|
|
|
|
|
|
2024-12-11 08:54:00 -03:00
|
|
|
**Required permission**: `grafana-oncall-app.outgoing-webhooks:read`
|
|
|
|
|
|
2023-08-22 14:05:52 -06:00
|
|
|
```shell
|
|
|
|
|
curl "{{API_URL}}/api/v1/webhooks/{{WEBHOOK_UID}}/" \
|
|
|
|
|
--request GET \
|
|
|
|
|
--header "Authorization: meowmeowmeow" \
|
|
|
|
|
--header "Content-Type: application/json"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The above command returns JSON structured in the following way:
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"id": "{{WEBHOOK_UID}}",
|
|
|
|
|
"name": "Demo Webhook",
|
|
|
|
|
"is_webhook_enabled": true,
|
|
|
|
|
"team": null,
|
|
|
|
|
"data": "{\"labels\" : {{ alert_payload.commonLabels | tojson()}}}",
|
|
|
|
|
"username": null,
|
|
|
|
|
"password": null,
|
|
|
|
|
"authorization_header": "****************",
|
|
|
|
|
"trigger_template": null,
|
|
|
|
|
"headers": null,
|
|
|
|
|
"url": "https://example.com",
|
|
|
|
|
"forward_all": false,
|
|
|
|
|
"http_method": "POST",
|
|
|
|
|
"trigger_type": "acknowledge",
|
|
|
|
|
"integration_filter": [
|
|
|
|
|
"CRV8A5MXC751A"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Create webhook
|
|
|
|
|
|
2024-12-11 08:54:00 -03:00
|
|
|
**Required permission**: `grafana-oncall-app.outgoing-webhooks:write`
|
|
|
|
|
|
2023-08-22 14:05:52 -06:00
|
|
|
```shell
|
|
|
|
|
curl "{{API_URL}}/api/v1/webhooks/" \
|
|
|
|
|
--request POST \
|
|
|
|
|
--header "Authorization: meowmeowmeow" \
|
|
|
|
|
--header "Content-Type: application/json" \
|
|
|
|
|
--data '{
|
|
|
|
|
"name": "New Webhook",
|
|
|
|
|
"url": "https://example.com",
|
|
|
|
|
"http_method": "POST",
|
|
|
|
|
"trigger_type" : "resolve"
|
|
|
|
|
}'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Trigger Types
|
|
|
|
|
|
2024-07-29 15:13:24 +01:00
|
|
|
For more detail, refer to [Event types](ref:event-types).
|
2023-08-22 14:05:52 -06:00
|
|
|
|
|
|
|
|
- `escalation`
|
2025-02-18 14:53:07 -03:00
|
|
|
- `personal notification`
|
2023-08-22 14:05:52 -06:00
|
|
|
- `alert group created`
|
|
|
|
|
- `acknowledge`
|
|
|
|
|
- `resolve`
|
|
|
|
|
- `silence`
|
|
|
|
|
- `unsilence`
|
|
|
|
|
- `unresolve`
|
|
|
|
|
- `unacknowledge`
|
2024-02-19 14:12:56 -03:00
|
|
|
- `status change`
|
2023-08-22 14:05:52 -06:00
|
|
|
|
|
|
|
|
### HTTP Methods
|
|
|
|
|
|
|
|
|
|
- `POST`
|
|
|
|
|
- `GET`
|
|
|
|
|
- `PUT`
|
|
|
|
|
- `DELETE`
|
|
|
|
|
- `OPTIONS`
|
|
|
|
|
|
|
|
|
|
The above command returns JSON structured in the following way:
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"id": "{{WEBHOOK_UID}}",
|
|
|
|
|
"name": "New Webhook",
|
|
|
|
|
"is_webhook_enabled": true,
|
|
|
|
|
"team": null,
|
|
|
|
|
"data": null,
|
|
|
|
|
"username": null,
|
|
|
|
|
"password": null,
|
|
|
|
|
"authorization_header": null,
|
|
|
|
|
"trigger_template": null,
|
|
|
|
|
"headers": null,
|
|
|
|
|
"url": "https://example.com",
|
|
|
|
|
"forward_all": true,
|
|
|
|
|
"http_method": "POST",
|
|
|
|
|
"trigger_type": "resolve",
|
|
|
|
|
"integration_filter": null
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Update webhook
|
|
|
|
|
|
2024-12-11 08:54:00 -03:00
|
|
|
**Required permission**: `grafana-oncall-app.outgoing-webhooks:write`
|
|
|
|
|
|
2023-08-22 14:05:52 -06:00
|
|
|
```shell
|
|
|
|
|
curl "{{API_URL}}/api/v1/webhooks/{{WEBHOOK_UID}}/" \
|
|
|
|
|
--request PUT \
|
|
|
|
|
--header "Authorization: meowmeowmeow" \
|
|
|
|
|
--header "Content-Type: application/json" \
|
|
|
|
|
--data '{
|
|
|
|
|
"is_webhook_enabled": false
|
|
|
|
|
}'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The above command returns JSON structured in the following way:
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"id": "{{WEBHOOK_UID}}",
|
|
|
|
|
"name": "New Webhook",
|
|
|
|
|
"is_webhook_enabled": false,
|
|
|
|
|
"team": null,
|
|
|
|
|
"data": null,
|
|
|
|
|
"username": null,
|
|
|
|
|
"password": null,
|
|
|
|
|
"authorization_header": null,
|
|
|
|
|
"trigger_template": null,
|
|
|
|
|
"headers": null,
|
|
|
|
|
"url": "https://example.com",
|
|
|
|
|
"forward_all": true,
|
|
|
|
|
"http_method": "POST",
|
|
|
|
|
"trigger_type": "resolve",
|
|
|
|
|
"integration_filter": null
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Delete webhook
|
|
|
|
|
|
2024-12-11 08:54:00 -03:00
|
|
|
**Required permission**: `grafana-oncall-app.outgoing-webhooks:write`
|
|
|
|
|
|
2023-08-22 14:05:52 -06:00
|
|
|
```shell
|
|
|
|
|
curl "{{API_URL}}/api/v1/webhooks/{{WEBHOOK_UID}}/" \
|
|
|
|
|
--request DELETE \
|
|
|
|
|
--header "Authorization: meowmeowmeow" \
|
|
|
|
|
--header "Content-Type: application/json"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Get webhook responses
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
curl "{{API_URL}}/api/v1/webhooks/{{WEBHOOK_UID}}/responses" \
|
|
|
|
|
--request GET \
|
|
|
|
|
--header "Authorization: meowmeowmeow" \
|
|
|
|
|
--header "Content-Type: application/json"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The above command returns JSON structured in the following way:
|
2022-06-03 08:09:47 -06:00
|
|
|
|
2023-08-22 14:05:52 -06:00
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"next": null,
|
|
|
|
|
"previous": null,
|
|
|
|
|
"results": [
|
|
|
|
|
{
|
|
|
|
|
"timestamp": "2023-08-18T16:38:23.106015Z",
|
|
|
|
|
"url": "https://example.com",
|
|
|
|
|
"request_trigger": "",
|
|
|
|
|
"request_headers": "{\"Authorization\": \"****************\"}",
|
|
|
|
|
"request_data": "{\"labels\": {\"alertname\": \"InstanceDown\", \"job\": \"node\", \"severity\": \"critical\"}}",
|
|
|
|
|
"status_code": 200,
|
|
|
|
|
"content": "",
|
|
|
|
|
"event_data": "{\"event\": {\"type\": \"acknowledge\", \"time\": \"2023-08-18T16:38:21.442981+00:00\"}, \"user\": {\"id\": \"UK49JJNPZMFLJ\", \"username\": \"oncall\", \"email\": \"admin@localhost\"}, \"alert_group\": {\"id\": \"IZQERPWKWCGH1\", \"integration_id\": \"CRV8A5MXC751A\", \"route_id\": \"RWNCT6C77M3WM\", \"alerts_count\": 1, \"state\": \"acknowledged\", \"created_at\": \"2023-08-18T16:34:27.678406Z\", \"resolved_at\": null, \"acknowledged_at\": \"2023-08-18T16:38:21.442981Z\", \"title\": \"[firing:2] InstanceDown \", \"permalinks\": {\"slack\": null, \"telegram\": null, \"web\": \"http://localhost:3000/a/grafana-oncall-app/alert-groups/IZQERPWKWCGH1\"}}, \"alert_group_id\": \"IZQERPWKWCGH1\", \"alert_payload\": {\"alerts\": [{\"endsAt\": \"0001-01-01T00:00:00Z\", \"labels\": {\"job\": \"node\", \"group\": \"production\", \"instance\": \"localhost:8081\", \"severity\": \"critical\", \"alertname\": \"InstanceDown\"}, \"status\": \"firing\", \"startsAt\": \"2023-06-12T08:24:38.326Z\", \"annotations\": {\"title\": \"Instance localhost:8081 down\", \"description\": \"localhost:8081 of job node has been down for more than 1 minute.\"}, \"fingerprint\": \"f404ecabc8dd5cd7\", \"generatorURL\": \"\"}, {\"endsAt\": \"0001-01-01T00:00:00Z\", \"labels\": {\"job\": \"node\", \"group\": \"canary\", \"instance\": \"localhost:8082\", \"severity\": \"critical\", \"alertname\": \"InstanceDown\"}, \"status\": \"firing\", \"startsAt\": \"2023-06-12T08:24:38.326Z\", \"annotations\": {\"title\": \"Instance localhost:8082 down\", \"description\": \"localhost:8082 of job node has been down for more than 1 minute.\"}, \"fingerprint\": \"f8f08d4e32c61a9d\", \"generatorURL\": \"\"}], \"status\": \"firing\", \"version\": \"4\", \"groupKey\": \"{}:{alertname=\\\"InstanceDown\\\"}\", \"receiver\": \"combo\", \"numFiring\": 2, \"externalURL\": \"\", \"groupLabels\": {\"alertname\": \"InstanceDown\"}, \"numResolved\": 0, \"commonLabels\": {\"job\": \"node\", \"severity\": \"critical\", \"alertname\": \"InstanceDown\"}, \"truncatedAlerts\": 0, \"commonAnnotations\": {}}, \"integration\": {\"id\": \"CRV8A5MXC751A\", \"type\": \"alertmanager\", \"name\": \"One - Alertmanager\", \"team\": null}, \"notified_users\": [], \"users_to_be_notified\": []}"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"timestamp": "2023-08-18T16:34:38.580574Z",
|
|
|
|
|
"url": "https://example.com",
|
|
|
|
|
"request_trigger": "",
|
|
|
|
|
"request_headers": null,
|
|
|
|
|
"request_data": "Data - Template Warning: Object of type Undefined is not JSON serializable",
|
|
|
|
|
"status_code": null,
|
|
|
|
|
"content": null,
|
|
|
|
|
"event_data": "{\"event\": {\"type\": \"acknowledge\", \"time\": \"2023-08-18T16:34:37.940655+00:00\"}, \"user\": {\"id\": \"UK49JJNPZMFLJ\", \"username\": \"oncall\", \"email\": \"admin@localhost\"}, \"alert_group\": {\"id\": \"IZQERPWKWCGH1\", \"integration_id\": \"CRV8A5MXC751A\", \"route_id\": \"RWNCT6C77M3WM\", \"alerts_count\": 1, \"state\": \"acknowledged\", \"created_at\": \"2023-08-18T16:34:27.678406Z\", \"resolved_at\": null, \"acknowledged_at\": \"2023-08-18T16:34:37.940655Z\", \"title\": \"[firing:2] InstanceDown \", \"permalinks\": {\"slack\": null, \"telegram\": null, \"web\": \"http://localhost:3000/a/grafana-oncall-app/alert-groups/IZQERPWKWCGH1\"}}, \"alert_group_id\": \"IZQERPWKWCGH1\", \"alert_payload\": {\"alerts\": [{\"endsAt\": \"0001-01-01T00:00:00Z\", \"labels\": {\"job\": \"node\", \"group\": \"production\", \"instance\": \"localhost:8081\", \"severity\": \"critical\", \"alertname\": \"InstanceDown\"}, \"status\": \"firing\", \"startsAt\": \"2023-06-12T08:24:38.326Z\", \"annotations\": {\"title\": \"Instance localhost:8081 down\", \"description\": \"localhost:8081 of job node has been down for more than 1 minute.\"}, \"fingerprint\": \"f404ecabc8dd5cd7\", \"generatorURL\": \"\"}, {\"endsAt\": \"0001-01-01T00:00:00Z\", \"labels\": {\"job\": \"node\", \"group\": \"canary\", \"instance\": \"localhost:8082\", \"severity\": \"critical\", \"alertname\": \"InstanceDown\"}, \"status\": \"firing\", \"startsAt\": \"2023-06-12T08:24:38.326Z\", \"annotations\": {\"title\": \"Instance localhost:8082 down\", \"description\": \"localhost:8082 of job node has been down for more than 1 minute.\"}, \"fingerprint\": \"f8f08d4e32c61a9d\", \"generatorURL\": \"\"}], \"status\": \"firing\", \"version\": \"4\", \"groupKey\": \"{}:{alertname=\\\"InstanceDown\\\"}\", \"receiver\": \"combo\", \"numFiring\": 2, \"externalURL\": \"\", \"groupLabels\": {\"alertname\": \"InstanceDown\"}, \"numResolved\": 0, \"commonLabels\": {\"job\": \"node\", \"severity\": \"critical\", \"alertname\": \"InstanceDown\"}, \"truncatedAlerts\": 0, \"commonAnnotations\": {}}, \"integration\": {\"id\": \"CRV8A5MXC751A\", \"type\": \"alertmanager\", \"name\": \"One - Alertmanager\", \"team\": null}, \"notified_users\": [], \"users_to_be_notified\": []}"
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"page_size": 50,
|
|
|
|
|
"count": 2,
|
|
|
|
|
"current_page_number": 1,
|
|
|
|
|
"total_pages": 1
|
|
|
|
|
}
|
|
|
|
|
```
|
2024-08-09 15:24:24 +01:00
|
|
|
|
|
|
|
|
> **Note**: The response is [paginated](ref:pagination). You may need to make multiple requests to get all records.
|