Getting started overview
The Atlassian Jira API provides programmatic access to Jira Cloud instances, allowing developers to integrate, automate, and extend Jira functionalities. This guide outlines the essential steps to get started, from account creation and credential generation to executing a successful first API request. The Jira Cloud platform utilizes a RESTful API architecture, primarily supporting JSON for request and response bodies. Understanding the core authentication methods and API structure is foundational for successful integration.
The Jira API is extensive, covering various aspects of project management, issue tracking, and service desk operations. Developers can interact with issues, projects, users, workflows, and other Jira entities. Atlassian offers comprehensive getting started guides for Jira Cloud, detailed REST API v3 reference documentation, and SDKs in multiple programming languages to facilitate development.
This overview focuses on the most common path for initial access: using an API token for basic authentication. OAuth 2.0 is also supported for more secure and granular access, particularly for third-party applications, but typically involves a more complex setup process for initial development.
Quick Reference Steps
| Step | What to Do | Where |
|---|---|---|
| 1. Create Account | Sign up for an Atlassian Cloud account (Jira instance). | Atlassian Jira homepage |
| 2. Generate API Token | Create a personal API token for authentication. | Atlassian API tokens page |
| 3. Identify Jira URL | Locate your Jira Cloud instance URL. | Your Jira Cloud dashboard (e.g., your-domain.atlassian.net) |
| 4. Construct Request | Formulate an API request with authentication headers. | Your preferred development environment |
| 5. Execute Request | Send the API call and process the response. | Terminal (cURL), Python script, Node.js application |
Create an account and get keys
To access the Jira API, you must first have an active Atlassian Cloud account with a Jira instance. Atlassian offers a free plan for up to 10 users, which is suitable for development and testing purposes. If you do not already have an account, navigate to the Atlassian Jira homepage and follow the sign-up process to create a new Jira Cloud site.
1. Sign up for an Atlassian Cloud account
Visit the Atlassian Jira website and select the option to get started with Jira Software (or any other Jira product). You will be prompted to create an Atlassian account and set up a new Jira Cloud site (e.g., your-domain.atlassian.net). This domain will be crucial for all your API requests.
2. Generate an API token
Jira Cloud APIs typically use API tokens for basic authentication, especially for personal scripts and integrations. These tokens act as substitutes for your password. To generate one:
- Log in to your Atlassian Cloud account.
- Navigate to your Atlassian profile (usually by clicking your avatar in the top right corner).
- Go to Account settings.
- Select Security from the left-hand menu.
- Under the "API token" section, click Create and manage API tokens.
- Click Create API token, give it a descriptive label (e.g., "Jira API Test"), and then click Create.
- Copy the generated token immediately. This token is shown only once. If you lose it, you will need to generate a new one.
For detailed instructions on generating and managing API tokens, refer to the Atlassian documentation on API tokens.
3. Identify your Jira Cloud URL
Your Jira Cloud instance URL is the base URL for all your API calls. It typically follows the format https://your-domain.atlassian.net. You can find this by logging into your Jira instance and observing the URL in your browser's address bar.
Your first request
With your Atlassian Cloud account, Jira instance URL, and API token, you are ready to make your first API call. We will use the REST API v3 to fetch information about a project or a specific issue. This example demonstrates how to use basic authentication with your email and API token.
Authentication Header
API token authentication requires sending an Authorization header with your request. The value of this header is a Base64 encoded string of your_email:your_api_token.
Example: If your email is [email protected] and your API token is ABCDEFGHIJKLMN, you would encode [email protected]:ABCDEFGHIJKLMN.
Many programming languages and tools provide functions for Base64 encoding. For instance, in Python, you can use base64.b64encode(b"[email protected]:ABCDEFGHIJKLMN").decode("ascii").
Example: Get all projects (cURL)
This cURL command retrieves a list of all projects visible to your user. Replace your-domain, [email protected], and your_api_token with your actual values.
curl --request GET \
--url 'https://your-domain.atlassian.net/rest/api/3/project' \
--user '[email protected]:your_api_token' \
--header 'Accept: application/json'
A successful response will return a JSON array of project objects, each containing details like id, key, name, and self-referencing links.
Example: Get all projects (Python)
This Python script performs the same request, demonstrating how to construct the authentication header programmatically.
import requests
import json
import base64
JIRA_DOMAIN = "your-domain.atlassian.net"
JIRA_EMAIL = "[email protected]"
JIRA_API_TOKEN = "your_api_token"
# Base64 encode the email and API token
auth_string = f"{JIRA_EMAIL}:{JIRA_API_TOKEN}"
encoded_auth_string = base64.b64encode(auth_string.encode("utf-8")).decode("ascii")
headers = {
"Accept": "application/json",
"Authorization": f"Basic {encoded_auth_string}"
}
url = f"https://{JIRA_DOMAIN}/rest/api/3/project"
response = requests.get(url, headers=headers)
if response.status_code == 200:
print(json.dumps(response.json(), indent=2))
else:
print(f"Error: {response.status_code} - {response.text}")
Remember to replace the placeholder values for JIRA_DOMAIN, JIRA_EMAIL, and JIRA_API_TOKEN with your actual credentials.
Example: Get all projects (Node.js using fetch)
Here's how to achieve the same with Node.js, utilizing the built-in fetch API and Buffer for Base64 encoding.
const JIRA_DOMAIN = "your-domain.atlassian.net";
const JIRA_EMAIL = "[email protected]";
const JIRA_API_TOKEN = "your_api_token";
const authString = `${JIRA_EMAIL}:${JIRA_API_TOKEN}`;
const encodedAuthString = Buffer.from(authString).toString('base64');
const headers = {
"Accept": "application/json",
"Authorization": `Basic ${encodedAuthString}`
};
const url = `https://${JIRA_DOMAIN}/rest/api/3/project`;
fetch(url, {
method: 'GET',
headers: headers
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log(JSON.stringify(data, null, 2));
})
.catch(error => {
console.error('Error fetching projects:', error);
});
This Node.js example assumes a modern Node.js environment where fetch is available globally or polyfilled.
Common next steps
After successfully making your first API call, consider these common next steps to further integrate with the Jira API:
- Explore the API Reference: Dive into the Jira Cloud platform REST API v3 documentation to understand the full range of available endpoints for issues, users, workflows, and more.
- Create and Update Issues: Programmatically create new issues, update existing ones, add comments, and manage attachments. This is a common use case for automating bug reporting or task creation.
- Implement Webhooks: Set up Jira webhooks to receive real-time notifications when events occur in Jira, such as an issue being updated or a comment being added. This enables reactive integrations.
- Utilize Official SDKs: For more complex applications, consider using one of the official Jira SDKs (Java, Python, JavaScript, Ruby, Go, C#) to streamline API interactions and handle authentication more robustly.
- Implement OAuth 2.0: For production applications or integrations requiring user consent and broader access, transition from API tokens to OAuth 2.0 (3LO) for enhanced security and delegated authorization. This is particularly relevant for applications serving multiple users or organizations. The OAuth 2.0 framework is a widely adopted industry standard for secure delegated access, as defined by the IETF RFC 6749.
- Error Handling and Rate Limiting: Incorporate robust error handling into your code to gracefully manage API errors (e.g., 4xx client errors, 5xx server errors). Be aware of Jira API rate limits and implement retry mechanisms with exponential backoff to avoid being blocked.
Troubleshooting the first call
Encountering issues during your first API call is common. Here are some troubleshooting tips:
- 401 Unauthorized: This is typically an authentication issue.
- Double-check your email address and API token for typos.
- Ensure the API token is correctly Base64 encoded (
your_email:your_api_token). - Confirm the API token has not been revoked or expired. Regenerate it if necessary.
- Verify that the user associated with the API token has the necessary permissions to access the requested resource (e.g., viewing projects).
- 403 Forbidden: While related to authorization, this often means your authenticated user lacks specific permissions for the resource or action.
- Check your Jira user's global and project-specific permissions.
- For example, if you're trying to create an issue, ensure the user has 'Create Issues' permission in the target project.
- 404 Not Found: The requested resource or endpoint does not exist.
- Verify your Jira Cloud instance URL (
your-domain.atlassian.net). - Check the API endpoint path (e.g.,
/rest/api/3/project). Refer to the Jira API reference for correct paths. - Ensure the project key or issue ID you are trying to access actually exists.
- 429 Too Many Requests: This indicates you have hit a rate limit.
- Slow down your requests.
- Implement exponential backoff in your code to retry requests after increasing delays.
- Check the
Retry-Afterheader in the response, if present, for guidance on when to retry. - Incorrect JSON Payload: When sending POST/PUT requests, ensure your JSON body is valid and matches the expected schema for the endpoint. Use a JSON validator if unsure.
- Network Issues: Ensure your development environment has network access to
*.atlassian.net. Proxy or firewall settings might interfere.