This Confluence macro retrieves all permissions for a given space, ensuring it collects the complete dataset even for large spaces.
It first resolves the target space key (either the current space or a provided parameter), then fetches the corresponding space ID required for API requests.
Using a loop with pagination support, the macro aggregates all permission entries across multiple API pages into a single collection.
From these permissions, it extracts unique user account IDs where the principal type is a user, avoiding duplicates through manual checks.
Next, the macro iterates over each collected user ID and performs additional API calls to fetch detailed user information.
It filters these users to identify only guest accounts (isGuest == true), again ensuring no duplicates are included in the final list.
Finally, the macro renders the output: if no guest users are found, it displays an informational message. Otherwise, it presents a styled list of guest users.
## Resolve spaceKey
#set($spaceKey = $space.key)
#if($parameters.space && !$parameters.space.equals("currentSpace()"))
#set($spaceKey = $parameters.space)
#end
#set ($baseUrl = $StringUtils.replace($baseUrl,"/wiki",""))
## Get space ID
#set($spaceRes = $ConfluenceManager.get("/wiki/api/v2/spaces?keys=${spaceKey}"))
#set($spaceId = $spaceRes.results.get(0).id)
## Fetch PAGINATED permissions
#set($url = "/wiki/api/v2/spaces/${spaceId}/permissions?limit=250")
#set($allPerms = [])
#foreach($i in [1..100]) ## Set safety loop
#set($res = $ConfluenceManager.get($url))
#if($res && $res.results)
#foreach($p in $res.results)
#set($void = $allPerms.add($p))
#end
#end
#if($res && $res._links && $res._links.next)
#set($url = $res._links.next)
#else
#break
#end
#end
#set($userIds = [])
#set($guestUsers = [])
## Collect unique user IDs from permissions
#foreach($perm in $allPerms)
#if($perm.principal.type == "user")
#set($id = $perm.principal.id)
## Dedupe
#set($exists = false)
#foreach($u in $userIds)
#if($u == $id)
#set($exists = true)
#end
#end
#if(!$exists)
#set($void = $userIds.add($id))
#end
#end
#end
## Fetch users + filter guests
#foreach($id in $userIds)
#set($user = $ConfluenceManager.get("/wiki/rest/api/user?accountId=${id}"))
#if($user && $user.isGuest)
## Dedupe
#set($exists = false)
#foreach($u in $guestUsers)
#if($u.accountId == $user.accountId)
#set($exists = true)
#end
#end
#if(!$exists)
#set($void = $guestUsers.add($user))
#end
#end
#end
## Show results
#if($guestUsers.size() == 0)
<div role="note" class="aui-message aui-message-info">
<p class="title">
<strong>No guest users found</strong>
</p>
</div>
#else
<h3>Guest users:</h3>
<ul style="list-style: none; padding-left: 0;">
#foreach ($user in $guestUsers)
<li style="margin: 1.5rem 0 0 2.5rem; display: flex; align-items: center; gap: 8px;">
<span class="aui-avatar aui-avatar-medium">
<span class="aui-avatar-inner">
<img src="$baseUrl/$user.profilePicture.path" alt="$user.displayName" />
</span>
</span>
<a href="$baseUrl/people/$user.accountId" target="_blank">
$user.displayName
</a>
</li>
#end
</ul>
#endDisplay issues using a custom JQL filter
Show filtered issues and their relations
Display a personalized greeting message for a logged-in user
Display a table showing the assignee history for issues based on JQL. The table includes the following information: Issue Key, Summary, and Assignee History.
Display Confluence users filtered by their email addresses
List all Confluence spaces with details such as space name, author, and creation date
Displays a list of pages in a specific space with a specified title or label
Show worklogs from Jira issues
Generate IDs in Base32 format
Embed a typo-tolerant search bar directly into Confluence pages to find, highlight, and jump to specific content