# Create an incident

Automatically create Uptime incidents from Jira by using our [Incidents API](https://betterstack.com/docs/uptime/api/getting-started-with-uptime-api/) and [Jira Automation](https://www.atlassian.com/software/jira/guides/expand-jira/automation ";_blank").

### 1. Create custom fields in Jira

To automatically acknowledge and resolve incidents in Uptime from Jira, you need to create two custom fields: `incident_id` and `BU_incident_url`.

1. In Jira, go to **Settings** → **Issues** → **Fields** → **Custom fields**.
2. Click **Create custom field**.
3. Select **Short text (plain text only)** and click **Next**.
    ![Custom field type.png](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/11a6d821-81f9-450d-6aba-fa3c71ea7800/md2x =1046x218)
4. Name the field `incident_id` and associate it with all screens.
5. Repeat the process to create a `BU_incident_url` field.

### 2. Set up a Jira automation rule

1. In your Jira project, go to **Project Settings** → **Automation**.
[info]
To apply this to all projects, go to **Global administration** and create a global rule.
[/info]
1. Click **Create rule**.
2. Select the **Issue created** trigger and click **Save**.
    ![Jira Trigger.png](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/1731c062-08a4-470d-01b1-c47773038200/public =740x316)
3. (Optional) Add a condition to specify when an incident should be created (e.g., for high-priority tickets).
    ![Jira Condition.png](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/36eccfe5-4b01-4274-4c2a-0680f10c9f00/lg2x =558x257)
4. Add a new action and select **Send web request**.
    ![Jira Action.png](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/f42aceb0-ced7-4adf-43f7-b474dd3a5300/public =748x266)
5. Configure the web request:  
      
    **Web request URL**: `https://uptime.betterstack.com/api/v2/incidents`  
    **Headers**: `Authorization: Bearer $TOKEN`  
    **HTTP Method**: `POST`  
    **Web request body**: `Custom data`

    ```json
    [label Custom data]
    {
        "name": "{{issue.key}} - {{issue.summary}}",
        "summary": "{{issue.key}} - {{issue.summary}}",
        "requester_email": "{{reporter.emailAddress}}",
        "description": {{issue.description.asJsonString}},
        "policy_id": "{UPTIME_POLICY_ID}"
    }
    ```
[note]
### Don't have an API token yet?
See our guide on [obtaining an API token](https://betterstack.com/docs/uptime/api/getting-started-with-uptime-api/).
[/note]
1. Check the box to **Delay execution of subsequent rule actions**.
2. Add a new action and select **Edit issue**.
    ![Jira Edit Issue.png](https://imagedelivery.net/xZXo0QFi-1_4Zimer-T0XQ/9840dec6-2189-4358-59a1-31fab9935a00/orig =303x109)
3. Set the `incident_id` field to `{{webResponse.body.data.id}}`.
4. Add another field to set `BU_incident_url` to `https://uptime.betterstack.com/team/{{YOUR_TEAM_ID}}/incidents/{{webResponse.body.data.id}}`.

[success]
## That's all. 🎉
From now on, a new Uptime incident will be created for each new Jira ticket that matches your conditions.
[/success]

[info]
### Need help with the Jira integration?
Please message us at **hello@betterstack.com**. We will help you with all the necessary configurations.
[/info]
