Automating Jira With the REST API: Practical Scripts in Node.js

When the UI is too slow, script it

Atlassian Automation covers most no-code needs. But for reports, bulk clean-ups, and integrations with other systems, the REST API is faster and more flexible.

Authentication

For scripts, use your email plus an API token (created at id.atlassian.com) with Basic auth. For apps used by others, use OAuth 2.0 or Forge.

const BASE = 'https://your-site.atlassian.net';
const auth = Buffer.from(`${process.env.JIRA_EMAIL}:${process.env.JIRA_TOKEN}`).toString('base64');
const headers = { Authorization: `Basic ${auth}`, Accept: 'application/json', 'Content-Type': 'application/json' };

Search With JQL

Jira Cloud's enhanced search endpoint uses token-based pagination:

async function search(jql, fields = ['summary', 'status', 'assignee']) {
  const issues = [];
  let nextPageToken;
  do {
    const res = await fetch(`${BASE}/rest/api/3/search/jql`, {
      method: 'POST',
      headers,
      body: JSON.stringify({ jql, fields, maxResults: 100, nextPageToken }),
    });
    if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
    const data = await res.json();
    issues.push(...data.issues);
    nextPageToken = data.nextPageToken;
  } while (nextPageToken);
  return issues;
}

const open = await search('project = SUP AND statusCategory != Done AND created >= -7d');
console.log(`${open.length} open tickets this week`);

Always check the current API docs — Atlassian deprecates older search endpoints over time.

Create an Issue

await fetch(`${BASE}/rest/api/3/issue`, {
  method: 'POST',
  headers,
  body: JSON.stringify({
    fields: {
      project: { key: 'SUP' },
      issuetype: { name: 'Task' },
      summary: 'Rotate expiring SSL certificate',
      description: {
        type: 'doc', version: 1,
        content: [{ type: 'paragraph', content: [{ type: 'text', text: 'Expires in 14 days.' }] }],
      },
    },
  }),
});

Descriptions and comments use Atlassian Document Format (ADF), not plain text.

Rate Limits

Jira Cloud rate-limits API calls. Handle 429 responses by waiting for the Retry-After header, and add small delays in bulk scripts.

Useful Script Ideas

  • Weekly SLA breach report to email or Slack
  • Find tickets with no assignee older than 3 days
  • Bulk-relabel issues after a component rename
  • Export data to a BI tool or Google Sheet
  • Sync Jira status with an external system

Safety

  • Test bulk updates on a sandbox or a small JQL first
  • Log every change your script makes
  • Store tokens in environment variables or a secret manager, never in code

Scripts turn hours of clicking into seconds. Start with read-only reports, then graduate to updates once you trust your JQL.

Arivanandhan Chitheshwaran