# Integrating with Webhooks

## Create an incident using our webhooks integration

Each webhook is unique to the service and escalation policy. Make sure you create a webhook integration and copy the webhook URL. [Know how](https://docs.spike.sh/integrations-guideline/create-integration-and-service-on-dashboard).

From your code, you can create an incident simply by making a **POST** request.

## Create an incident

<mark style="color:green;">`POST`</mark> `https://hooks.spike.sh/:token/push-events`

#### Path Parameters

| Name  | Type   | Description                               |
| ----- | ------ | ----------------------------------------- |
| token | string | Unique token for your webhook integration |

#### Request Body

| Name     | Type   | Description                                                                                                               |
| -------- | ------ | ------------------------------------------------------------------------------------------------------------------------- |
| title    | string | This will be the title of your incident. Failing to add this will create an empty incident. Read more about this below 👇 |
| body     | string | Accepts objects and strings. This data will be in your incident details                                                   |
| severity | string | <p>Sets the severity on your incident. Options are</p><p><strong>sev1, sev2, and sev3.</strong></p>                       |
| priority | string | <p>Sets the priority on your incident. Options are</p><p><strong>p1, p2, p3, p4, and p5</strong></p>                      |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
{ Ok: true }
```

{% endtab %}

{% tab title="500 Could not process your request." %}

```
{}
```

{% endtab %}
{% endtabs %}

The above request will create a new incident. Please make sure you have used the correct webhook URL. If you have copied the URL from the dashboard then the **token \_\*\*\*\***\_\*\* should already be present.\*\* A new incident is created soon as make a POST request. A successful request will get you 200 HTTP response status code.

### **When is a new incident NOT created?**

If the integration has an open incident (*not resolved state*) \_\_ with the same title then a new incident will NOT be created.

### What is the title's significance?

The **title** plays an important role really. A new incident will use this title and it will be sent on all alter channels. The title acts as a unique identifier to perform group actions, suppress repeated incidents and also to auto-resolve them.

### What happens if I miss adding a title?

Failing to add **title** would create incidents with no message. This also means that it will NOT group, suppress or auto-resolve these incidents.

{% hint style="info" %}
We highly recommend you add a title to your POST request while creating an incident
{% endhint %}

## Auto-resolve incident

<mark style="color:green;">`POST`</mark> `https://hooks.spike.sh/:token/push-events`

#### Path Parameters

| Name  | Type   | Description                               |
| ----- | ------ | ----------------------------------------- |
| token | string | Unique token for your webhook integration |

#### Request Body

| Name   | Type   | Description                                                                                                                                               |
| ------ | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status | string | **resolve**                                                                                                                                               |
| body   | string | As of now, you can add any message about the incident you would like here. Accepts objects too.                                                           |
| title  | string | This will be the title of your incident. Failing to add this will create an empty incident title with all other parameters. Read more about this below 👇 |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
{ Ok: true }
```

{% endtab %}

{% tab title="500 Could not process your request." %}

```
{}
```

{% endtab %}
{% endtabs %}

The above request will automatically resolve incidents. We use the title and the token to uniquely get open incidents and resolve them.

All you need is to add the **status parameter as 'resolve'** in your POST request. The rest of the parameters are the same as creating incident request.

{% hint style="warning" %}
Make sure to have the same **title while resolving,** otherwise it won't work.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.spike.sh/integrations-guideline/integrating-with-webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
