# Who Am I

`GET /v1/whoami`

The account and workspace this request acts in, the person it acts as
and their role in that workspace, and the API key it used.

Without ``X-Qualia-Workspace`` the workspace is the key's own (for a
signed-in user, the account's default). Any valid key may ask; no scope is
needed. An SDK client with a key and no configured account uses this
``account_id``.

- Base URL: `https://junction-api.qualiastudios.dev`
- Authentication: an API key in the `X-API-Key` header, or `Authorization: Bearer …`

## Responses

- `200` The bound account, workspace and key: `application/json` `WhoamiResponse`
- `401` Invalid or missing API key: `application/json` `ErrorResponse`
- `404` The named workspace is not readable: `application/json` `ErrorResponse`

## Schemas

```yaml
WhoamiResponse:
  properties:
    account_id:
      description: The bound account
      type:
        - string
        - "null"
    account_name:
      description: The account's name
      type:
        - string
        - "null"
    account_type:
      description: personal or organization (the platform's account type)
      type:
        - string
        - "null"
    workspace_id:
      description: The bound workspace
      type:
        - string
        - "null"
    workspace_name:
      description: The workspace's name
      type:
        - string
        - "null"
    user_id:
      description: "The person it acts as: for an API key, its creator"
      type:
        - string
        - "null"
    username:
      description: That person's username
      type:
        - string
        - "null"
    role:
      description: That person's role in the bound workspace (an API key's scopes cap what it may do with it); null when it could not be read
      nullable: true
      type: string
      enum:
        - viewer
        - contributor
        - admin
        - owner
    principal:
      type: string
      enum:
        - api_key
        - user
    key:
      description: The API key, or null for a signed-in user
      nullable: true
      allOf:
        - $ref: "#/components/schemas/WhoamiKey"
  type: object
  required:
    - account_id
    - workspace_id
    - principal
  title: WhoamiResponse
  description: The caller, as this request was bound.
WhoamiKey:
  properties:
    name:
      description: The key's name
      type:
        - string
        - "null"
    key_prefix:
      description: The key's first 12 characters, as the dashboard lists it
      type:
        - string
        - "null"
    scope:
      type: string
      enum:
        - organization
        - workspace
        - restricted
      description: "organization: every workspace of the account its creator can reach; workspace: only the workspace that owns it; restricted: a custom workspace or repository allowlist"
    scopes:
      items:
        type: string
      type: array
      description: Granted permissions
    allowed_project_ids:
      items:
        type: string
      type: array
      description: Workspaces the key is restricted to; empty means no restriction
    expires_at:
      description: Expiry, ISO 8601
      type:
        - string
        - "null"
  type: object
  required:
    - scope
  title: WhoamiKey
  description: The API key the request authenticated with.
ErrorResponse:
  properties:
    detail:
      type: string
      description: Error message describing what went wrong
  type: object
  required:
    - detail
  title: ErrorResponse
  description: Standard error response.
```
