# Authenticate Jira and Confluence REST with an API token

URL: https://goingstellar.ro/reference/atlassian-rest-api/authentication-api-tokens/

Basic authentication sends the Atlassian account email and an API token in an Authorization header. The same credentials work on Jira (/rest/api/3/...) and on Confluence (/wiki/...), and every call runs with the permissions of the account that owns the token. A bad or missing credential does not produce a login page or a 403, so the first call to make is GET /rest/api/3/myself.

## Endpoints

| Method | Path | What it does |
|---|---|---|
| GET | `/rest/api/3/myself` | Returns the account the credentials belong to. Use it as the connectivity and identity check. |
| GET | `/wiki/rest/api/user/current` | Returns the same account as seen by Confluence. |

## Examples

### GET /rest/api/3/myself

Confirms the email and token are accepted by Jira and shows which account (and time zone) the calls will run as.

```bash
curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/myself'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/myself',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "accountId": "<accountId>",
 "accountType": "atlassian",
 "active": true,
 "timeZone": "Europe/Bucharest",
 "locale": "en_US",
 "groups": {
  "size": 6,
  "items": []
 },
 "applicationRoles": {
  "size": 1,
  "items": []
 },
 "expand": "groups,applicationRoles"
}
```

Response headers:

```
Content-Type: application/json;charset=UTF-8
```

Sent to Atlassian Cloud on 29 Nov 2026.

### GET /wiki/rest/api/user/current

Confirms the same email and token work on the Confluence side of the site, with no second credential.

```bash
curl \
  -u "you@example.com:$ATLASSIAN_API_TOKEN" \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/wiki/rest/api/user/current'
```

```python
import os
import requests

EMAIL = "you@example.com"
r = requests.get(
    'https://your-domain.atlassian.net/wiki/rest/api/user/current',
    auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)
```

Response: HTTP 200

```
{
 "type": "known",
 "accountId": "<accountId>",
 "accountType": "atlassian",
 "displayName": "<display name>",
 "locale": "en_US",
 "accountStatus": "active"
}
```

Sent to Atlassian Cloud on 29 Nov 2026.

### GET /rest/api/3/myself

Shows what a request with no Authorization header gets back, which is the same symptom as a wrong token.

```bash
curl \
  -H 'Accept: application/json' \
  'https://your-domain.atlassian.net/rest/api/3/myself'
```

```python
import requests

r = requests.get(
    'https://your-domain.atlassian.net/rest/api/3/myself',
    headers={'Accept': 'application/json'},
)
print(r.status_code, r.text)
```

Response: HTTP 401

```
Client must be authenticated to access this resource.
```

Sent to Atlassian Cloud on 29 Nov 2026.

## How it behaves

- The Authorization header is Basic followed by base64 of email:token. The API token takes the place of the password, and the Jira guide notes it keeps working when two-factor authentication or SAML is enabled for the organisation.
- GET /rest/api/3/myself answers 200 with the account's accountId, accountType, time zone and locale. The groups and applicationRoles objects are present with a size but an empty items list.
- GET /wiki/rest/api/user/current answers 200 with the same accountId under Confluence's own user shape (publicName, accountStatus, profilePicture).
- A request without credentials to the same myself endpoint answers 401 with a plain text body, not JSON.

## Pitfalls

- Use the account email as the user name. The token alone is not a credential, and the base64 step must encode the colon between the two parts.
- A 401 on myself covers both a missing and a wrong credential. Check the header is present before suspecting the token.
- Authorization follows the token owner. A script that works for an administrator can get 404 or 403 for the same call under a normal user.
- The guides recommend OAuth 2.0 (3LO) for anything beyond personal scripts and bots, and ask apps not to collect customers' API tokens.

## Questions and answers

### Which user name goes with an Atlassian API token?

The email address of the Atlassian account that created the token. The guides describe the credential as useremail:api_token, base64 encoded, sent as Authorization: Basic.

### Does the same token work for Jira and Confluence?

Yes. Both guides use the same email and token pair, and the runs above call myself on Jira and user/current on Confluence with one credential.

## Related

- [Requests without authentication](https://goingstellar.ro/reference/atlassian-rest-api/anonymous-requests/)
- [The api.atlassian.com gateway and the cloud id](https://goingstellar.ro/reference/atlassian-rest-api/api-gateway-cloud-id/)
- [The current user](https://goingstellar.ro/reference/atlassian-rest-api/myself-current-user/)
- [The current user in Confluence](https://goingstellar.ro/reference/atlassian-rest-api/confluence-current-user/)
- [HTTP status codes](https://goingstellar.ro/reference/atlassian-rest-api/http-status-codes/)

## Sources

- [Basic auth for REST APIs, Jira (Atlassian Developer)](https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/)
- [Basic auth for REST APIs, Confluence (Atlassian Developer)](https://developer.atlassian.com/cloud/confluence/basic-auth-for-rest-apis/)
- [Security for other integrations, Jira (Atlassian Developer)](https://developer.atlassian.com/cloud/jira/platform/security-for-other-integrations/)
- [Get current user (Jira REST API v3)](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-myself/#api-rest-api-3-myself-get)
- [Get current user (Confluence REST API v1)](https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-users/#api-wiki-rest-api-user-current-get)

