> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Identity in functions

`ctx.frame.as` describes the principal for this invocation. Its fields
include `id`, `kind`, `for`, `email` and `phone`.

* `id` is the principal's stable, kind-qualified `PrincipalId`: `person:…`
  for a signed-in person, `service:…` for a service, and `anonymous:…` for
  a signed-out caller. A signed-out client is one anonymous principal for
  the whole registered session its calls arrive on (a call on no session is
  its own), and two sessions' principals cannot be linked. It holds no
  grant of its own: only an entry whose `allow` names `role.anyone` admits
  it, through that class grant, and a trial of its call admits it exactly
  as the call would.
* `kind` is `"person"`, `"agent"` (a principal acting under a delegation grant),
  `"service"`, `"installation"` or `"anonymous"`. An exposed function whose
  `allow` excludes `role.anyone` also excludes `"anonymous"` from the type
  of `ctx.frame.as.kind`. Internal functions, reactions and mutations
  declared with `by: "app"` keep the full union.
* In an agent's frame, `id` names the agent and `for` names the delegator.
  The kernel derives `for` from the agent's live delegation grants, never
  from the call. A `once` key
  uses the agent's id.
* `email` and `phone` hold verified contact details. Each is `null` when
  the host has no trusted verification for it.

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { query, role } from "@bijectionhq/bijection";

export const me = query({ allow: [role.signedIn] }, (ctx) => ctx.frame.as.id);
```

`allow: [role.signedIn]` admits every authenticated person, and
`allow: [role.anyone]` admits signed-out callers too. Each is a
[class grant](https://docs.bijection.com/access/decisions.md#open-entries) the program issues at install
and the lock prints; nothing is ambient. A function with no `allow` is
internal. To give a principal more
than that, [grant it a role](https://docs.bijection.com/access/grants.md).

The same principal is the `as` root of every [guard](https://docs.bijection.com/access/guards.md), so a
rule about the person rather than the role is a guard on its claims:

```ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { act, forbid, mutation, role } from "@bijectionhq/bijection";

export const checkout = mutation({ allow: [role.signedIn] }, async (ctx) => {
  // …
});
export const verifiedOnly = forbid(act.enter(checkout), {
  where: (a) => a.as.email.isNull(),
  message: "Verify your email address before checking out.",
});
```

Store the `id` in a `t.principal` field when a fact must name its author or
owner. See [Storing users](https://docs.bijection.com/access/authentication/user-records.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.