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

# Assign a Role to a User

> Assign a specific role to a user within an account or project



## OpenAPI

````yaml POST /api/v1/accounts/{accountId}/roles/assignments
openapi: 3.1.0
info:
  title: AuthZ Service API
  description: Authorization service for managing roles and user permissions
  version: 1.1.0
servers:
  - url: https://api.aion.xyz
    description: Production server
  - url: https://api.dev.internal.aion.xyz
    description: Staging server
security:
  - BearerAuth: []
tags:
  - name: Authorization
    description: Authorization check operations
  - name: Roles
    description: Operations related to role management
  - name: User Roles
    description: Operations related to user role queries
  - name: Role Assignments
    description: Operations for assigning, updating, and revoking roles
paths:
  /api/v1/accounts/{accountId}/roles/assignments:
    post:
      tags:
        - Role Assignments
      summary: Assign a role to a user
      description: Assign a specific role to a user within an account or project
      operationId: createRoleAssignment
      parameters:
        - name: accountId
          in: path
          required: true
          description: The account identifier (external account ID)
          schema:
            type: string
            example: my-company-account
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RoleAssignmentRequest'
      responses:
        '201':
          description: Role successfully assigned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RoleAssignmentResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Role assignment already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    RoleAssignmentRequest:
      type: object
      properties:
        assigneeId:
          type: string
          description: Assignee identifier (external user/group ID)
          example: john.doe
        assigneeType:
          $ref: '#/components/schemas/AssigneeType'
        roleId:
          type: string
          description: Role identifier to assign
          example: project_admin
        projectId:
          type: string
          description: >-
            Project identifier (required for PROJECT scoped roles, must be empty
            for ACCOUNT scoped roles)
          example: project-alpha
      required:
        - assigneeId
        - assigneeType
        - roleId
    RoleAssignmentResponse:
      type: object
      properties:
        assigneeId:
          type: string
          description: Assignee identifier (external user/group ID)
          example: jane.smith
        assigneeType:
          $ref: '#/components/schemas/AssigneeType'
        roleId:
          type: string
          description: Role identifier
          example: account_admin
        status:
          $ref: '#/components/schemas/AssignmentStatus'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - assigneeId
        - assigneeType
        - roleId
        - status
        - createdAt
        - updatedAt
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code
              example: BAD_REQUEST
            message:
              type: string
              description: Error message
              example: Invalid request parameters
            details:
              type: array
              items:
                type: string
              description: Additional error details
              example:
                - projectId is required for PROJECT scoped roles
          required:
            - code
            - message
      required:
        - error
    AssigneeType:
      type: string
      enum:
        - USER
        - IAMGROUP
      description: The type of assignee
    AssignmentStatus:
      type: string
      enum:
        - ACTIVE
        - INACTIVE
      description: The status of the role assignment
  responses:
    BadRequest:
      description: Bad request - Invalid input parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: BAD_REQUEST
              message: Invalid request parameters
              details:
                - accountId must be a valid identifier
    Unauthorized:
      description: Unauthorized - Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: UNAUTHORIZED
              message: Authentication required
    Forbidden:
      description: Forbidden - Insufficient permissions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: FORBIDDEN
              message: Insufficient permissions to access this resource
    NotFound:
      description: Not found - Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: NOT_FOUND
              message: Resource not found
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT Bearer token authentication

````