The Jira Cloud REST API is a set of HTTPS endpoints that allow you to programmatically create, read, update, and delete issues and project data. Most users mistakenly try to use their account password for authentication, but Jira Cloud requires an API token for basic authentication.

Authentication Uses API Tokens Not Passwords

To interact with the Jira Cloud API, you must authenticate your requests. Using your standard login password in a script will result in a 401 Unauthorized error. You must generate an API token from your Atlassian account settings. This token acts as a secure key that you can revoke at any time without changing your main password.

Once you have the token, you use Basic Authentication. This involves a base64 encoded string consisting of your email address and the API token, separated by a colon. Most modern programming libraries handle this encoding for you if you provide the email and token as separate credentials. Ensure you store this token in an environment variable rather than hard-coding it into your scripts to prevent accidental exposure.

API Endpoints Vary by Data Type

The Jira Cloud API is split into several functional areas. The most common is the Jira Software API, which handles issues, boards, and sprints. Other endpoints handle user management or project configuration. Each request must target a specific URL structure that includes your site domain. For example, a request to get a single issue will always target the /issue endpoint followed by the specific issue key.

Resource Common HTTP Method Typical Use Case
/issue GET, POST, PUT Fetching details or creating new tickets
/project GET Listing project leads and keys
/search POST Running JQL queries to find multiple issues
/user GET Finding account IDs for assignees

JQL Queries Power the Search Endpoint

While you can fetch a single issue by its key, you often need to find a group of issues based on specific criteria. For this, you use the /search endpoint. This endpoint accepts Jira Query Language (JQL), which is the same syntax used in the Jira web interface search bar. JQL allows you to filter by project, status, assignee, or custom fields.

When using the search endpoint, you can choose between a GET request with query parameters or a POST request with a JSON body. A POST request is preferred for complex JQL strings to avoid URL length limits. You can also specify exactly which fields you want returned using the "fields" parameter. Requesting only the summary and status instead of all available fields reduces the payload size and speeds up your script execution.

Handling Pagination in Large Result Sets

The API does not return every matching issue in a single response. It uses pagination to protect server performance. By default, the API returns a limited number of results, typically 50. To get more, you must use the "startAt" parameter. If the response indicates there are more results than the current page size, your script should loop, increasing the "startAt" value by the page size until all issues are retrieved. This prevents your application from timing out when dealing with thousands of tickets.

JSON Body Structure for Issue Updates

Updating an issue requires a PUT request to the /issue endpoint. The body must be a JSON object. A common mistake is sending the entire issue object back to the server. You only need to send the specific fields you wish to change. These changes must be nested inside a "fields" object.

Updating certain fields requires specific formats. For example, changing the summary is a simple string update. However, updating a dropdown menu or a status requires an object containing an "id" or a "name". If you provide a value that does not exist in the project's configuration, the API will return a 400 Bad Request error. Always verify the exact ID of the status or option via a GET request before attempting a PUT update.

Updating Issue Statuses via Transitions

You cannot change an issue's status by simply updating the "status" field. Status changes in Jira are governed by workflows. To move an issue from "To Do" to "Done", you must use the /transitions endpoint. First, perform a GET request to see which transitions are available for that specific issue. Each transition has a unique ID. You then send a POST request to the transitions endpoint with the ID of the desired destination status. This ensures that all workflow validators and post-functions are triggered correctly.

Example Request to Create an Issue

To create a new issue, you send a POST request to /rest/api/3/issue. The request body must define the project, the issue type, and the summary. The following example demonstrates the JSON structure required for a basic task creation.

{
  "fields": {
    "project": {
      "key": "PROJ"
    },
    "summary": "Fix login page alignment",
    "description": {
      "type": "doc",
      "version": 1,
      "content": [
        {
          "type": "paragraph",
          "content": [
            {
              "type": "text",
              "text": "The login button is shifted 5px to the left on mobile devices."
            }
          ]
        }
      ]
    },
    "issuetype": {
      "name": "Task"
    }
  }
}

Note that in API version 3, the description field uses the Atlassian Document Format (ADF) rather than plain text or HTML. This is a structured JSON format that allows for rich text. If you find ADF too complex for simple scripts, you can use API version 2, which accepts plain strings for descriptions, though version 3 is the current standard for Cloud.

Common API Errors and Fixes

When a request fails, Jira returns a standard HTTP status code. Understanding these codes allows you to debug your integration quickly. A 400 error usually means your JSON is malformed or you are missing a required field, such as the project key. A 401 error almost always points to an incorrect API token or an incorrectly formatted Basic Auth header.

A 403 Forbidden error occurs when the user associated with the API token does not have the necessary permissions in Jira. For example, if you try to delete an issue but your account only has "Browse Project" permissions, the API will block the request. Check the Project Permissions settings in the Jira UI to ensure the account has the "Edit Issue" or "Transition Issue" permission.

Status Code Meaning Primary Fix
400 Bad Request Check JSON syntax and required fields
401 Unauthorized Regenerate API token and check email
403 Forbidden Verify user permissions in Project Settings
404 Not Found Verify the Issue Key or Project Key exists
429 Too Many Requests Implement a retry delay (exponential backoff)

If you receive a 429 error, it means you have hit the rate limit. Jira Cloud limits the number of requests to ensure stability. To fix this, implement a sleep timer in your code. Instead of sending 100 requests in one second, space them out or use a library that handles exponential backoff, which increases the wait time between retries after each failure.