---
title: "Jira"
description: "Open Jira Cloud issues from TRUSTIVAN findings and blocking verdicts, one per fact, and close them when the finding is resolved or suppressed."
---

TRUSTIVAN creates issues in a Jira **Cloud** project through the Jira REST API,
as the Atlassian account whose API token you give it. It is not a Jira app from
the Atlassian Marketplace, and nothing in Jira flows back: closing an issue in
Jira does not change the finding in TRUSTIVAN.

What it does do is keep the two in step from TRUSTIVAN's side. Each fact gets
one issue, labelled so it can be found again, and when the finding is resolved
or suppressed in TRUSTIVAN the issue is moved to a done status.

<Warning>
  Jira Cloud only. The requests use the v3 REST API, which Jira Data Center
  does not have; a Data Center site answers `404` and the destination reports
  the failure.
</Warning>

## Prerequisites

- **A Jira account for TRUSTIVAN to act as**, ideally a dedicated one, with
  permission in the project to browse, create issues and transition issues.
- **An API token** for that account, created in the Atlassian account settings
  under **Security → API tokens**. It is sent with the account's email address
  as HTTP Basic authentication.
- **The project key** (such as `SEC`) and, optionally, an issue type name.
  Without one, issues are created as `Task`.
- **An administrator of the TRUSTIVAN organization**, signed in with `curl` so
  `cookies.txt` holds the session (see the [quickstart](/getting-started/quickstart)).
  Changing notifications needs `webhooks:manage`, which an API key cannot hold.
- **A plan that includes webhooks.**

## Create the destination

```bash
curl -s -X POST https://app.trustivan.com/api/v1/notification-targets \
  -H 'Content-Type: application/json' \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')" \
  -d '{
        "name": "appsec-jira",
        "channel": "jira",
        "url": "https://acme.atlassian.net",
        "secret": "<API token>",
        "config": {
          "email": "svc-trustivan@acme.com",
          "project_key": "SEC",
          "issue_type": "Bug"
        },
        "events": ["verdict.recorded", "finding.state_changed"],
        "min_severity": "high"
      }'
```

`url` is the site's base URL, `https://` with no path. The token goes in
`secret` and is stored encrypted. `config` takes exactly `email`,
`project_key` and `issue_type`; any other key is a `400`.

## What opens and closes an issue

| Event | Opens an issue when | One issue per | Closed when |
|---|---|---|---|
| `verdict.recorded` | A verdict blocks a deployment | Verdict | Never: close it in Jira |
| `scan.completed` | A scan found new critical or high findings | Scan | Never: close it in Jira |
| `finding.state_changed` | A finding is reopened or has its status changed | Finding, by its fingerprint, which is stable across rescans | The finding is resolved or suppressed |
| `finding.sla_breached` | Findings newly pass their remediation deadline | Batch of breaches | Never: close it in Jira |

Every issue carries a label of the form `trustivan-<event>-<id>`. That label is
how TRUSTIVAN avoids a second issue for the same fact, and how it finds the
issue again to close it. Do not remove it.

To close an issue, TRUSTIVAN searches for the label, reads the issue's available
transitions and applies the one that leads to a status in Jira's **Done**
category, whatever the workflow calls it. If the workflow has no such transition
from where the issue sits, nothing is guessed: the destination's `last_error`
names the issue, and you close it yourself.

A finding that is resolved and then reopened within 30 days does not get a new
issue, and its closed issue is not reopened: TRUSTIVAN still holds the earlier
delivery for that fact. Reopen the issue in Jira if it should be tracked.

## Test it

```bash
curl -s -X POST "https://app.trustivan.com/api/v1/notification-targets/$TARGET_ID/test" \
  -b cookies.txt \
  -H "X-CSRF-Token: $(grep trustivan_csrf cookies.txt | awk '{print $7}')"

curl -s "https://app.trustivan.com/api/v1/notification-targets/$TARGET_ID" -b cookies.txt \
  | jq '.target | {enabled, last_success_at, last_error}'
```

The test creates a real issue titled "Test notification from TRUSTIVAN". Delete
it in Jira.

## Troubleshooting

| Symptom | Cause |
|---|---|
| `400` naming `email` or `project_key` | The setting is missing, or the email is not an address |
| `last_error` with a `401` or `403` | The token is wrong or revoked, or the account cannot create issues in the project. Replace the token with `POST /api/v1/notification-targets/{id}/rotate-secret` |
| `last_error` with a `404` | The site is Jira Data Center, or the base URL has a path |
| `last_error` with a `400` from Jira | The project has no issue type by that name, or requires a field TRUSTIVAN does not set |
| `last_error` names an issue it could not close | The workflow has no transition to a done status from the issue's current status |
| The destination was disabled automatically | Deliveries failed repeatedly. Fix the cause, then `PATCH` it with `{"enabled": true}` |

## See also

- [Send notifications to Slack, Jira and other tools](/how-to/configure-notifications):
  every channel, field and limit, and ServiceNow, which closes what it opens the
  same way
- [PagerDuty](/integrations/pagerduty)
- [Bulk triage](/how-to/bulk-triage): resolving findings closes their issues
