Use the REST API
Before you start
- You have the Advanced edition and an active license. See App Editions.
- You have an API token. The token works as the Jira administrator who created it. See Manage API tokens.
- You have a template for work items. A template for customer portal doesn’t work with the REST API.
Steps
Select Apps > Issue Templates Agent > Templates.
Select the rows of the templates you want to use, and select Use in REST API. The dialog shows the Rest API url and ready-made example request bodies for your templates. With one template selected, it shows a body for each shape below. With several templates, it shows only the body for new work items. You can also create an API token in the dialog, under Create new api token.


Send a
POSTrequest to the Rest API url. The URL already has the query parameterpath=/templates/run. Put the API token in theAuthorizationheader as the bare token value, without a prefix such asBearer. Send a JSON body in one of the two shapes below.
The example bodies in the dialog also contain a variables object with an actor, which is your account ID. The REST API ignores variables, so the body doesn’t need it. You can delete it or leave it in. The app takes the user from the API token. See Result.
The dialog fills in the smart values {{project.id}} and {{issue.id}} in the example bodies, so that you can paste them into a Jira Automation flow. Outside Jira Automation, replace them with real IDs. In the body for new work items, the dialog also leaves the placeholder {replace-with-issueTypeId} for you to replace.
Create new work items
{ "templates": [ { "projectIdOrKey": "SPACE_ID_OR_KEY", "issueTypeId": "WORK_TYPE_ID", "templateId": "TEMPLATE_ID" } ]}Each entry creates one work item. projectIdOrKey is the ID or key of the space, issueTypeId is the ID of the work type, and templateId is the ID of the template. None of them can be empty. One request can contain several entries with different templates, spaces, and work types.
Apply a template to an existing work item
{ "templates": [ { "issueIdOrKey": "WORK_ITEM_ID_OR_KEY", "templateId": "TEMPLATE_ID" } ]}The body has exactly one entry. You can’t apply several templates or several work items in one request. If a body fits both shapes, the app creates new work items.
Result
The response is plain text with a short message and a status code. If the call fails, the message tells you why, for example that the license is not active, the token is invalid, or the token owner isn’t allowed to make the call.
- Creating work items: the app responds with 201 as soon as it accepts the request. The response doesn’t contain the keys of the work items, and 201 doesn’t mean that they already exist. The app creates the work items, and the child work items of a template with a structure, a moment later. If Jira rejects a work item, for example because of a field value, the caller isn’t told. Only the Audit log records it. The token owner is the reporter, unless the template sets a Reporter.
- Applying a template: the app updates the work item before it responds with 200. If Jira rejects the update, the app responds with 422 and the work item stays unchanged. The user-related values of the template resolve for the Reporter of the template if it has one, and otherwise for the token owner.
Example: apply a template from Jira Automation
You can call the REST API from a Jira Automation flow with the Send web request action. This example lets users apply a template to any work item with a manual trigger. To choose a template in the flow without a token, see Use templates in Jira Automation.
Select Apps > Issue Templates Agent > Templates, select the row of the template, and select Use in REST API.
Copy the Rest API url. Under Create new api token, enter a label, select the plus icon, and copy the token. The dialog shows the token only once. Copy also the body under If you want to apply on the existing issue.
In Jira, select Settings > System > Global automation, select Create flow, and select Create from scratch.
Select the trigger Manual trigger from work item.
Add the action Send web request, and set it up:
- In Web request URL, paste the Rest API url.
- In HTTP method, select POST.
- In Web request body, select Custom data, and paste the body in Custom data.
{{issue.id}}is the work item that the flow runs on. - Under Headers, enter
Authorizationin Key and paste the token in Value, without a prefix such asBearer. Select Hidden, so that Jira masks the token.


Select Next, and then select Save and enable. Enter a name in Flow name, and select Turn on flow.
To run the flow, open a work item, select the lightning-bolt icon next to the status, and under Automations, select the name of the flow.
Jira Automation sends the request, and the app applies the template to the work item. The REST API acts as the token owner, not as the user who ran the flow. See Result and Rules for every call.
If the call fails, open the audit log of the flow. It shows the HTTP status and the message of the app. For example, a wrong token gives 401 and the message Unauthenticated request.
To create new work items instead, paste the body under If you want to create a new issue in step 5. It uses {{project.id}}, so the new work item gets the space of the work item that the flow runs on. Replace {replace-with-issueTypeId} with the ID of the work type.
Rules for every call
- The app checks the license before the token. A caller with a bad token on a site without the Advanced edition gets the license response, not 401.
- The app checks the token owner on every call, not only when it creates the token. The owner must hold the Administer Jira permission at that time. To apply a template to an existing work item, the owner must also hold the Edit work items permission on it. When the owner loses these permissions, every call with the owner’s tokens gets 403.
- The REST API doesn’t check template restrictions or the Enabled switch.
- For new work items, the app doesn’t check the Create work items permission of the token owner in the space. It checks only Administer Jira.