# WHOAMI

> WHOAMI function in StackQL: return the principal ID of the authenticated caller when access management is enabled.

Source: https://stackql.io/language-spec/functions/session/whoami

Returns the principal ID of the authenticated caller.  Requires a session started with [access management](/command-line-usage/access-management) enabled.  Available in StackQL `v1.0` and later.

See also:  
[[` GROUPS `]](/language-spec/functions/session/groups) [[ Access Management ]](/command-line-usage/access-management)

* * * 

## Syntax

```sql
SELECT WHOAMI() [ AS <alias> ];
```

## Arguments

None.

## Return Value(s)

Returns the principal ID string established for the current statement.  The function fails in a session started without `--access.config`.

* * *

## Examples

### Inspect the established identity

Both functions take no arguments and describe the caller that the server authenticated for this statement.  `whoami()` returns the principal ID and `groups()` the caller's directory groups, so running them together is a quick check that a token or certificate maps to the expected principal before anything else is run.

```sql
SELECT whoami() AS principal, groups() AS memberships;
```
