GROUPS
Returns the directory group memberships of the authenticated caller as a JSON array. Requires a session started with access management enabled. Available in StackQL v1.0 and later.
See also:
[WHOAMI] [ Access Management ]
Syntax
SELECT GROUPS() [ AS <alias> ];
Arguments
None.
Return Value(s)
Returns a JSON array of group IDs from the principal directory snapshot taken for the current statement, for example ["readers"]. Membership is refreshed for each statement, so a revocation is reflected by the next statement. The function fails in a session started without --access.config.
Examples
Inspect the established identity
The two functions together show the caller's principal ID and its current directory groups. Because membership is read afresh for every statement, running this after a directory change confirms that the change is visible to the session.
SELECT whoami() AS principal, groups() AS memberships;