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

# Resolve the authenticated actor's effective POS scopes

> Returns the `pos.*` scopes the CALLING credential currently holds. This is the discovery entry point: call it FIRST, once, before planning any other work, and use the answer to decide what to attempt.

HOW TO USE THE RESULT. Every documented operation carries an `x-required-permissions` array. If an entry of that array is missing from `effectivePermissions`, the router gate refuses the call with 403 before the handler runs — do not attempt it, and do not retry it with a different body, because nothing about the request can change the outcome. Match the scope EXACTLY (`pos.team.view` does not satisfy `pos.team.manage`) and match it PER OPERATION, not per resource: most routers gate reads on a `.view` scope and writes on a `.manage` one, so holding `pos.customers.view` lets you list customers and NOT edit them.

NECESSARY, NOT SUFFICIENT (solya-pos#950). Holding the advertised scope only gets you past the router gate. Several use-cases additionally assert a kernel permission that the scope does not imply, so a call can pass the gate and still return a bare 403 from inside the handler — known cases include the team writes (`pos.team.manage`) and recording a customer consent decision (`pos.customers.manage`, solya-pos#949). Treat a 403 on an operation whose scope you DO hold as a server-side grant gap to report, not as something to work around. Some operations also demand a second, human authority on top of any scope — see `POST /v1/auth/elevate`.

READING THE PAYLOAD. The answer is wrapped: `{ data: { effectivePermissions } }`. That envelope is specific to this operation — nearly every other operation returns its payload raw — so read `data.effectivePermissions`, not the root. The array is sorted and de-duplicated, which makes it stable enough to cache for the lifetime of the credential and to diff between two tokens. An EMPTY array is a valid, successful answer: the caller is authenticated but holds no POS scope, so every scope-gated operation will 403 and only this endpoint and the unauthenticated reads (`GET /v1/permissions/manifest`, `GET /v1/fiscal-keys`) will work.

SCOPE AND LIMITS. This describes the CALLER and nobody else — there is no way to ask what another actor holds, and the `role` label on a team-directory row is a display string that answers no authorization question. It needs no scope of its own (any authenticated actor may introspect itself) and it is a pure read: it grants nothing, refreshes nothing and does not extend the session. Because it is the cheapest authenticated call in the API, it doubles as the credential check — a 401 means the bearer token is missing, malformed or expired, and re-authentication is the only fix. One code path serves both credential kinds: a Keycloak access token's `scope` claim and an opaque POS session's server-derived scopes resolve to the same vocabulary.



## OpenAPI

````yaml /openapi.json get /v1/auth/whoami
openapi: 3.0.3
info:
  title: Solya POS API
  version: 1.0.0
  description: >-
    The Solya POS backend HTTP surface. Every documented operation is
    agent-ready: it carries an `operationId`, an agent-facing `description`, the
    `pos.*` scopes it enforces (`x-required-permissions`) and an `x-agent-tier`.
    Success responses return the payload as raw JSON; failures return the
    `ErrorResponse` envelope (`{ error: { code, message, statusCode } }`).
servers:
  - url: /
    description: The backend, relative to its deployed origin.
security: []
paths:
  /v1/auth/whoami:
    get:
      tags:
        - Auth
      summary: Resolve the authenticated actor's effective POS scopes
      description: >-
        Returns the `pos.*` scopes the CALLING credential currently holds. This
        is the discovery entry point: call it FIRST, once, before planning any
        other work, and use the answer to decide what to attempt.


        HOW TO USE THE RESULT. Every documented operation carries an
        `x-required-permissions` array. If an entry of that array is missing
        from `effectivePermissions`, the router gate refuses the call with 403
        before the handler runs — do not attempt it, and do not retry it with a
        different body, because nothing about the request can change the
        outcome. Match the scope EXACTLY (`pos.team.view` does not satisfy
        `pos.team.manage`) and match it PER OPERATION, not per resource: most
        routers gate reads on a `.view` scope and writes on a `.manage` one, so
        holding `pos.customers.view` lets you list customers and NOT edit them.


        NECESSARY, NOT SUFFICIENT (solya-pos#950). Holding the advertised scope
        only gets you past the router gate. Several use-cases additionally
        assert a kernel permission that the scope does not imply, so a call can
        pass the gate and still return a bare 403 from inside the handler —
        known cases include the team writes (`pos.team.manage`) and recording a
        customer consent decision (`pos.customers.manage`, solya-pos#949). Treat
        a 403 on an operation whose scope you DO hold as a server-side grant gap
        to report, not as something to work around. Some operations also demand
        a second, human authority on top of any scope — see `POST
        /v1/auth/elevate`.


        READING THE PAYLOAD. The answer is wrapped: `{ data: {
        effectivePermissions } }`. That envelope is specific to this operation —
        nearly every other operation returns its payload raw — so read
        `data.effectivePermissions`, not the root. The array is sorted and
        de-duplicated, which makes it stable enough to cache for the lifetime of
        the credential and to diff between two tokens. An EMPTY array is a
        valid, successful answer: the caller is authenticated but holds no POS
        scope, so every scope-gated operation will 403 and only this endpoint
        and the unauthenticated reads (`GET /v1/permissions/manifest`, `GET
        /v1/fiscal-keys`) will work.


        SCOPE AND LIMITS. This describes the CALLER and nobody else — there is
        no way to ask what another actor holds, and the `role` label on a
        team-directory row is a display string that answers no authorization
        question. It needs no scope of its own (any authenticated actor may
        introspect itself) and it is a pure read: it grants nothing, refreshes
        nothing and does not extend the session. Because it is the cheapest
        authenticated call in the API, it doubles as the credential check — a
        401 means the bearer token is missing, malformed or expired, and
        re-authentication is the only fix. One code path serves both credential
        kinds: a Keycloak access token's `scope` claim and an opaque POS
        session's server-derived scopes resolve to the same vocabulary.
      operationId: whoami
      responses:
        '200':
          description: >-
            The caller's effective POS scopes, sorted and de-duplicated, under a
            `data` envelope.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      effectivePermissions:
                        type: array
                        items:
                          type: string
                        description: >-
                          The `pos.*` scopes the caller holds — sorted,
                          de-duplicated.
                    required:
                      - effectivePermissions
                    additionalProperties: false
                required:
                  - data
                additionalProperties: false
                description: >-
                  The caller's effective POS scopes, sorted and de-duplicated,
                  under a `data` envelope.
                example:
                  data:
                    effectivePermissions:
                      - pos.catalog.view
                      - pos.checkout.operate
        '400':
          description: >-
            The request failed schema validation; `error.fieldErrors` lists the
            fields.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
        '401':
          description: No valid credential was presented — send a bearer token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: An unexpected server error — safe to retry idempotent requests.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    ValidationErrorResponse:
      type: object
      required:
        - error
      additionalProperties: false
      description: >-
        A `VALIDATION_FAILED` envelope carrying the offending fields in
        `fieldErrors`.
      properties:
        error:
          type: object
          required:
            - code
            - message
            - statusCode
          additionalProperties: false
          properties:
            code:
              type: string
              enum:
                - VALIDATION_FAILED
            message:
              type: string
            statusCode:
              type: integer
            fieldErrors:
              type: array
              description: >-
                One entry per rejected field: the field path and why it was
                rejected.
              items:
                type: object
                required:
                  - field
                  - message
                additionalProperties: false
                properties:
                  field:
                    type: string
                    description: Dot-path of the offending field.
                  message:
                    type: string
                    description: Why the field was rejected.
    ErrorResponse:
      type: object
      required:
        - error
      additionalProperties: false
      description: The uniform failure envelope every non-2xx response returns.
      properties:
        error:
          type: object
          required:
            - code
            - message
            - statusCode
          additionalProperties: false
          properties:
            code:
              type: string
              enum:
                - VALIDATION_FAILED
                - UNAUTHORIZED
                - FORBIDDEN
                - NOT_FOUND
                - CONFLICT
                - BUSINESS_RULE_VIOLATION
                - INTERNAL_ERROR
              description: >-
                Machine-readable kernel `ResultCode` — branch on this, not on
                `message`.
            message:
              type: string
              description: >-
                Human-readable explanation. Safe to surface; never leaks server
                internals.
            statusCode:
              type: integer
              description: >-
                The HTTP status, mirrored into the body so a client need not
                read headers.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        `Authorization: Bearer <token>`. Accepts EITHER a Keycloak access token
        (scopes-in-token) OR an opaque POS session token; both resolve to the
        same `pos.*` scope vocabulary the route guards enforce.

````