# Configuring OpsGenie to receive webhooks

### Preparing the OpsGenie app to use for alerting <a href="#opsgenieconfigurationtoreceivewebhooks-preparationstouseopsgenieforalerting" id="opsgenieconfigurationtoreceivewebhooks-preparationstouseopsgenieforalerting"></a>

1\. Activate the OpsGenie app on your Cloud instance.

* If you want to use an already existing Atlassian site, do the following:

&#x20;       a. Create a Jira Service Management project.

&#x20;       b. Create a team.

&#x20;       c. Add OpsGenie integration.&#x20;

{% hint style="info" %}
**Note**: If your site URL is `https://{your-atlassian-site}.atlassian.net`, the OpsGenie app will be accessible on the following link: `https://{your-atlassian-.site}.app.opsgenie.com/alert/list`.
{% endhint %}

* You can also register a new OpsGenie account in an independent way, without starting from a Jira project. In this case, a new Atlassian Cloud site will be automatically set up for you without Jira integration in place.

{% hint style="warning" %}
**Important**: If you opted for data storage in the EU, then the URL of your OpsGenie will contain an extra “.eu” segment, for example: `https://{your-atlassian-.site}.app.eu.opsgenie.com/alert/list`

The geological location of your instance will also impact the URL of the OpsGenie API.\
In the EU: [https://api.eu.opsgenie.com](https://api.opsgenie.com/v2/alerts/requests/:requestId)\
Everywhere else: [https://api.opsgenie.com](https://api.opsgenie.com/v2/alerts/requests/:requestId)

Please keep in mind that the Service URL in the auto-generated template has to be adjusted accordingly.
{% endhint %}

## Basic configuration (required)

1\. Acquire an API key so that Email This Issue for Jira will be able to authenticate with OpsGenie.&#x20;

{% hint style="info" %}
**Important**: There is a possibility for misconfiguration. If adding a new API key from the **Teams** tab using the **API key management** option under **APP SETTINGS**, the generated key can not be used for creating alerts. It is highly recommended to start the integration process from the **Settings** tab as described below!
{% endhint %}

Choose from the following options:

* Use the default integration configuration.&#x20;

&#x20;      a. Go to **Settings**, and choose **Configured Integrations** under **INTEGRATIONS.**

&#x20;       b. Select the Default API entry.

![](https://4173056255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY44m7ZY1jU4Arh2tzwNn%2Fuploads%2FPTI38JLzWO7K4ireNTVe%2Fimage.png?alt=media\&token=b596070f-2204-4a9d-a2d7-912908e3cbc0)

&#x20;      c. Use the API key in the default configuration without any changes as shown in the following image:

![](https://4173056255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY44m7ZY1jU4Arh2tzwNn%2Fuploads%2FReDkWR11T7p5x4ZE4DIX%2Fimage.png?alt=media\&token=32759d1c-3489-4bdc-bba1-5a4d4584908b)

* Create a new integration configuration.

&#x20;      a. Go to **Settings**, and choose **Integration list** under **INTEGRATIONS.**

&#x20;      b. Select the API option from the Integration list.

![](https://4173056255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY44m7ZY1jU4Arh2tzwNn%2Fuploads%2FoMdinZdURR8u8OTmsJPk%2Fimage.png?alt=media\&token=94f47b45-de9e-4fc1-b362-d2d623b8c469)

&#x20;       c. The API key is generated automatically. Select the **Create and Update Access** permission scope and the **Enabled** option as sown in the image below:

![](https://4173056255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY44m7ZY1jU4Arh2tzwNn%2Fuploads%2FUsWDHrNtuxlrvdm6ffEE%2Fimage.png?alt=media\&token=bcee8faa-9ce2-4530-810e-0d14c1cb4ea0)

{% hint style="warning" %}
**Important**: For **Free** and **Essentials** plans, the integrations can only be added from the Team Dashboards.
{% endhint %}

2\. To add the integration, do the following, as shown in the image below:

&#x20;   a. Go to **Teams**, and choose **Integrations**.

&#x20;   b. Click the **Add integration** button.

![](https://4173056255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FY44m7ZY1jU4Arh2tzwNn%2Fuploads%2FCIGA0o8l8ZREWhkHydxK%2Fimage.png?alt=media\&token=b5ac8d2a-e8e2-4211-a835-43dadd01b732)

For more information, see the API Integration documentation: <https://docs.opsgenie.com/docs/api-integration>.

## Creating alerts with custom content (optional)

Although Email This Issue for Jira provides you with a general-purpose template to create alerts in OpsGenie, you may want to further customize the posted request.&#x20;

### **Headers**

* Content-type: `application/json` (automatically added)
* Authorization: GenieKey *`<api key>`*

### **Message payload (JSON body)**

The request body may be enriched with the following fields that are parsed by OpsGenie while creating the alert based on the incoming request:

| **Field**     | **Requirement** | **Description**                                                                                                                                                                                                                                               | **Limit**             |
| ------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| `message`     | Mandatory       | The message of the alert.                                                                                                                                                                                                                                     | 130 characters        |
| `alias`       | Optional        | This field is used for alert de-duplication. When there is an open alert with the same alias, no new alert is created, only a counter is incremented. After closing this alert, and there is a new alert with the same alias sent in, a new alert is created. | 512 characters        |
| `description` | Optional        | Generally used for providing a detailed information about the alert.                                                                                                                                                                                          | 15000 characters      |
| `tags`        | Optional        | The tags of the alert.                                                                                                                                                                                                                                        | 20 x 50 characters    |
| `details`     | Optional        | The map of key-value pairs to use as custom properties of the alert.                                                                                                                                                                                          | 8000 characters total |
| `entity`      | Optional        | Generally used for specifying, which domain the alert is related to.                                                                                                                                                                                          | 512 characters        |
| `priority`    | Optional        | The priority level of the alert. Its possible values are **P1**, **P2**, **P3**, **P4** and **P5**. The default value is **P3**.                                                                                                                              |                       |

For more details, see the Alert API documentation: <https://docs.opsgenie.com/docs/alert-api>
