# Set up the Jira connection

An admin connects your Jira **site** once, and every team member connects their **own Jira
account** once. New here? Start with the [overview](https://docket.rocks/en/docs/jira-user-guide).

---

## Creating the service account token

*(Admin, once.)*

docket uses this token to read projects, issues and worklogs. It never writes to Jira.

1. Logged in as the **service account**, go to
   **[id.atlassian.com → Security → API tokens](https://id.atlassian.com/manage-profile/security/api-tokens)**.
2. Click **Create API token**, give it a label (e.g. `docket service account`) and select
   **exactly these two scopes**:

| Scope | What it's for |
|---|---|
| `read:jira-user` | Verify the token and read user info (e.g. display names for workload view) |
| `read:jira-work` | Read projects, issues, and worklogs from Jira |

3. Click **Create** and copy the token right away. Atlassian shows it only once.
4. Paste it into docket in Part 1 below.

> **Use a dedicated service account ("bot")**, not a real person's account. If that person leaves
> and their account is deactivated, the connection breaks.

### What the service account needs in Jira

Read access only, no write or admin rights:

- **Access to Jira**: a Jira seat in your Atlassian organization.
- **"Browse projects" on every project you link.** In a **team-managed** project, add the account
  under *Project settings → Access* with the role **Viewer**. In a **company-managed** project, it
  needs a project role with "Browse projects" in the project's permission scheme (often every
  logged-in user already has it).
- **"Browse users and groups"** (global permission): only needed to search Jira people when you
  map them to docket users (see *Questions about accounts and tokens* below).

Without read access to a project, Jira returns no issues instead of an error. docket detects this
and says so in red under **Project → Settings → Jira**.

Each person writes their time to Jira through their own connection (Part 2), so they need
permission to log work on the issue. The service account doesn't.

---

## Part 1: Admin connects your Jira site

*(Admin, once per Jira site.)*

1. Go to **Administration → Integrations** and click **Add connection**.
2. Fill in:
   - **Name**, e.g. "Company Jira".
   - **Site URL**: `https://yourcompany.atlassian.net`. docket looks up the Jira `cloud_id`
     from it.
   - **Service account email** and **API token** of the bot account.
   - **Time tracking backend**: leave on **Jira core worklogs** unless your team logs time with
     **Tempo Timesheets**. Then choose Tempo and enter the Tempo API token.
   - **Jira authors without a docket account** (on by default): for everyone who logs time in
     Jira but has no docket user, docket creates a **placeholder user**, so their time counts in
     budgets and reports (see [How time from Jira is handled](https://docket.rocks/en/docs/jira-sync-behaviour)). The
     **service a new placeholder starts with** sets the rate their time is billed at; you can
     change it per placeholder later. Without a service, their time stays read-only.
3. Click **Add connection**. docket checks the credentials against Jira right away: a green
   **active** badge means Jira is reachable, a red **auth failed** badge means the email or token
   is wrong or lacks access (fix it with ✎ **Edit**). **↻ Test** checks again at any time, e.g.
   after you rotate the token.

---

## Part 2: Each team member connects their Jira account

*(Everyone who books time on Jira tickets, once.)*

docket writes your time to Jira as you, so the hours appear under your name, not the bot's.

1. In your **profile settings** (your name → Settings), go to the **Jira** section and click
   **Connect with Jira**.
2. On Atlassian's page, pick your Jira site and click **Accept**. You land back in docket.
3. docket shows **Connected as** with your Jira name and a ✓/✗ list of your workspace's Jira
   sites:
   - **✓**: your time on that site's projects syncs to Jira.
   - **✗ Not shared with docket yet**: you didn't pick that site on Atlassian's page. Click
     **Add another Jira site** and pick it.
   - **✗** with another message: your Atlassian account can't reach that site, usually because
     you have no access there. Ask your admin.

> **If you skip this step**, you can still book time on Jira tickets, but it isn't sent to Jira.
> Those entries are flagged **"Not in Jira — connect your Jira account."** Once you've connected,
> docket sends them to Jira by itself.

**If the connection stops working** (you revoked it at Atlassian, or it went unused for about
three months), the Jira section says so and shows a **Reconnect Jira** button. Atlassian also asks
everyone to confirm the connection again once a year.

**Disconnecting:** the bin icon next to "Connected as" removes the connection from docket. To
withdraw docket's access completely, also remove docket in your Atlassian profile under
**[Connected apps](https://id.atlassian.com/manage-profile/apps)**.

### Alternative: a personal API token

Use this if **Connect with Jira** isn't shown, or if your company's Atlassian admin has blocked
connecting apps (Atlassian then shows a notice on its page):

1. With your **own** Atlassian account, go to
   **[id.atlassian.com → Security → API tokens](https://id.atlassian.com/manage-profile/security/api-tokens)**,
   click **Create API token**, give it a label (e.g. `docket`) and select **exactly these two
   scopes**:

| Scope | What it's for |
|---|---|
| `read:jira-user` | Verify the token (docket checks it can reach each connected site) |
| `write:jira-work` | Create, update, and delete your worklogs in Jira |

2. Click **Create** and copy the token right away. Atlassian shows it only once.
3. In docket's **Jira** section, click **Use an API token instead**, enter your **Atlassian email**
   and the token, leave the scope on **Default (all connections)** and click **Save token**.

One token works for every Jira site your Atlassian account can access.

---

## Questions about accounts and tokens

**Where do I find my Jira account ID?**
Usually you don't need it: docket reads it when you connect your Jira account. When an **admin**
maps a docket user to a Jira user by hand (Administration → Integrations → connection → User mapping),
typing a name or email in the Jira user field searches Jira live and fills in the accountId when
you pick a match. The search needs the service account to have Jira's global **"Browse users and
groups"** permission (Jira admin → **Global permissions**, granted to a group the service account
belongs to; full Jira admin rights aren't needed). If the search still finds nothing, enter the
accountId directly. You find it:

- **in your Jira profile:** your avatar (top right in Jira) → **Profile**. The account ID is in
  the page URL: `https://yourcompany.atlassian.net/jira/people/`**`5b10ac8d82e05b22cc7d4ef5`**
- **via the REST API:** while logged into Jira, open
  `https://yourcompany.atlassian.net/rest/api/3/myself` in your browser. The JSON response
  contains `"accountId": "..."`.

**Do I need a Jira licence for everyone?**
Yes. Everyone who logs time to Jira needs their own Atlassian account and connects it, because
their hours are written to Jira as them.

**What if we use Tempo for time tracking?**
Your admin sets **Tempo** on the connection. Worklogs are then written via the Tempo API with the
connection's token, and team members' own connections only tell docket who they are in Jira.

**Is my connection safe?**
Your connection (or API token) is stored encrypted and never shown again. Only you can manage it;
even admins can't see it. docket asks Atlassian only for what it needs: reading your Jira work and
user info, and writing your worklogs.

---

Next: **[link a project and start tracking time](https://docket.rocks/en/docs/jira-project-linking)**.