oncall-engine/docs/sources/oncall-api-reference/integrations.md
Michael Derynck 6b40f95033 World, meet OnCall!
Co-authored-by: Eve832 <eve.meelan@grafana.com>
    Co-authored-by: Francisco Montes de Oca <nevermind89x@gmail.com>
    Co-authored-by: Ildar Iskhakov <ildar.iskhakov@grafana.com>
    Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
    Co-authored-by: Julia <ferril.darkdiver@gmail.com>
    Co-authored-by: maskin25 <kengurek@gmail.com>
    Co-authored-by: Matias Bordese <mbordese@gmail.com>
    Co-authored-by: Matvey Kukuy <motakuk@gmail.com>
    Co-authored-by: Michael Derynck <michael.derynck@grafana.com>
    Co-authored-by: Richard Hartmann <richih@richih.org>
    Co-authored-by: Robby Milo <robbymilo@fastmail.com>
    Co-authored-by: Timur Olzhabayev <timur.olzhabayev@grafana.com>
    Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
    Co-authored-by: Yulia Shanyrova <yulia.shanyrova@grafana.com>
2022-06-03 08:09:47 -06:00

6.7 KiB

+++ title = "Integrations HTTP API" aliases = ["/docs/grafana-cloud/oncall/oncall-api-reference/integrations/"] weight = 500 +++

Create an integration

curl "{{API_URL}}/api/v1/integrations/" \
  --request POST \
  --header "Authorization: meowmeowmeow" \
  --header "Content-Type: application/json" \
  --data '{
      "type":"grafana"
  }'

The above command returns JSON structured in the following way:

{
    "id": "CFRPV98RPR1U8",
    "name": "Grafana :blush:",
    "team_id": null,
    "link": "{{API_URL}}/integrations/v1/grafana/mReAoNwDm0eMwKo1mTeTwYo/",
    "type": "grafana",
    "default_route": {
        "id": "RVBE4RKQSCGJ2",
        "escalation_chain_id": "F5JU6KJET33FE",
        "slack": {
            "channel_id": "CH23212D"
        }
    },
    "templates": {
        "grouping_key": null,
        "resolve_signal": null,
        "slack": {
            "title": null,
            "message": null,
            "image_url": null
        },
        "web": {
            "title": null,
            "message": null,
            "image_url": null
        },
        "email": {
            "title": null,
            "message": null
        },
        "sms": {
            "title": null
        },
        "phone_call": {
            "title": null
        },
        "telegram": {
            "title": null,
            "message": null,
            "image_url": null
        }
    }
}

Integrations are sources of alerts and alert groups for Grafana OnCall. For example, to learn how to integrate Grafana OnCall with Alertmanager see [Alertmanager]({{< relref "../integrations/add-alertmanager" >}}).

HTTP request

POST {{API_URL}}/api/v1/integrations/

Get integration

curl "{{API_URL}}/api/v1/integrations/CFRPV98RPR1U8/" \
  --request GET \
  --header "Authorization: meowmeowmeow" \
  --header "Content-Type: application/json"

The above command returns JSON structured in the following way:

{
    "id": "CFRPV98RPR1U8",
    "name": "Grafana :blush:",
    "team_id": null,
    "link": "{{API_URL}}/integrations/v1/grafana/mReAoNwDm0eMwKo1mTeTwYo/",
    "type": "grafana",
    "default_route": {
        "id": "RVBE4RKQSCGJ2",
        "escalation_chain_id": "F5JU6KJET33FE",
        "slack": {
            "channel_id": "CH23212D"
        }
    },
    "templates": {
        "grouping_key": null,
        "resolve_signal": null,
        "slack": {
            "title": null,
            "message": null,
            "image_url": null
        },
        "web": {
            "title": null,
            "message": null,
            "image_url": null
        },
        "email": {
            "title": null,
            "message": null
        },
        "sms": {
            "title": null
        },
        "phone_call": {
            "title": null
        },
        "telegram": {
            "title": null,
            "message": null,
            "image_url": null
        }
    }
}

This endpoint retrieves an integration. Integrations are sources of alerts and alert groups for Grafana OnCall.

HTTP request

GET {{API_URL}}/api/v1/integrations/<INTEGRATION_ID>/

List integrations

curl "{{API_URL}}/api/v1/integrations/" \
  --request GET \
  --header "Authorization: meowmeowmeow" \
  --header "Content-Type: application/json"

The above command returns JSON structured in the following way:

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": "CFRPV98RPR1U8",
            "name": "Grafana :blush:",
            "team_id": null,
            "link": "{{API_URL}}/integrations/v1/grafana/mReAoNwDm0eMwKo1mTeTwYo/",
            "type": "grafana",
            "default_route": {
                "id": "RVBE4RKQSCGJ2",
                "escalation_chain_id": "F5JU6KJET33FE", 
                "slack": {
                    "channel_id": "CH23212D"
                }
            },
            "templates": {
                "grouping_key": null,
                "resolve_signal": null,
                "slack": {
                    "title": null,
                    "message": null,
                    "image_url": null
                },
                "web": {
                    "title": null,
                    "message": null,
                    "image_url": null
                },
                "email": {
                    "title": null,
                    "message": null
                },
                "sms": {
                    "title": null
                },
                "phone_call": {
                    "title": null
                },
                "telegram": {
                    "title": null,
                    "message": null,
                    "image_url": null
                }
            }
        }
    ]
}

HTTP request

GET {{API_URL}}/api/v1/integrations/

Update integration

curl "{{API_URL}}/api/v1/integrations/CFRPV98RPR1U8/" \
  --request PUT \
  --header "Authorization: meowmeowmeow" \
  --header "Content-Type: application/json" \
  --data '{
      "templates": {
          "grouping_key": null,
          "resolve_signal": null,
          "slack": {
             "title": null,
             "message": null,
             "image_url": null
          }
      }
  }'

The above command returns JSON structured in the following way:

{
    "id": "CFRPV98RPR1U8",
    "name": "Grafana :blush:",
    "team_id": null,
    "link": "{{API_URL}}/integrations/v1/grafana/mReAoNwDm0eMwKo1mTeTwYo/",
    "type": "grafana",
    "default_route": {
        "id": "RVBE4RKQSCGJ2",
        "escalation_chain_id": "F5JU6KJET33FE",
        "slack": {
            "channel_id": "CH23212D"
        }
    },
    "templates": {
        "grouping_key": null,
        "resolve_signal": null,
        "slack": {
           "title": null,
           "message": null,
           "image_url": null
        },
        "web": {
            "title": null,
            "message": null,
            "image_url": null
        },
        "email": {
            "title": null,
            "message": null
        },
        "sms": {
            "title": null
        },
        "phone_call": {
            "title": null
        },
        "telegram": {
            "title": null,
            "message": null,
            "image_url": null
        }
    }
}

HTTP request

PUT {{API_URL}}/api/v1/integrations/<INTEGRATION_ID>/

Delete integration

Deleted integrations will stop recording new alerts from monitoring. Integration removal won't trigger removal of related alert groups or alerts.

curl "{{API_URL}}/api/v1/integrations/CFRPV98RPR1U8/" \
  --request DELETE \
  --header "Authorization: meowmeowmeow"

HTTP request

DELETE {{API_URL}}/api/v1/integrations/<INTEGRATION_ID>/