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

# Check current user's role

> Checks whether the currently logged-in user (identified by their own session JWT, not a
{user_id} path param or admin credential) holds at least one of the given roles within an
organization. If the user is not a member of the organization, or the organization does not
exist, the result is simply `has_role: false`, not an error.




## OpenAPI

````yaml openapi-public post /organizations/roles/check
openapi: 3.0.0
info:
  version: 3.0.4
  title: Hanko Public API
  description: >
    ## Introduction


    This is the OpenAPI specification for the [Hanko Public
    API](https://github.com/teamhanko/hanko/blob/main/backend/README.md#basic-usage).


    ## Authentication


    The API uses [JSON Web Tokens](https://www.rfc-editor.org/rfc/rfc7519.html)
    (JWTs) for authentication.

    JWTs are verified using [JSON Web
    Keys](https://www.rfc-editor.org/rfc/rfc7517) (JWK).

    JWKs can be
    [configured](https://github.com/teamhanko/hanko/blob/main/backend/docs/Config.md#all-available-config-options)

    through the `secrets.keys` options. The API also publishes public
    cryptographic keys as a

    [JWK set](https://www.rfc-editor.org/rfc/rfc7517#section-2) through the
    `.well-known/jwks.json` endpoint

    to enable clients to verify token signatures.

    JWTs must be provided on requests to protected endpoints using one of the
    following schemes:


    ### CookieAuth


    **Security Scheme Type**: `API Key`


    **Cookie parameter name**: `hanko`


    The JWT must be provided in a Cookie with the name `hanko`.


    ### BearerTokenAuth


    **Security Scheme Type**: `http`


    **HTTP Authorization Scheme**: `Bearer`


    **Bearer format**: `JWT`


    The JWT must be provided in an HTTP Authorization header with bearer type:
    `Authorization: Bearer <JWT>`.


    ## Cross-Origin Resource Sharing

    Cross-Origin Resource Sharing (CORS) can be currently

    [configured](https://github.com/teamhanko/hanko/blob/main/backend/docs/Config.md#all-available-config-options)

    for public endpoints via the `server.public.cors` options.


    ---
  contact:
    email: developers@hanko.io
  license:
    name: AGPL-3.0-or-later
    url: https://www.gnu.org/licenses/agpl-3.0.txt
servers:
  - url: https://{tenant_id}.hanko.io
    variables:
      tenant_id:
        default: ''
        description: The (UU)ID of a tenant. Replace the default value with your tenant ID.
security: []
externalDocs:
  description: More about Hanko
  url: https://github.com/teamhanko/hanko
paths:
  /organizations/roles/check:
    post:
      tags:
        - Organization Management
      summary: Check current user's role
      description: >
        Checks whether the currently logged-in user (identified by their own
        session JWT, not a

        {user_id} path param or admin credential) holds at least one of the
        given roles within an

        organization. If the user is not a member of the organization, or the
        organization does not

        exist, the result is simply `has_role: false`, not an error.
      operationId: checkOrganizationRole
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                organization_id:
                  description: The ID of the organization to check
                  allOf:
                    - $ref: '#/components/schemas/UUID4'
                roles:
                  description: >
                    IDs or slugs of roles to check for. The check succeeds if
                    the user holds at least one

                    of the listed roles (OR semantics).
                  type: array
                  items:
                    type: string
                  minItems: 1
              required:
                - organization_id
                - roles
      responses:
        '200':
          description: Role check result
          content:
            application/json:
              schema:
                type: object
                properties:
                  has_role:
                    type: boolean
                required:
                  - has_role
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - CookieAuth: []
        - BearerTokenAuth: []
components:
  schemas:
    UUID4:
      type: string
      format: uuid4
      example: c339547d-e17d-4ba7-8a1d-b3d5a4d17c1c
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 400
            message: Bad Request
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 401
            message: Unauthorized
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 500
            message: Internal Server Error
  securitySchemes:
    CookieAuth:
      type: apiKey
      in: cookie
      name: hanko
    BearerTokenAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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