# Update a Jira integration

Updates the settings of a Jira integration, the same settings as its **Configure** page. Send only the parameters you wish to change.

Connect the integration in **Errors** → [Integrations](https://errors.betterstack.com/team/0/integrations/) first, since connecting Jira needs you to authorize Better Stack in Jira.

[endpoint]
base_url = "https://errors.betterstack.com"
path = "/api/v1/jira-integrations/{id}"
method = "PATCH"

[[path_param]]
name = "id"
description = "The ID of the Jira integration, the number in the URL of its **Configure** page."
required = true
type = "string"

[[body_param]]
name = "applications"
description = "The applications whose errors the integration handles, replacing the whole list. Each is an object with the `application_id` of an error tracking application in the integration's team and optionally its `environments`, a list of environment names where empty or left out means every environment. Send `[]` for any application."
required = false
type = "array of objects"

[[body_param]]
name = "notifications"
description = "The **Automatic work item creation** toggles to change, as booleans. Toggles you leave out keep their value. The keys are `spikes`, `new_errors`, `automatically_reopened`, `occurrence_milestones`, `occurrence_threshold`, `affected_users_threshold`."
required = false
type = "object"

[[body_param]]
name = "occurrence_threshold_count"
description = "How many occurrences within `occurrence_threshold_interval` trigger `notifications.occurrence_threshold`. A positive whole number."
required = false
type = "integer"

[[body_param]]
name = "occurrence_threshold_interval"
description = "The interval of the occurrence threshold: `minute`, `hour`, `day`, or `week`."
required = false
type = "string"

[[body_param]]
name = "affected_users_threshold_count"
description = "How many affected users in total trigger `notifications.affected_users_threshold`. A positive whole number."
required = false
type = "integer"

[[body_param]]
name = "tag_filter"
description = "Only create work items for errors where at least one exception has every tag listed, with one of its values, replacing the whole list. Each row is an object with a `tag` and its `values`, a list of strings. Use a tag once, at most 10 rows, 50 values per tag and 200 characters per tag or value. Send `[]` for every error."
required = false
type = "array of objects"

[[body_param]]
name = "name"
description = "The name that identifies the integration in Better Stack."
required = false
type = "string"

[[body_param]]
name = "jira_project_key"
description = "The key of the Jira space work items are created in. A new space needs `jira_issue_type_id` in the same request, and clears `jira_fields` unless the request sets them. The space, work type and fields can't change until Jira is connected, or while its authorization has expired."
required = false
type = "string"

[[body_param]]
name = "jira_issue_type_id"
description = "The ID of the Jira work type new work items get. Can't be empty."
required = false
type = "string"

[[body_param]]
name = "jira_fields"
description = "The values of other Jira fields new work items get, keyed by Jira field ID, replacing the whole object. To see the IDs and value shapes, fill the fields in on the **Configure** page once and read them back with a GET."
required = false
type = "object"

[[header]]
name = "Authorization"
description = "Bearer `$TOKEN`"
required = true
type = "string"

[[header]]
name = "Content-Type"
description = "application/json"
required = true
type = "string"
[/endpoint]

[responses]
[[response]]
status = 200
description = '''Returns the updated Jira integration.'''
body = '''{
  "data": {
    "id": "31174",
    "type": "jira_integration",
    "attributes": {
      "team_id": "t123456",
      "team_name": "My team",
      "applications": [
        { "application_id": 1234, "environments": [] }
      ],
      "notifications": {
        "spikes": false,
        "new_errors": false,
        "automatically_reopened": false,
        "occurrence_milestones": false,
        "occurrence_threshold": false,
        "affected_users_threshold": true
      },
      "occurrence_threshold_count": 10,
      "occurrence_threshold_interval": "minute",
      "affected_users_threshold_count": 25,
      "tag_filter": [],
      "name": "Ops errors",
      "jira_site_url": "https://example.atlassian.net",
      "jira_project_key": "OPS",
      "jira_issue_type_id": "10002",
      "jira_fields": {
        "labels": ["errors"]
      }
    }
  }
}'''

[[response]]
status = 401
description = '''Unauthorized'''
body = '''{
  "errors": "Invalid Team API token. How to find your Team API token: https://betterstack.com/docs/logs/api/getting-started/#obtaining-a-logtail-api-token"
}'''

[[response]]
status = 404
description = '''Not Found'''
body = '''{
  "errors": "Resource with the provided ID was not found"
}'''

[[response]]
status = 422
description = '''Returned when a value can't be applied. The error says which and why.'''
body = '''{
  "errors": "Pass jira_issue_type_id with a new jira_project_key: work types belong to a space."
}'''
[/responses]

#### Example cURL

[code-tabs]
```shell
[label Create work items in another space]
curl --request PATCH \
  --url https://errors.betterstack.com/api/v1/jira-integrations/31174 \
  --header "Authorization: Bearer $TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
    "jira_project_key": "OPS",
    "jira_issue_type_id": "10002",
    "jira_fields": {
      "labels": ["errors"]
    }
  }'
```
```shell
[label Create work items for errors that affect 25 users]
curl --request PATCH \
  --url https://errors.betterstack.com/api/v1/jira-integrations/31174 \
  --header "Authorization: Bearer $TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{
    "notifications": {
      "affected_users_threshold": true
    },
    "affected_users_threshold_count": 25
  }'
```
[/code-tabs]
