- Which API should I use?
- Jira API
- Script context variables
- Domain APIs
- Scenarios API
- API reference pages
- Next steps
Which API should I use?
| What you need | API | Page |
|---|---|---|
| Search, create, update, or transition issues | Issues |
Issues |
| Work with users, projects, fields, components, versions | Users, Projects, Fields, Components, Versions |
Jira Entities |
| Manage boards, sprints, and epics | Boards, Sprints, Epics |
Jira Entities |
| List attachments or copy them between issues | Attachments |
Jira Entities |
| Work with groups, filters, labels, permissions | Groups, Filters, Labels, JQL, Permissions |
Jira Entities |
| Access admin objects (workflows, screens, schemes, roles) or JSM Assets | Workflows, WorkflowSchemes, Screens, Roles, … , Assets |
Configuration & Assets |
| Work with service desks, customer requests, SLA, approvals, participants | JSM |
Service Management |
| Store structured data | tables |
Tables |
| Process messages asynchronously | queue |
Queues |
| Trigger scripts from other scripts | asyncEvent |
Async Events |
| Customize issue forms at runtime | uim |
UI Modifications |
| Build rich text (ADF), work with dates, arrays, strings, CSV | Adf, DateUtils, Arrays, Strings, CSV, Validator |
Utilities |
| Use smart value methods on strings, arrays, dates | .capitalize(), .distinct(), .plusDays() |
Smart Value Methods |
| Simple issue helpers without rich objects | Jira.* |
This page (below) |
| Call a Jira REST endpoint not covered above | requestJira() |
This page (below) |
Jira API
JiBrok Studio provides two levels of Jira API access:
- High-level API namespaces (
Issues,Users,Projects, etc.) - smart field resolution, auto-transforms, rich objects - Low-level
requestJira()- direct REST API calls for anything not covered by the namespaces
In between sits the Jira namespace with a few mid-level helpers (see Jira namespace below).
| Level | Method | Details |
|---|---|---|
| High | Issues, Users, Projects, Fields, Components, Versions, Boards, Sprints, Epics, Links, Attachments, Groups, Filters, Labels, JQL, Permissions |
Issues, Jira Entities |
| High | JSM |
Service Management |
| Mid | Jira.* |
search, getIssue, createIssue, etc. |
| Low | requestJira() |
Direct REST API calls - GET, POST, PUT, DELETE |
Shared API call limit
All API calls share a single counter per script execution - across requestJira(), Jira.*, and all namespace methods. The exact limit depends on the trigger type (e.g. 40 for console, 20 for UIM) - see the per-trigger limits table.
// Each of these counts toward the shared API call limit:
requestJira("/rest/api/3/myself") // 1 call
Jira.search("project = TEST") // 1 call
Issues.get("TEST-1") // 1 call
Users.current() // 1 call (first time only)
List methods and pagination
List methods (Users.find, Users.findAssignable, Projects.list, Fields.getContexts, Fields.getOptions, Groups.find, Groups.getMembers, Groups.getBulk, Labels.list, Boards.list, Boards.getSprints, Statuses.list, issue.getComments, …) return every page of the underlying endpoint, not only the first one. A loop over the result therefore sees the complete list.
- Every page is a separate API call and counts against the per-trigger limit.
- At most 20 pages are fetched. A list longer than that comes back truncated - narrow the query, or page manually.
- Passing
startAtormaxResultsswitches the method back to a single request with exactly those parameters. Groups.find(query)with a query uses the group picker, which cannot be paged: one request, at most 200 groups. Without a query it walks all groups.
// Every group, one API call per page
const groups = Groups.find()
// Exactly one request - useful when the API budget is tight
const firstTen = Groups.getBulk({ maxResults: 10 })
Admin namespaces that expose both list() and listAll() keep them distinct: list(opts?) reads a single page, listAll() walks all of them. See Configuration & Assets.
JSM list methods are the exception: each call reads one page, controlled by start / limit - see Service Management.
Jira namespace
The Jira object provides mid-level helper methods. These are simpler than the API namespaces but more convenient than raw requestJira().
| Method | Description |
|---|---|
Jira.search(jql, options?) |
Search issues via JQL - one page; options: { fields?, maxResults?, nextPageToken?, expand? }; returns { issues, nextPageToken, isLast } |
Jira.getIssue(issueKey, options?) |
Get a single issue |
Jira.createIssue(fields) |
Create a new issue |
Jira.updateIssue(issueKey, fields) |
Update an existing issue |
Jira.deleteIssue(issueKey) |
Delete an issue |
Jira.addComment(issueKey, body) |
Add a comment (string or ADF) |
Jira.transition(issueKey, transitionId, options?) |
Transition an issue by transition ID (string); options: { fields?, comment? } |
// Search
const result = Jira.search("project = TEST AND status = Open", {
fields: ["summary", "status"],
maxResults: 10,
})
// Get issue
const issue = Jira.getIssue("TEST-1")
log(issue.fields.summary)
// Create issue
const created = Jira.createIssue({
project: { key: "TEST" },
summary: "New task",
issuetype: { name: "Task" },
})
// Update
Jira.updateIssue("TEST-1", { summary: "Updated" })
// Transition
Jira.transition("TEST-1", "31", {
fields: { resolution: { name: "Done" } },
comment: "Closing this issue",
})
Jira.search sends fields as given - without it Jira returns only issue IDs, so list the fields you read. Each call is one request: page with nextPageToken.
All Jira.* methods throw on HTTP errors:
try {
Jira.getIssue("NOEXIST-999")
} catch (e) {
log(e.message) // => Jira.getIssue failed: 404 - <Jira error message>
}
requestJira(path, options)
Low-level Jira REST API call. Use this for endpoints not covered by the high-level namespaces.
requestJira(path, options?) -> { ok, status, body }
path- string, must start with/rest/options- optional object:method-"GET"(default),"POST","PUT", or"DELETE"body- request body (automatically serialized to JSON)
Response object:
| Property | Type | Description |
|---|---|---|
ok |
boolean | true if HTTP status is 2xx |
status |
number | HTTP status code |
body |
any | Pre-parsed JSON response, or null if empty/not JSON |
requestJira() never throws on HTTP errors - check res.ok or res.status instead.
The body option accepts a plain JavaScript object. It is automatically serialized to JSON internally. Do not call JSON.stringify() on the body - doing so causes double serialization and may result in silent API errors.
// GET request (default)
const me = requestJira('/rest/api/3/myself')
log(me.body.displayName) // => current user's name
// POST with body
const count = requestJira('/rest/api/3/search/approximate-count', {
method: 'POST',
body: { jql: 'project = TEST' }
})
log(count.body.count) // => approximate number of matching issues
// Error handling
const res = requestJira('/rest/api/3/issue/BAD-1')
if (!res.ok) {
log(`Error: ${res.status}`) // => Error: 404
}
// Iterating over results
const found = requestJira('/rest/api/3/search/jql', {
method: 'POST',
body: { jql: 'project = TEST', fields: ['summary'], maxResults: 50 }
})
for (const issue of found.body.issues) {
log(issue.key)
}
// PUT (update)
const upd = requestJira('/rest/api/3/issue/TEST-1', {
method: 'PUT',
body: { fields: { summary: 'Updated summary' } }
})
log(upd.ok) // => true
// DELETE
const del = requestJira('/rest/api/3/issue/TEST-1', { method: 'DELETE' })
log(del.status) // => 204
Limits:
| Limit | Value |
|---|---|
| Max API calls per script | Depends on trigger type (shared with Jira.* and all API namespaces). See per-trigger limits |
| Max response size per call | 10 MB |
Exceeding either limit throws a catchable error:
try {
requestJira("/rest/api/3/myself")
} catch (e) {
log(e.message) // => requestJira: exceeded maximum API calls (40)
}
When to use requestJira vs API namespaces:
| Use case | Recommended |
|---|---|
| Common issue operations | Issues API - smart fields, auto-transforms |
| User lookup | Users API |
| Project info | Projects API |
| Endpoints not covered by namespaces | requestJira() |
| Need full control over request/response | requestJira() |
| Bulk operations with pagination | requestJira() with manual pagination |
Script context variables
Variables available in scripts depending on context:
| Variable | Available when | Description |
|---|---|---|
issueKey |
Issue key provided | The issue key string |
issue |
Issue context loaded | Issue data object |
context |
Always | Execution context metadata |
event |
Event/async/workflow post function/workflow validator triggers | Event payload |
webhook |
Webtrigger | Webhook request data (method, path, headers, body, query, rawBody) |
jqlFunction |
JQL Function trigger | Frozen object: name (string), operator (in/not in), args (native array, up to 10) |
event.transition |
Workflow post function/workflow validator trigger | Transition details (from_status, to_status, transitionName) |
event.modifiedFields |
Workflow validator trigger | Fields modified during the transition |
uim |
UIM triggers | UI modification methods |
uimData |
UIM triggers | Form field values and callback info |
currentUser |
Always | Current user info |
| Global vars | When defined | Variables from the global script |
Domain APIs
tables
See Data Storage for full details.
| Method | Description |
|---|---|
tables.get(tableName) |
Get table schema |
tables.rows(tableName, options?) |
Query rows with filtering and sorting |
tables.addRow(tableName, data) |
Add a single row |
tables.addRows(tableName, dataArray) |
Bulk insert multiple rows |
tables.updateRow(tableName, rowId, data) |
Update a row |
tables.deleteRow(tableName, rowId) |
Delete a single row |
tables.deleteRows(tableName, where) |
Delete rows matching filter (returns count) |
tables.findRow(tableName, where) |
Find first row matching filter |
tables.count(tableName, where?) |
Count rows (optionally filtered) |
queue
See Data Storage for full details.
| Method | Description |
|---|---|
queue.push(queueName, payload, priority?) |
Push a message |
queue.pull(queueName, count?) |
Pull messages for processing |
queue.consume(queueName, count?) |
Pull + auto-acknowledge |
queue.peek(queueName, count?) |
Preview without changing state |
queue.ack(messageId) |
Acknowledge a processed message |
queue.reject(messageId) |
Mark message as failed |
queue.requeue(messageId) |
Move failed message back to pending |
queue.size(queueName) |
Get pending message count |
queue.stats(queueName) |
Get full queue statistics |
asyncEvent
| Method | Description |
|---|---|
asyncEvent.push(scriptId, payload?, options?) |
Trigger another script asynchronously |
asyncEvent.pushSelf(payload?, options?) |
Trigger the current script asynchronously |
// Trigger another script
asyncEvent.push("550e8400-e29b-41d4-a716-446655440000", {
action: "process",
issueKey: "TEST-1"
})
// Trigger self with delay
asyncEvent.pushSelf({ step: 2 }, { delayInSeconds: 60 })
Scenarios API
Scenarios split long-running scripts into managed steps. Each step runs as a separate Forge event, avoiding execution timeouts for bulk operations. See Scenarios for the full guide.
Step functions
| Function | Description |
|---|---|
step(name, fn) |
One-time step. fn receives (ctx), return value stored in ctx[name] |
loop(name, fn, initialState) |
Repeatable step. fn receives (state, ctx). Call next(newState) to repeat, or return to finish |
batch(name, config, fn) |
Process issues in pages. config is JQL string or config object. fn receives (issue, ctx) |
Batch config properties
| Property | Type | Default | Description |
|---|---|---|---|
jql |
string | - | JQL query (one of jql/keys/source required) |
keys |
string[] | - | Array of issue keys |
source |
function | - | (ctx) => keys[] - dynamic source |
fields |
string[] | all | Fields to load per issue |
expand |
string[] | none | Expand options |
batchSize |
number | 100 | Issues per page (max 100) |
maxIssues |
number | unlimited | Stop after this many |
continueOnError |
boolean | true | Continue on failure |
Data transfer functions
| Function | Description |
|---|---|
emit(value) |
Save a value to the step’s data buffer (call multiple times) |
getStepData(stepName, opts?) |
Read emitted data from a previous step. Returns { items, total } |
progress(data) |
Report custom progress data visible in the UI |
next(newState) |
Continue a loop() with updated state (only inside loop()) |
Example
step('count', () => {
return { total: Issues.count('project = PROJ') }
})
batch('cleanup', 'project = PROJ AND updated < -180d', (issue) => {
issue.transition('Done')
})
step('report', (ctx) => {
log(`Done: ${ctx.cleanup.processed}/${ctx.count.total}, ${ctx.cleanup.failed} errors`)
})
API reference pages
Detailed reference for each API area:
- Issues - Search, create, update, transition issues. RichIssue properties and methods, SearchResult, Smart Field Resolution, ChainablePromise.
- Jira Entities - Users, Projects, Fields (incl. context options), Components, Versions, Boards, Sprints, Epics, Links, Attachments, Groups, Filters, Labels, JQL, Permissions. User and Project wrapper objects.
- Configuration & Assets - Administration namespaces (workflows, screens, schemes, roles) and JSM Assets (CMDB).
- Service Management -
JSMnamespace: service desks, queues, request types, customer requests, comments, SLA, participants, approvals, organizations, customers. - Async Events - asyncEvent.push and asyncEvent.pushSelf for triggering scripts asynchronously.
- Tables - Custom Tables API - CRUD, filtering, sorting, upsert, context-aware methods.
- Queues - Message Queue API - push, pull, consume, acknowledge, priority, statistics.
- UI Modifications - UIM API for modifying form fields on the issue create form and the JSM portal request create form.
- Utilities - Adf (builder + reader), DateUtils, Arrays, Strings, CSV, Validator.
- Smart Value Methods - String (28 methods), Array (9 methods), Date instance methods (arithmetic, navigation, formatting, comparison), Groovy date types.
Next steps
- Scripting Language - Language syntax and sandbox details
- Script Engine Reference - Built-in interactive reference with examples
- Use Cases - Practical scripting examples
- Scenarios - Multi-step scenarios for bulk operations
- Data Storage - Tables and queues usage
- Limits - All execution and storage limits
