API Tokens

API Tokens

 

General information

You can read more about Tokens here REST API Tokens


Get all Tokens

Method type: GET

URL: {JIRA_URL}/rest/extender/1.0/tokenTools/get

Respons format: JSON

Example response:

{ "total": 2, "pages": 1, "maxResults": 50, "startAt": 0, "tokens": [ { "authorKey": "JIRAUSER1010", //empty if token for user was generated by Jira Administrator "userKey": "JIRAUSER1010", "userDisplayName": "Jira Administrator", "label": "Token name", "user": "admin", "token": "ip9ul19f8jenb92tji8lo34qt7tb1meo", //not available in secure mode "id": "AXEQQSwYJYRAQ69YkhGJIh3gBBawC4RbG6+hdNOXAjXAVO56ummCoBRPLVWFuhlDnsmT1cWf56rXDj78q9fmlg==", "limitTo": "[post].*/rest/api/2/issue/KANBAN-100/comment.*<br>.*/rest/api/2/issue/SCRUM-[1-2]{1}/comment.*", "ip": "", "validUntil": 1630476718964, "dateCreated": 1622700718964, "counter": 100 }, { "authorKey": "JIRAUSER1010", //empty if token for user was generated by Jira Administrator "userKey": "JIRAUSER1010", "userDisplayName": "Jira Administrator", "label": "Token name two", "user": "jankowalski", "token": "okf8a73basc74nasc9n32", //not available in secure mode "id": "AXEQQSwYJYRAQ6hGJIhBawCG6+OXAjXV56umoRPLVWFuhlDnsmT1cWf56rXDj78q9fmlg==", "limitTo": "", "ip": "192.168.1.1", "validUntil": 1630476718964, "dateCreated": 1622700718964, "counter": 123456 } ], "status": "ok" }

 


Create Token

Method type: POST

URL: {JIRA_URL}/rest/extender/1.0/tokenTools/set

Request format: JSON

Example request:

{ "label": "Token name", "daysUntilExpiry": 90, "userName": "admin", "limitTo": "[post].*/rest/api/2/issue/KANBAN-100/comment.*\n.*/rest/api/2/issue/SCRUM-[1-2]{1}/comment.*" }
{ "label": "Token name", "daysUntilExpiry": 0 "token": "ip9ul19f8jenb92tji8lo34qt7tb1meo" }
{ "label": "Token name YXZ", "userName": "admin" }
{ "label": "Token name ABC" }

label - required - token name

daysUntilExpiry - optional - for security reasons, you can set this token to automatically expire. You can't change the expiry date once the token is created.

userName - optional - a user who will be able to use the token, leave this field empty so that anyone can use the token (only for Jira Administrator)

limitTo - optional - you can limit the token to specific urls and methods, you can add new line sign using \n, \\n or <br>

token - optional - token, leave this field empty and the system will generate a random string

 


Delete Token

Method type: DELETE

URL: {JIRA_URL}/rest/extender/1.0/tokenTools/delete

Request format: JSON

Example request:

{ "token": "ip9ul19f8jenb92tji8lo34qt7tb1meo" }

 


Disable/Enable "Usage Details" data collection

Available ONLY for JIRA administrators

Method type: POST

URL: {JIRA_URL}/rest/extender/1.0/tokenTools/set

Request format: JSON

Example request:

{ "collectUsageDetails": false }
{ "collectUsageDetails": true }

 


Disable/Enable adding token calls to the audit log

Available ONLY for JIRA administrators

Method type: POST

URL: {JIRA_URL}/rest/extender/1.0/tokenTools/set

Request format: JSON

Example request:

{ "addAuditRecord": false }
{ "addAuditRecord": true }

 

 


Pagination

This REST API uses pagination to improve performance for all Jira users. Pagination is enforced for methods that could return a large collection of items. When you make a request to a paged API, the response will wrap the returned array of values in a JSON object with paging metadata, for example:

{ "startAt" : 0, "maxResults" : 10, "total": 200, "tokens": [ { /* result 0 */ }, { /* result 1 */ }, { /* result 2 */ } ] }

Where:

  • startAt is the index of the first item returned in the page of results.

  • maxResults is the maximum number of items that can be returned per page. Each API endpoint may have a different limit for the number of items returned, and these limits may change without notice. (default value - 1000)

  • total is the total number of items contained in all pages. This number may change as the client requests the subsequent pages, therefore the client should always assume that the requested page can be empty.

 


Changes

Since v. 1.70.*

Since v. 2.19.*

Since v. 6.23.*

  • The API is now accessible to all users, subject to the maintenance of appropriate permissions

  • Added paging functionality and an enhanced API for token fetching tokens