# Self — the caller's user + workspace + session context

GET

/v1/identity/whoami

```sh
curl --request GET \
  --url https://example.com/v1/identity/whoami \
  --header 'Authorization: Bearer <token>'
```

Reflects the auth middleware’s attached context: `tenantId` + `scopes` always; `userId` / `sessionId` / `providerId` / `expiresAt` when the caller is on a session token; the fuller `UserRecord` under `user` when a `userId` is present and the `IdentityDirectoryBinding` resolves it. Always mounted — the `/users/*` routes only mount when the directory binding is wired.

## Authorizations

- **[bearerAuth](https://docs.kindgi.com/v0.7.0/reference/api.md#bearerauth)**

## Responses

### 200

Auth + user context.

application/json

Introspection of the caller’s current authentication context. Always carries `tenantId` and `scopes` (empty for static bearer tokens), plus `userId` when the token carries one; `principal` says whom the caller acts as, and an API key adds `tokenId`, its `role` and the `projectId` it is limited to; session-token callers additionally see `sessionId`, `providerId`, and `expiresAt`. `user` is the caller’s directory record, present when the deployment wires an identity directory and it knows the `userId`. `reviewerRole` is set when the caller is a reviewer — its token carries a reviewer role, or its user is a registered reviewer — so clients can gate reviewer-only UI (the approvals surface) without a second round trip.

object

**tenantId**

required

string format: uuid

**actor**

The caller as approvals name a person: `user:<id>` or `service_account:<id>`, the same string as an approval’s `requestedBy` and a decision’s `decidedBy`.

string

**userId**

string

**sessionId**

string

**providerId**

string

**scopes**

required

Array\<string>

**expiresAt**

string format: date-time

**reviewerRole**

Reviewer role class. Hierarchy: standard < senior < admin.

string

Allowed values: standard senior admin

**user**

Workspace-scoped user record (admin plane). `primaryEmail` may be redacted on the wire based on workspace policy (the routes treat it as opaque). `metadata` is free-form JSON — deployments carry IdP claims / provisioning source / roles here.

object

**userId**

required

string

**tenantId**

required

string format: uuid

**primaryEmail**

string

**displayName**

string

**createdAt**

required

string format: date-time

**lastActiveAt**

string format: date-time

**unregisteredAt**

When they were removed from the workspace (`POST /v1/identity/users/{userId}/unregister`); absent while they are here.

string format: date-time

**invite**

Their invitation, while they haven’t signed in: absent once they have, for people added without an email, and for people added before invitations (from 0.1.9).

object

**state**

required

string

Allowed values: pending expired

**expiresAt**

required

string format: date-time

**sentAt**

When it was last emailed; absent when it never was.

string format: date-time

**firstSignedInAt**

Their first sign-in that made a session. Absent before it, and for people who last signed in before it was kept (from 0.1.9).

string format: date-time

**createdBy**

Who added them: `user:<id>` (a tenant admin) or `service_account:<id>`; `identity_provider:<providerId>` for someone who joined by domain through that identity provider, or `email_domain:<domain>` through one of the workspace’s allowed domains; `site:<siteId>` for a person a site signs in. Ids only, never an email. Absent for the seed user, and from a runtime that doesn’t keep it.

string

\>= 1 characters

**metadata**

object

**_key_**

additional properties

any

**grants**

The person’s grants: only on `GET /v1/identity/users?include=grants`, and only from a runtime that reads grants.

object

**userId**

required

string

**tenantAdmin**

Whether the person is a tenant admin. Absent when the runtime has no authorization store: nothing grants it then.

boolean

**tenantAdminFromSetting**

Whether the running server’s `KINDGI_ADMIN_EMAILS` names the person: they’re a tenant admin at every start, and taking tenant admin from them, or removing them, answers 409 `listed-admin` until the address is off the list. Absent when the runtime doesn’t report it.

boolean

**tenantMember**

Whether the person is a tenant member: they read the workspace’s settings (providers, policies, adapters, signing keys, deployments), not its projects. A person is one from being added. Absent when the runtime has no authorization store, or doesn’t report it.

boolean

**projects**

required

Direct project memberships.

Array\<object>

A person’s direct role on a project.

object

**projectId**

required

string

**role**

required

Role on a project, as read. `member` is only read, on a role given before it was retired: it grants what `viewer` does, and writes refuse it.

string

Allowed values: viewer runner editor owner admin member

**teams**

required

Team memberships.

Array\<object>

A person’s role in a team.

object

**teamId**

required

string

**role**

required

Role on a team membership.

string

Allowed values: member admin

**reviewer**

A person’s active entry on the reviewer roster.

object

**role**

required

Reviewer role class. Hierarchy: standard < senior < admin.

string

Allowed values: standard senior admin

**capabilities**

The capabilities the person holds, such as `env:write` or `signing-keys:write`. Absent when the runtime doesn’t report them: unknown, not none.

Array\<string>

**principal**

Whom an API key acts for: a person, or a service account.

object

**kind**

required

string

Allowed values: user service-account

**id**

required

The user id, or the service account id.

string

\>= 1 characters

**tokenId**

The caller’s API key, when it is one.

string

**role**

The caller’s API key role, when the key has one, or its session’s role ceiling.

string

Allowed values: admin member

**projectId**

The project the caller’s API key or session is limited to, when it is.

string

**readOnly**

With `tokenId`: whether the caller’s API key only reads. A session has none. Absent from older servers.

boolean

**tenantAdmin**

Whether the caller is a tenant admin, decided as the admin routes decide it: `admin` on the workspace when the runtime authorizes, otherwise the `tenant-admin` scope of a full key (never a `member` key, one limited to a project, or one that only reads). A console shows its admin pages by it. Absent from older servers: read `scopes`.

boolean

**servedEnv**

The env this runtime serves (`KINDGI_ENV`): where the values its tools read are kept. With `refusesOtherEnvs`, it’s the only one: a secret, env value or secret reference under another env is refused (`409 env-not-served`), so a client defaults to `envName`. Absent when the runtime serves no env, and from older servers.

object

**envName**

required

The env name.

string

**refusesOtherEnvs**

required

Whether values under any other env are refused.

boolean

##### Example

```json
{
  "reviewerRole": "standard",
  "user": {
    "invite": {
      "state": "pending"
    },
    "grants": {
      "projects": [
        {
          "role": "viewer"
        }
      ],
      "teams": [
        {
          "role": "member"
        }
      ],
      "reviewer": {
        "role": "standard"
      }
    }
  },
  "principal": {
    "kind": "user"
  },
  "role": "admin"
}
```

### 401

Missing / malformed / expired / revoked bearer token.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

### 429

`rate-limit-exceeded` with `details.limit: "api-requests"`, on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; `Retry-After` says when to send it again.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

### 503

The database was too busy to answer in time (`database-busy`), or the authorization store couldn’t be reached (`authz-backend-unavailable`); `Retry-After` (whole seconds) says when to try again.

application/json

object

**error**

required

object

**code**

required

Stable machine-readable discriminant. Values match domain error codes (see `docs/API-ROUTE-CONVENTIONS.md` §4.3).

string

**message**

required

string

**details**

Optional, kind-specific.

object

**_key_**

additional properties

any

**requestId**

required

Server-assigned request id; also echoed via `X-Request-Id` header.

string

##### Examplegenerated

```json
{
  "error": {
    "code": "example",
    "message": "example",
    "details": {},
    "requestId": "example"
  }
}
```

#### Headers

**Retry-After**

integer

\>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

## See also

- [Run with authorization](https://docs.kindgi.com/v0.7.0/deploy/authorization.md)
- [People, API keys and service accounts](https://docs.kindgi.com/v0.7.0/deploy/people-and-keys.md)
- [Error code `authz-backend-unavailable`](https://docs.kindgi.com/v0.7.0/reference/errors.md#authz-backend-unavailable)
- [Error code `database-busy`](https://docs.kindgi.com/v0.7.0/reference/errors.md#database-busy)
- [Error code `rate-limit-exceeded`](https://docs.kindgi.com/v0.7.0/reference/errors.md#rate-limit-exceeded)
- [Every error code](https://docs.kindgi.com/v0.7.0/reference/errors.md)
