---
title: "Get the authenticated principal"
method: GET
path: "/api/cli/whoami"
tags: ["Authentication"]
---

# Get the authenticated principal

`GET /api/cli/whoami`

## Request

- Base URL: `https://api.factory.ai`
- URL: `https://api.factory.ai/api/cli/whoami`
- Auth: HTTP bearer

Returns the principal a user access token, a user API key or a service account API key authenticates, and the organization the request acts in.

## Headers

- `X-Factory-Whoami-Extended` 'true'
- `X-Factory-Session-Attribution` string
- `X-Factory-Org-Id` string

## Response `200`

Response for status 200

- GetWhoami200ResponseBody
  - `userId` string, required: For a user access token or a user API key, the user's ID; for a service account API key, the service account's ID.
  - `orgId` string, required: For an API key, the key's organization; for a user access token, the organization the request acts in, as `X-Factory-Org-Id` describes.
  - `region` 'global' | 'eu'
  - `inferenceRegion` 'global' | 'eu' | 'us' | 'in'
  - `isEnterprise` boolean
  - `principalKind` 'human' | 'service': `human` for a user access token or a user API key, `service` for a service account API key.
  - `premBaseHostV2` string
  - `attribution` object
    - `userId` string, required
    - `name` string
    - `source` 'web' | 'desktop' | 'cli_tui' | 'cli_exec' | 'cli_acp' | 'slack' | 'jira' | 'linear' | 'microsoft-teams' | 'google-chat' | 'sessions_api' | 'api' | 'sdk' | 'automation' | 'readiness-remediation' | 'readiness-evaluation' | 'wiki-generation' | 'wiki-ci-setup' | 'ios'
    - `sharedSessionMember` true
    - `receipt` string
    - `sessionId` string, required

## Other responses

- `400`: Response for status 400
- `401`: Response for status 401
- `402`: Response for status 402
- `403`: Response for status 403
- `404`: Response for status 404
- `451`: Response for status 451
- `500`: Response for status 500
- `503`: Response for status 503

## Changes

- **2026-12-01** `2e37e1b079d2`: 1 info
  - added the optional property `attribution/sharedSessionMember` to the response with the `200` status
- **2026-11-19** `06762b4102b4`: 1 warning
  - added the new `ios` enum value to the `attribution/source` response property for the response status `200`
- **2026-11-17** `54bb6cc588c0`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/factory/apis/factory-public-api/changes/api/cli/whoami/get.md)

---

[API](https://skmtc.dev/factory/apis/factory-public-api.md) - [All operations](https://skmtc.dev/factory/apis/factory-public-api/llms.txt) - [OpenAPI document](https://skmtc.dev/factory/apis/factory-public-api/revisions/2e37e1b079d2?raw)
