> ## 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.

# Create a role binding

> user_id must resolve to a real user, or the request fails with 404. org_id and the
membership itself aren't separately verified - a missing membership, whether because
the organization doesn't exist or the user just isn't a member of it, resolves to 400,
same as an unrecognized role reference in the body.




## OpenAPI

````yaml openapi-admin post /organizations/{org_id}/users/{user_id}/roles
openapi: 3.0.3
info:
  version: 3.0.4
  title: Hanko Admin API
  description: >
    ## Introduction


    This is the OpenAPI specification for the [Hanko Admin
    API](https://github.com/teamhanko/hanko/blob/main/backend/README.md#start-private-api).


    ## Authentication


    The Admin API must be protected by an access management system.


    ---
  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/admin
    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/{org_id}/users/{user_id}/roles:
    post:
      tags:
        - Role Management
      summary: Create a role binding
      description: >
        user_id must resolve to a real user, or the request fails with 404.
        org_id and the

        membership itself aren't separately verified - a missing membership,
        whether because

        the organization doesn't exist or the user just isn't a member of it,
        resolves to 400,

        same as an unrecognized role reference in the body.
      operationId: createRoleBinding
      parameters:
        - name: org_id
          in: path
          description: ID of the organization
          required: true
          schema:
            $ref: '#/components/schemas/UUID4'
        - name: user_id
          in: path
          description: ID of the user
          required: true
          schema:
            $ref: '#/components/schemas/UUID4'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                role:
                  description: The ID or slug of the role to bind
                  type: string
              required:
                - role
      responses:
        '200':
          description: The new role binding
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RoleBinding'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - BearerApiKeyAuth: []
components:
  schemas:
    UUID4:
      type: string
      format: uuid4
      example: c339547d-e17d-4ba7-8a1d-b3d5a4d17c1c
    RoleBinding:
      type: object
      description: A role held by a user within one organization.
      required:
        - role_id
        - slug
        - name
        - created_at
      properties:
        role_id:
          description: The ID of the role
          allOf:
            - $ref: '#/components/schemas/UUID4'
        slug:
          description: The slug of the role
          type: string
        name:
          description: The display name of the role
          type: string
        created_at:
          description: Time the role was bound to the user
          type: string
          format: date-time
    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
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 404
            message: Not found
    Conflict:
      description: Conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 409
            message: Conflict
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 500
            message: Internal Server Error
  securitySchemes:
    BearerApiKeyAuth:
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your API key. Must only be used when using Hanko Cloud.
      type: http
      scheme: bearer
      bearerFormat: API Key

````

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