Going Stellar

Home/Atlassian REST API reference

Jira and Confluence Cloud REST API

Authenticate Jira and Confluence REST with an API token

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

MethodPathWhat it does
GET/rest/api/3/myselfReturns the account the credentials belong to. Use it as the connectivity and identity check.
GET/wiki/rest/api/user/currentReturns 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.

curl

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

Python (requests)

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 .

GET /wiki/rest/api/user/current

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

curl

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

Python (requests)

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 .

GET /rest/api/3/myself

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

curl

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

Python (requests)

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 .

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.

Sources

  1. Basic auth for REST APIs, Jira (Atlassian Developer)
  2. Basic auth for REST APIs, Confluence (Atlassian Developer)
  3. Security for other integrations, Jira (Atlassian Developer)
  4. Get current user (Jira REST API v3)
  5. Get current user (Confluence REST API v1)

Markdown version · All REST API pages