Automatically send an email to all members of a Jira project role
Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.
Summary
Sometimes we need to send emails to users in specific space roles. The send email action in Jira Automation can send emails only to user picker fields and groups.
In this article, we create an automation to retrieve users’ email addresses within a role and, with that, send emails to them.
This feature request is opened to have this implemented:
Solution
There's no single “email everyone on the space” button. The reliable pattern is a Jira Automation rule that iterates the space's role members (or a mailing group) and sends an email action.
Determine space and role IDs
Recipients will only receive the email if their email address is visible in their Atlassian account under Profile and visibility settings. Addresses hidden from other users will not resolve, so confirm visibility before relying on this rule. See: Update your profile and visibility settings.
Identify the role you would like to send the email to:
1. Access the following URL to get the list of the roles you have within the space,
2. The REST endpoint keys roles by ID, so you must use the numeric role ID from the /role/{roleid} path segment — the display name of the role will not work in the automation rule.
https://<yourinstance>.atlassian.net/rest/api/3/project/{projectid}/role/3. This endpoint lists roles available for your space
4 . You should be able to identify the role ID in the URLs listed, for example: /role/{roleid}
Note: When sending web requests in Jira, we use the Authentication header encoded as base64
Please follow the steps in this document to generate a new token: Automation for Jira - Send web request using Jira REST API
Automation rule to notify each email address in a space role
Trigger: Work item Created
You can select another trigger based on your requirements
Action: Send a web request
Request URL:
https://<yourinstance>.atlassian.net/rest/api/3/project/{projectid}/role/{roleid}Replace the
{projectid}and{roleid}with the appropriate values from above
Headers:
Authorization: Basic <base64_encoded_api_token>
Content-type: application/json
HTTP Method: GET
Web Request body: Empty
Delay execution...: checked
The first request returns account IDs, not email addresses. The advanced branch iterates each account ID as {{newusers}}, and the second request resolves each one to {{webResponse.body.emailAddress}} for the Send email action.
Add a Branch - Advanced branch:
Smart value:
{{webResponse.body.actors.actorUser.accountId}}Variablename: newusers
In our advanced branch, we will execute the subsequent actions for each of the results (each email address) as a variable, in this example {{newusers}}
Add a new Send web request action:
Request URL:
https://<yourinstance>.atlassian.net/rest/api/3/user/search?accountId={{newusers}}Headers:
Authorization: Basic <base64_encoded_api_token>
Content-type: application/json
HTTP Method: GET
Web Request body: Empty
Delay execution...: checked
Add a Send email action:
To:
{{webResponse.body.emailAddress}}Subject and Content: Your choice
How do I know it worked?
Run the rule once and confirm the audit log shows the email action succeeded and recipients received it.
Was this helpful?