{
  "schemes": [
    "https"
  ],
  "swagger": "2.0",
  "info": {
    "description": "Authentication, users, roles, and tenants.",
    "title": "IAM API",
    "contact": {},
    "version": "1.0.0"
  },
  "host": "api.catazenta.com",
  "basePath": "/v1",
  "paths": {
    "/api-keys": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "List API keys with pagination and filters",
        "produces": [
          "application/json"
        ],
        "tags": [
          "API Keys"
        ],
        "summary": "List API keys",
        "parameters": [
          {
            "type": "string",
            "description": "Search term (name or key_prefix)",
            "name": "search",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "csv",
            "description": "Status filter (active, revoked, expired)",
            "name": "status",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Filter by service account ID",
            "name": "service_account_id",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 10,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/APIKeyListResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Create a new API key for a service account. The raw key is returned once.",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "API Keys"
        ],
        "summary": "Create an API key",
        "parameters": [
          {
            "description": "API key creation request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/CreateAPIKeyRequest"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/CreateAPIKeyResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/api-keys/{id}": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Retrieve an API key by ID",
        "produces": [
          "application/json"
        ],
        "tags": [
          "API Keys"
        ],
        "summary": "Get an API key",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "API Key ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/APIKeyResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "delete": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Permanently delete an API key",
        "produces": [
          "application/json"
        ],
        "tags": [
          "API Keys"
        ],
        "summary": "Delete an API key",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "API Key ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Update an API key's name or expiration",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "API Keys"
        ],
        "summary": "Update an API key",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "API Key ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Update request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UpdateAPIKeyRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/APIKeyResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/api-keys/{id}/status": {
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Change an API key's status (e.g., revoke)",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "API Keys"
        ],
        "summary": "Change API key status",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "API Key ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Status change request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ChangeAPIKeyStatusRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/APIKeyResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/auth/login": {
      "post": {
        "description": "Authenticate user and issue JWT tokens with default or specified tenant",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Auth"
        ],
        "summary": "Login",
        "parameters": [
          {
            "description": "Login credentials",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/LoginRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/MinimalLoginResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/auth/logout": {
      "post": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Logout user and clear cached permissions",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Auth"
        ],
        "summary": "Logout",
        "responses": {
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/auth/me": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get current authenticated user information with roles, permissions, and tenants from Redis cache",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Auth"
        ],
        "summary": "Get current user info",
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/MeResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/auth/me/password": {
      "put": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Change current user's password",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Auth"
        ],
        "summary": "Change password",
        "parameters": [
          {
            "description": "Password change request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ChangePasswordRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/response.SuccessResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/auth/refresh": {
      "post": {
        "description": "Get a new access token using refresh token",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Auth"
        ],
        "summary": "Refresh access token",
        "parameters": [
          {
            "description": "Refresh token",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/RefreshTokenRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/RefreshTokenResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/auth/tenant/switch": {
      "post": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Switch the current user to another tenant they have access to without re-authentication",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Auth"
        ],
        "summary": "Switch to another accessible tenant",
        "parameters": [
          {
            "description": "Switch tenant request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/SwitchTenantRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/SelectTenantResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/auth/users/{id}/password": {
      "put": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Reset a user's password (admin only)",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Auth"
        ],
        "summary": "Reset password (admin)",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "User ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Password reset request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ResetPasswordRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/response.SuccessResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/features": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get a paginated list of features",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Features"
        ],
        "summary": "List features",
        "parameters": [
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 20,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Search term",
            "name": "search",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "csv",
            "description": "Filter by status",
            "name": "status",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/FeatureListResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Create a new feature in the system",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Features"
        ],
        "summary": "Create a new feature",
        "parameters": [
          {
            "description": "Feature creation request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/CreateFeatureRequest"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/FeatureResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/features/{id}": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get a feature by their ID",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Features"
        ],
        "summary": "Get feature by ID",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Feature ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/FeatureResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "delete": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Soft delete a feature",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Features"
        ],
        "summary": "Delete feature",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Feature ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/features/{id}/status": {
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Change the status of a feature (activate/deactivate)",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Features"
        ],
        "summary": "Change feature status",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Feature ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Feature status change request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ChangeFeatureStatusRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/FeatureResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/organizations/{org_id}/users": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "List all users that belong to any tenant within the specified organization",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "List users in an organization",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Organization ID",
            "name": "org_id",
            "in": "path",
            "required": true
          },
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 20,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Search term",
            "name": "search",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "csv",
            "description": "Filter by status",
            "name": "status",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/UserListResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/permissions": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "List permissions with pagination and filters",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Permissions"
        ],
        "summary": "List permissions",
        "parameters": [
          {
            "type": "string",
            "description": "Feature ID filter",
            "name": "feature_id",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Sub-feature ID filter",
            "name": "sub_feature_id",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Search term",
            "name": "search",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "csv",
            "description": "Status filter",
            "name": "status",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 10,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/PermissionListResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Create a new permission",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Permissions"
        ],
        "summary": "Create a new permission",
        "parameters": [
          {
            "description": "Permission creation request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/CreatePermissionRequest"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/PermissionResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/permissions/{id}": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get a permission by ID",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Permissions"
        ],
        "summary": "Get a permission by ID",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Permission ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/PermissionResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "delete": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Soft delete a permission",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Permissions"
        ],
        "summary": "Delete a permission",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Permission ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/permissions/{id}/status": {
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Change a permission's status",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Permissions"
        ],
        "summary": "Update a permission",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Permission ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Permission status change request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ChangePermissionStatusRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/PermissionResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/roles": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "List roles with pagination and filters",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Roles"
        ],
        "summary": "List roles",
        "parameters": [
          {
            "type": "string",
            "description": "Tenant ID filter (must be in user's accessible tenants)",
            "name": "tenant_id",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Search term",
            "name": "search",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "csv",
            "description": "Status filter",
            "name": "status",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 10,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/RoleListResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Create a new role",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Roles"
        ],
        "summary": "Create a new role",
        "parameters": [
          {
            "description": "Role creation request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/CreateRoleRequest"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/RoleResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/roles/{id}": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get a role by ID",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Roles"
        ],
        "summary": "Get a role by ID",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Role ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/RoleResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "delete": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Soft delete a role",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Roles"
        ],
        "summary": "Delete a role",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Role ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Update a role",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Roles"
        ],
        "summary": "Update a role",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Role ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Role update request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UpdateRoleRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/RoleResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/roles/{id}/permissions": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get all permissions assigned to a role",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Roles"
        ],
        "summary": "Get role permissions",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Role ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 20,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/RolePermissionListResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "patch": {
        "security": [
          {
            "BearerAuth": []
          },
          {
            "BearerAuth": []
          }
        ],
        "description": "Assign permissions to a role (adds to existing)\nRemove a single permission from a role",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json",
          "application/json"
        ],
        "tags": [
          "Roles",
          "Roles"
        ],
        "summary": "Remove a permission from role",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Role ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Permissions to assign",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UpdateRolePermissionsRequest"
            }
          },
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Role ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/response.SuccessResponse"
            }
          },
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/roles/{id}/permissions/{permission_id}": {
      "delete": {
        "security": [
          {
            "BearerAuth": []
          },
          {
            "BearerAuth": []
          }
        ],
        "description": "Assign permissions to a role (adds to existing)\nRemove a single permission from a role",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json",
          "application/json"
        ],
        "tags": [
          "Roles",
          "Roles"
        ],
        "summary": "Remove a permission from role",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Role ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Permissions to assign",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UpdateRolePermissionsRequest"
            }
          },
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Role ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Permission ID",
            "name": "permission_id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/response.SuccessResponse"
            }
          },
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/roles/{id}/status": {
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Change a role's status (activate or deactivate)",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Roles"
        ],
        "summary": "Change role status",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Role ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Status change request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ChangeRoleStatusRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/RoleResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/service-accounts": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "List service accounts with pagination and filters",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Service Accounts"
        ],
        "summary": "List service accounts",
        "parameters": [
          {
            "type": "string",
            "description": "Search term (name or code)",
            "name": "search",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "csv",
            "description": "Status filter (active, inactive)",
            "name": "status",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 10,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/ServiceAccountListResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Create a new service account (machine identity)",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Service Accounts"
        ],
        "summary": "Create a service account",
        "parameters": [
          {
            "description": "Service account creation request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/CreateServiceAccountRequest"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/ServiceAccountResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/service-accounts/{id}": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Retrieve a service account by ID",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Service Accounts"
        ],
        "summary": "Get a service account",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Service Account ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/ServiceAccountResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "delete": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Delete a service account and its role mappings",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Service Accounts"
        ],
        "summary": "Delete a service account",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Service Account ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Update a service account's name or description",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Service Accounts"
        ],
        "summary": "Update a service account",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Service Account ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Update request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UpdateServiceAccountRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/ServiceAccountResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/service-accounts/{id}/status": {
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Change a service account's status (activate or deactivate)",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Service Accounts"
        ],
        "summary": "Change service account status",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Service Account ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Status change request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ChangeStatusRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/ServiceAccountResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/sub-features": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get a paginated list of sub-features",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Sub-Features"
        ],
        "summary": "List sub-features",
        "parameters": [
          {
            "type": "string",
            "description": "Filter by feature ID",
            "name": "feature_id",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 20,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Search term",
            "name": "search",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "csv",
            "description": "Filter by status",
            "name": "status",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/SubFeatureListResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Create a new sub-feature in the system",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Sub-Features"
        ],
        "summary": "Create a new sub-feature",
        "parameters": [
          {
            "description": "Sub-feature creation request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/CreateSubFeatureRequest"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/SubFeatureResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/sub-features/{id}": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get a sub-feature by its ID",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Sub-Features"
        ],
        "summary": "Get sub-feature by ID",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Sub-Feature ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/SubFeatureResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "delete": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Soft delete a sub-feature",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Sub-Features"
        ],
        "summary": "Delete sub-feature",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Sub-Feature ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/sub-features/{id}/status": {
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Change the status of a sub-feature (activate/deactivate)",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Sub-Features"
        ],
        "summary": "Change sub-feature status",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "Sub-Feature ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Sub-feature status change request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ChangeSubFeatureStatusRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/SubFeatureResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/users": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get a paginated list of users scoped to the caller's JWT tenant",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "List users in my tenant",
        "parameters": [
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 20,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          },
          {
            "type": "string",
            "description": "Search term",
            "name": "search",
            "in": "query"
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "collectionFormat": "csv",
            "description": "Filter by status",
            "name": "status",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/UserListResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Create a new user or assign an existing one to the caller's JWT tenant",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "Create a user",
        "parameters": [
          {
            "description": "Create/assign user request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/AssignUserToTenantRequest"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/UserDetailsResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/users/{id}": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get a user by their ID",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "Get user by ID",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "User ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/UserDetailsResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "delete": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Remove a user from the caller's JWT tenant",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "Delete a user",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "User ID",
            "name": "id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Update an existing user",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "Update user",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "User ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "User update request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UpdateUserRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/UserDetailsResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "409": {
            "description": "Conflict",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/users/{id}/roles": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get all roles assigned to a user in the caller's JWT tenant",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "Get user roles",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "User ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 20,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/UserRoleListResponse"
                    }
                  }
                }
              ]
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      },
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Add roles to a user in the caller's JWT tenant. Uses PATCH semantics — adds to existing roles without removing them.",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "Add roles to user",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "User ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Role IDs to add",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/AddUserRolesRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/response.SuccessResponse"
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/users/{id}/roles/{role_id}": {
      "delete": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Remove a single role from a user in the caller's JWT tenant",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "Remove a role from user",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "User ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M3",
            "description": "Role ID",
            "name": "role_id",
            "in": "path",
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/users/{id}/status": {
      "patch": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Change a user's status (activate or deactivate)",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "Change user status",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "User ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "description": "Status change request",
            "name": "request",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ChangeUserStatusRequest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/UserResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    },
    "/users/{id}/tenants": {
      "get": {
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get all tenants a user has access to",
        "produces": [
          "application/json"
        ],
        "tags": [
          "Users"
        ],
        "summary": "Get user tenants",
        "parameters": [
          {
            "type": "string",
            "example": "01J5C2D3E4F5G6H7I8J9K0L1M2",
            "description": "User ID",
            "name": "id",
            "in": "path",
            "required": true
          },
          {
            "type": "integer",
            "default": 1,
            "description": "Page number",
            "name": "page",
            "in": "query"
          },
          {
            "type": "integer",
            "default": 20,
            "description": "Page size",
            "name": "page_size",
            "in": "query"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "allOf": [
                {
                  "$ref": "#/definitions/response.SuccessResponse"
                },
                {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/definitions/UserTenantListResponse"
                    }
                  }
                }
              ]
            }
          },
          "400": {
            "description": "Bad Request",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "401": {
            "description": "Unauthorized",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "403": {
            "description": "Forbidden",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "404": {
            "description": "Not Found",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          },
          "500": {
            "description": "Internal Server Error",
            "schema": {
              "$ref": "#/definitions/response.ErrorResponse"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "response.Error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "field": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "response.ErrorResponse": {
      "type": "object",
      "properties": {
        "errors": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/response.Error"
          }
        },
        "message": {
          "type": "string"
        },
        "success": {
          "type": "boolean"
        }
      }
    },
    "response.PaginationInfo": {
      "type": "object",
      "properties": {
        "has_next": {
          "type": "boolean"
        },
        "page": {
          "type": "integer"
        },
        "page_size": {
          "type": "integer"
        },
        "total_items": {
          "type": "integer"
        },
        "total_pages": {
          "type": "integer"
        }
      }
    },
    "response.SuccessResponse": {
      "type": "object",
      "properties": {
        "data": {},
        "success": {
          "type": "boolean"
        }
      }
    },
    "MinimalLoginResponse": {
      "type": "object",
      "properties": {
        "access_token": {
          "type": "string"
        },
        "expires_in": {
          "type": "integer"
        },
        "refresh_token": {
          "type": "string"
        },
        "token_type": {
          "type": "string"
        }
      }
    },
    "RefreshTokenResponse": {
      "type": "object",
      "properties": {
        "access_token": {
          "type": "string"
        },
        "expires_in": {
          "type": "integer"
        },
        "token_type": {
          "type": "string"
        }
      }
    },
    "SelectTenantResponse": {
      "type": "object",
      "properties": {
        "access_token": {
          "type": "string"
        },
        "expires_in": {
          "type": "integer"
        },
        "refresh_token": {
          "type": "string"
        },
        "tenant_info": {
          "$ref": "#/definitions/TenantSummary"
        },
        "token_type": {
          "type": "string"
        },
        "user": {
          "$ref": "#/definitions/UserSummary"
        }
      }
    },
    "TenantSummary": {
      "type": "object",
      "properties": {
        "is_default": {
          "type": "boolean"
        },
        "organization_code": {
          "type": "string"
        },
        "organization_id": {
          "type": "string"
        },
        "organization_name": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "tenant_code": {
          "type": "string"
        },
        "tenant_id": {
          "type": "string"
        },
        "tenant_name": {
          "type": "string"
        }
      }
    },
    "UserSummary": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "status": {
          "type": "string"
        }
      }
    },
    "ActorSummary": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "example": "user"
        }
      }
    },
    "TenantSummary2": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "acme"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8d1"
        },
        "name": {
          "type": "string",
          "example": "Acme Corporation"
        }
      }
    },
    "UserRoleListItem": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "admin"
        },
        "created_at": {
          "type": "string",
          "example": "2024-01-01T00:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8e1"
        },
        "modified_at": {
          "type": "string",
          "example": "2024-01-10T12:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary"
        },
        "name": {
          "type": "string",
          "example": "Administrator"
        },
        "permission_count": {
          "type": "integer",
          "example": 20
        },
        "status": {
          "type": "string",
          "example": "active"
        },
        "tenant": {
          "$ref": "#/definitions/TenantSummary2"
        }
      }
    },
    "UserRoleListResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/UserRoleListItem"
          }
        },
        "pagination": {
          "$ref": "#/definitions/response.PaginationInfo"
        }
      }
    },
    "APIKeyListItem": {
      "type": "object",
      "properties": {
        "created_at": {
          "type": "string",
          "example": "2025-01-15T08:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary2"
        },
        "description": {
          "type": "string",
          "example": "API key used for ERP data synchronization"
        },
        "expires_at": {
          "type": "string",
          "example": "2025-12-31T23:59:59Z"
        },
        "id": {
          "type": "string",
          "example": "01J5C2D3E4F5G6H7I8J9K0L1M2"
        },
        "key_prefix": {
          "type": "string",
          "example": "czk_a1b2c3d4"
        },
        "last_used_at": {
          "type": "string",
          "example": "2025-06-15T10:30:00Z"
        },
        "modified_at": {
          "type": "string",
          "example": "2025-01-16T10:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary2"
        },
        "name": {
          "type": "string",
          "example": "ERP Sync Key"
        },
        "service_account": {
          "$ref": "#/definitions/ServiceAccountSummary"
        },
        "status": {
          "type": "string",
          "example": "active"
        }
      }
    },
    "APIKeyListResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/APIKeyListItem"
          }
        },
        "pagination": {
          "$ref": "#/definitions/response.PaginationInfo"
        }
      }
    },
    "APIKeyResponse": {
      "type": "object",
      "properties": {
        "created_at": {
          "type": "string",
          "example": "2025-01-15T08:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary2"
        },
        "description": {
          "type": "string",
          "example": "API key used for ERP data synchronization"
        },
        "expires_at": {
          "type": "string",
          "example": "2025-12-31T23:59:59Z"
        },
        "id": {
          "type": "string",
          "example": "01J5C2D3E4F5G6H7I8J9K0L1M2"
        },
        "key_prefix": {
          "type": "string",
          "example": "czk_a1b2c3d4"
        },
        "last_used_at": {
          "type": "string",
          "example": "2025-06-15T10:30:00Z"
        },
        "modified_at": {
          "type": "string",
          "example": "2025-01-16T10:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary2"
        },
        "name": {
          "type": "string",
          "example": "ERP Sync Key"
        },
        "service_account": {
          "$ref": "#/definitions/ServiceAccountSummary"
        },
        "status": {
          "type": "string",
          "example": "active"
        }
      }
    },
    "ActorSummary2": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "example": "user"
        }
      }
    },
    "ChangeAPIKeyStatusRequest": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "active",
            "revoked"
          ],
          "example": "revoked"
        }
      }
    },
    "CreateAPIKeyRequest": {
      "type": "object",
      "required": [
        "name",
        "service_account_id"
      ],
      "properties": {
        "description": {
          "type": "string",
          "maxLength": 500,
          "example": "API key used for ERP data synchronization"
        },
        "expires_at": {
          "type": "string",
          "example": "2025-12-31T23:59:59Z"
        },
        "name": {
          "type": "string",
          "maxLength": 255,
          "example": "ERP Sync Key"
        },
        "service_account_id": {
          "type": "string",
          "example": "01J5C2D3E4F5G6H7I8J9K0L1M2"
        }
      }
    },
    "CreateAPIKeyResponse": {
      "type": "object",
      "properties": {
        "created_at": {
          "type": "string",
          "example": "2025-01-15T08:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary2"
        },
        "description": {
          "type": "string",
          "example": "API key used for ERP data synchronization"
        },
        "expires_at": {
          "type": "string",
          "example": "2025-12-31T23:59:59Z"
        },
        "id": {
          "type": "string",
          "example": "01J5C2D3E4F5G6H7I8J9K0L1M2"
        },
        "key_prefix": {
          "type": "string",
          "example": "czk_a1b2c3d4"
        },
        "last_used_at": {
          "type": "string",
          "example": "2025-06-15T10:30:00Z"
        },
        "modified_at": {
          "type": "string",
          "example": "2025-01-16T10:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary2"
        },
        "name": {
          "type": "string",
          "example": "ERP Sync Key"
        },
        "raw_key": {
          "type": "string",
          "example": "czk_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0"
        },
        "service_account": {
          "$ref": "#/definitions/ServiceAccountSummary"
        },
        "status": {
          "type": "string",
          "example": "active"
        }
      }
    },
    "ServiceAccountSummary": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "erp-connector"
        },
        "id": {
          "type": "string",
          "example": "01J5C2D3E4F5G6H7I8J9K0L1M2"
        },
        "name": {
          "type": "string",
          "example": "ERP Connector"
        }
      }
    },
    "UpdateAPIKeyRequest": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string",
          "maxLength": 500,
          "example": "Updated description"
        },
        "expires_at": {
          "type": "string",
          "example": "2026-06-30T23:59:59Z"
        },
        "name": {
          "type": "string",
          "maxLength": 255,
          "example": "Updated ERP Key"
        }
      }
    },
    "ChangePasswordRequest": {
      "type": "object",
      "required": [
        "new_password",
        "old_password"
      ],
      "properties": {
        "new_password": {
          "type": "string",
          "minLength": 8,
          "example": "NewSecurePass456!"
        },
        "old_password": {
          "type": "string",
          "minLength": 8,
          "example": "OldPass123!"
        }
      }
    },
    "LoginRequest": {
      "type": "object",
      "required": [
        "client_id",
        "email",
        "password"
      ],
      "properties": {
        "client_id": {
          "type": "string",
          "example": "pim_web"
        },
        "email": {
          "type": "string",
          "example": "user@example.com"
        },
        "password": {
          "type": "string",
          "example": "SecurePass123!"
        },
        "tenant_id": {
          "description": "Optional: specify tenant",
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8d1"
        }
      }
    },
    "MeResponse": {
      "type": "object",
      "properties": {
        "active_tenant": {
          "$ref": "#/definitions/TenantInfo"
        },
        "permissions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "roles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "tenants": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/TenantInfo"
          }
        },
        "user": {
          "$ref": "#/definitions/UserInfo"
        }
      }
    },
    "RefreshTokenRequest": {
      "type": "object",
      "required": [
        "client_id",
        "refresh_token"
      ],
      "properties": {
        "client_id": {
          "type": "string",
          "example": "pim_web"
        },
        "refresh_token": {
          "type": "string",
          "example": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
        }
      }
    },
    "ResetPasswordRequest": {
      "type": "object",
      "required": [
        "new_password",
        "user_id"
      ],
      "properties": {
        "new_password": {
          "type": "string",
          "minLength": 8,
          "example": "ResetPass789!"
        },
        "user_id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8d2"
        }
      }
    },
    "SwitchTenantRequest": {
      "type": "object",
      "required": [
        "client_id",
        "tenant_id"
      ],
      "properties": {
        "client_id": {
          "type": "string",
          "example": "pim_web"
        },
        "tenant_id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8d3"
        }
      }
    },
    "TenantInfo": {
      "type": "object",
      "properties": {
        "is_default": {
          "type": "boolean",
          "example": true
        },
        "organization_code": {
          "type": "string",
          "example": "acme"
        },
        "organization_id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8d4"
        },
        "organization_name": {
          "type": "string",
          "example": "Acme Inc"
        },
        "status": {
          "type": "string",
          "example": "active"
        },
        "tenant_code": {
          "type": "string",
          "example": "tenant_001"
        },
        "tenant_id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8d1"
        },
        "tenant_name": {
          "type": "string",
          "example": "Acme Corporation"
        }
      }
    },
    "UserInfo": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8d2"
        },
        "name": {
          "type": "string",
          "example": "John Doe"
        }
      }
    },
    "ActorSummary3": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "example": "user"
        }
      }
    },
    "ChangeFeatureStatusRequest": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "active",
            "inactive"
          ],
          "example": "active"
        }
      }
    },
    "CreateFeatureRequest": {
      "type": "object",
      "required": [
        "code"
      ],
      "properties": {
        "code": {
          "type": "string",
          "example": "product_management"
        }
      }
    },
    "FeatureListItem": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "product_management"
        },
        "created_at": {
          "type": "string",
          "example": "2024-01-01T00:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary3"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8b1"
        },
        "modified_at": {
          "type": "string",
          "example": "2024-01-10T12:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary3"
        },
        "name": {
          "type": "string",
          "example": "Product Management"
        },
        "permission_count": {
          "type": "integer",
          "example": 15
        },
        "status": {
          "type": "string",
          "example": "active"
        },
        "sub_feature_count": {
          "type": "integer",
          "example": 5
        }
      }
    },
    "FeatureListResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/FeatureListItem"
          }
        },
        "pagination": {
          "$ref": "#/definitions/response.PaginationInfo"
        }
      }
    },
    "FeatureResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "product_management"
        },
        "created_at": {
          "type": "string",
          "example": "2024-01-01T00:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary3"
        },
        "description": {
          "type": "string",
          "example": "Manage product catalog and inventory"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8b1"
        },
        "modified_at": {
          "type": "string",
          "example": "2024-01-10T12:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary3"
        },
        "name": {
          "type": "string",
          "example": "Product Management"
        },
        "permission_count": {
          "type": "integer",
          "example": 15
        },
        "status": {
          "type": "string",
          "example": "active"
        },
        "sub_feature_count": {
          "type": "integer",
          "example": 5
        }
      }
    },
    "ActorSummary4": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "example": "user"
        }
      }
    },
    "ChangePermissionStatusRequest": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "active",
            "inactive"
          ],
          "example": "active"
        }
      }
    },
    "CreatePermissionRequest": {
      "type": "object",
      "required": [
        "code"
      ],
      "properties": {
        "code": {
          "type": "string",
          "maxLength": 100,
          "example": "iam:features:view"
        }
      }
    },
    "FeatureSummary": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "product_management"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8b1"
        },
        "name": {
          "type": "string",
          "example": "Product Management"
        }
      }
    },
    "PermissionListItem": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "product_management.product_catalog.create"
        },
        "created_at": {
          "type": "string",
          "example": "2024-01-01T00:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary4"
        },
        "feature": {
          "$ref": "#/definitions/FeatureSummary"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8f1"
        },
        "modified_at": {
          "type": "string",
          "example": "2024-01-10T12:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary4"
        },
        "name": {
          "type": "string",
          "example": "Create Product"
        },
        "status": {
          "type": "string",
          "example": "active"
        },
        "sub_feature": {
          "$ref": "#/definitions/SubFeatureSummary"
        }
      }
    },
    "PermissionListResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PermissionListItem"
          }
        },
        "pagination": {
          "$ref": "#/definitions/response.PaginationInfo"
        }
      }
    },
    "PermissionResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "product_management.product_catalog.create"
        },
        "created_at": {
          "type": "string",
          "example": "2024-01-01T00:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary4"
        },
        "description": {
          "type": "string",
          "example": "Permission to create products"
        },
        "feature": {
          "$ref": "#/definitions/FeatureSummary"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8f1"
        },
        "modified_at": {
          "type": "string",
          "example": "2024-01-10T12:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary4"
        },
        "name": {
          "type": "string",
          "example": "Create Product"
        },
        "status": {
          "type": "string",
          "example": "active"
        },
        "sub_feature": {
          "$ref": "#/definitions/SubFeatureSummary"
        }
      }
    },
    "SubFeatureSummary": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "product_catalog"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8c1"
        },
        "name": {
          "type": "string",
          "example": "Product Catalog"
        }
      }
    },
    "ActorSummary5": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "example": "user"
        }
      }
    },
    "ChangeRoleStatusRequest": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "active",
            "inactive"
          ],
          "example": "active"
        }
      }
    },
    "CreateRoleRequest": {
      "type": "object",
      "required": [
        "code",
        "name"
      ],
      "properties": {
        "code": {
          "type": "string",
          "example": "admin"
        },
        "description": {
          "type": "string",
          "example": "Full system access"
        },
        "name": {
          "type": "string",
          "maxLength": 255,
          "example": "Administrator"
        },
        "permission_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "example": [
            "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8f1",
            "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8f2"
          ]
        }
      }
    },
    "FeatureSummary2": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "PermissionListItem2": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "feature": {
          "$ref": "#/definitions/FeatureSummary2"
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "sub_feature": {
          "$ref": "#/definitions/SubFeatureSummary2"
        }
      }
    },
    "RoleListItem": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "admin"
        },
        "created_at": {
          "type": "string",
          "example": "2024-01-01T00:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary5"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8e1"
        },
        "modified_at": {
          "type": "string",
          "example": "2024-01-10T12:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary5"
        },
        "name": {
          "type": "string",
          "example": "Administrator"
        },
        "permission_count": {
          "type": "integer",
          "example": 20
        },
        "status": {
          "type": "string",
          "example": "active"
        },
        "tenant": {
          "$ref": "#/definitions/TenantSummary3"
        },
        "user_count": {
          "type": "integer",
          "example": 5
        }
      }
    },
    "RoleListResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RoleListItem"
          }
        },
        "pagination": {
          "$ref": "#/definitions/response.PaginationInfo"
        }
      }
    },
    "RolePermissionListResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/PermissionListItem2"
          }
        },
        "pagination": {
          "$ref": "#/definitions/response.PaginationInfo"
        }
      }
    },
    "RoleResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "admin"
        },
        "created_at": {
          "type": "string",
          "example": "2024-01-01T00:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary5"
        },
        "description": {
          "type": "string",
          "example": "Full system access"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8e1"
        },
        "modified_at": {
          "type": "string",
          "example": "2024-01-10T12:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary5"
        },
        "name": {
          "type": "string",
          "example": "Administrator"
        },
        "status": {
          "type": "string",
          "example": "active"
        }
      }
    },
    "SubFeatureSummary2": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "TenantSummary3": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "acme"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8d1"
        },
        "name": {
          "type": "string",
          "example": "Acme Corporation"
        }
      }
    },
    "UpdateRolePermissionsRequest": {
      "type": "object",
      "required": [
        "permission_ids"
      ],
      "properties": {
        "permission_ids": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string"
          }
        }
      }
    },
    "UpdateRoleRequest": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string",
          "example": "Updated description"
        },
        "name": {
          "type": "string",
          "example": "Super Administrator"
        }
      }
    },
    "ActorSummary6": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "example": "user"
        }
      }
    },
    "ChangeStatusRequest": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "active",
            "inactive"
          ],
          "example": "active"
        }
      }
    },
    "CreateServiceAccountRequest": {
      "type": "object",
      "required": [
        "code",
        "name"
      ],
      "properties": {
        "code": {
          "type": "string",
          "example": "erp-connector"
        },
        "description": {
          "type": "string",
          "example": "Service account for ERP integration"
        },
        "name": {
          "type": "string",
          "maxLength": 255,
          "example": "ERP Connector"
        },
        "role_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "example": [
            "01J5C2D3E4F5G6H7I8J9K0L1M2"
          ]
        }
      }
    },
    "RoleSummary": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "admin"
        },
        "id": {
          "type": "string",
          "example": "01J5C2D3E4F5G6H7I8J9K0L1M2"
        },
        "name": {
          "type": "string",
          "example": "Administrator"
        }
      }
    },
    "ServiceAccountListItem": {
      "type": "object",
      "properties": {
        "api_key_count": {
          "type": "integer",
          "example": 2
        },
        "code": {
          "type": "string",
          "example": "erp-connector"
        },
        "created_at": {
          "type": "string",
          "example": "2025-01-15T08:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary6"
        },
        "id": {
          "type": "string",
          "example": "01J5C2D3E4F5G6H7I8J9K0L1M2"
        },
        "modified_at": {
          "type": "string",
          "example": "2025-01-16T10:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary6"
        },
        "name": {
          "type": "string",
          "example": "ERP Connector"
        },
        "roles": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RoleSummary"
          }
        },
        "status": {
          "type": "string",
          "example": "active"
        }
      }
    },
    "ServiceAccountListResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ServiceAccountListItem"
          }
        },
        "pagination": {
          "$ref": "#/definitions/response.PaginationInfo"
        }
      }
    },
    "ServiceAccountResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "erp-connector"
        },
        "created_at": {
          "type": "string",
          "example": "2025-01-15T08:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary6"
        },
        "description": {
          "type": "string",
          "example": "Service account for ERP integration"
        },
        "id": {
          "type": "string",
          "example": "01J5C2D3E4F5G6H7I8J9K0L1M2"
        },
        "modified_at": {
          "type": "string",
          "example": "2025-01-16T10:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary6"
        },
        "name": {
          "type": "string",
          "example": "ERP Connector"
        },
        "roles": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RoleSummary"
          }
        },
        "status": {
          "type": "string",
          "example": "active"
        }
      }
    },
    "UpdateServiceAccountRequest": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string",
          "example": "Updated description"
        },
        "name": {
          "type": "string",
          "maxLength": 255,
          "example": "Updated ERP Connector"
        },
        "role_ids": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "example": [
            "01J5C2D3E4F5G6H7I8J9K0L1M2"
          ]
        }
      }
    },
    "ActorSummary7": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "example": "user"
        }
      }
    },
    "ChangeSubFeatureStatusRequest": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "active",
            "inactive"
          ],
          "example": "active"
        }
      }
    },
    "CreateSubFeatureRequest": {
      "type": "object",
      "required": [
        "code"
      ],
      "properties": {
        "code": {
          "type": "string",
          "example": "product_catalog"
        }
      }
    },
    "FeatureSummary3": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "product_management"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8b1"
        },
        "name": {
          "type": "string",
          "example": "Product Management"
        }
      }
    },
    "SubFeatureListItem": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "product_catalog"
        },
        "created_at": {
          "type": "string",
          "example": "2024-01-01T00:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary7"
        },
        "feature": {
          "$ref": "#/definitions/FeatureSummary3"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8c1"
        },
        "modified_at": {
          "type": "string",
          "example": "2024-01-10T12:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary7"
        },
        "name": {
          "type": "string",
          "example": "Product Catalog"
        },
        "permission_count": {
          "type": "integer",
          "example": 8
        },
        "status": {
          "type": "string",
          "example": "active"
        }
      }
    },
    "SubFeatureListResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SubFeatureListItem"
          }
        },
        "pagination": {
          "$ref": "#/definitions/response.PaginationInfo"
        }
      }
    },
    "SubFeatureResponse": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "product_catalog"
        },
        "created_at": {
          "type": "string",
          "example": "2024-01-01T00:00:00Z"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary7"
        },
        "description": {
          "type": "string",
          "example": "Manage product catalog entries"
        },
        "feature": {
          "$ref": "#/definitions/FeatureSummary3"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8c1"
        },
        "modified_at": {
          "type": "string",
          "example": "2024-01-10T12:00:00Z"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary7"
        },
        "name": {
          "type": "string",
          "example": "Product Catalog"
        },
        "permission_count": {
          "type": "integer",
          "example": 8
        },
        "status": {
          "type": "string",
          "example": "active"
        }
      }
    },
    "ActorSummary8": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "example": "user"
        }
      }
    },
    "AddUserRolesRequest": {
      "type": "object",
      "required": [
        "role_ids"
      ],
      "properties": {
        "role_ids": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string"
          },
          "example": [
            "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8e1",
            "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8e2"
          ]
        }
      }
    },
    "AssignUserToTenantRequest": {
      "type": "object",
      "properties": {
        "email": {
          "description": "New user fields (required when user_id is absent)",
          "type": "string",
          "maxLength": 255,
          "example": "john@company.com"
        },
        "name": {
          "type": "string",
          "maxLength": 255,
          "minLength": 1,
          "example": "John Doe"
        },
        "password": {
          "type": "string",
          "maxLength": 100,
          "minLength": 6
        },
        "role_ids": {
          "description": "Optional roles to assign (role IDs)",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "user_id": {
          "description": "Existing user — mutually exclusive with Email/Name",
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8d2"
        }
      }
    },
    "ChangeUserStatusRequest": {
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "active",
            "inactive",
            "suspended"
          ],
          "example": "active"
        }
      }
    },
    "RoleSummary2": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "example": "admin"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8e1"
        },
        "name": {
          "type": "string",
          "example": "Administrator"
        }
      }
    },
    "UpdateUserRequest": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "maxLength": 255,
          "example": "jane.smith@example.com"
        },
        "name": {
          "type": "string",
          "maxLength": 255,
          "minLength": 1,
          "example": "Jane Smith"
        },
        "role_ids": {
          "description": "Already optional with pointer",
          "type": "array",
          "items": {
            "type": "string"
          },
          "example": [
            "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8e1",
            "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8e2"
          ]
        }
      }
    },
    "UserDetailsResponse": {
      "type": "object",
      "properties": {
        "created_at": {
          "type": "string"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary8"
        },
        "email": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "last_login_at": {
          "type": "string"
        },
        "modified_at": {
          "type": "string"
        },
        "modified_by": {
          "$ref": "#/definitions/ActorSummary8"
        },
        "name": {
          "type": "string"
        },
        "roles": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RoleSummary2"
          }
        },
        "status": {
          "type": "string"
        }
      }
    },
    "UserListItem": {
      "type": "object",
      "properties": {
        "created_at": {
          "type": "string"
        },
        "created_by": {
          "$ref": "#/definitions/ActorSummary8"
        },
        "email": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "last_login_at": {
          "type": "string"
        },
        "modified_at": {
          "type": "string"
        },
        "modified_by": {
          "description": "Add this field",
          "allOf": [
            {
              "$ref": "#/definitions/ActorSummary8"
            }
          ]
        },
        "name": {
          "type": "string"
        },
        "roles": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RoleSummary2"
          }
        },
        "status": {
          "type": "string"
        }
      }
    },
    "UserListResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/UserListItem"
          }
        },
        "pagination": {
          "$ref": "#/definitions/response.PaginationInfo"
        }
      }
    },
    "UserResponse": {
      "type": "object",
      "properties": {
        "created_at": {
          "type": "string",
          "example": "2024-01-01T00:00:00Z"
        },
        "email": {
          "type": "string",
          "example": "user@example.com"
        },
        "id": {
          "type": "string",
          "example": "0193a5b6-e7c0-7df0-b4b1-c0a1f5e3a8d2"
        },
        "last_login_at": {
          "type": "string",
          "example": "2024-01-15T10:30:00Z"
        },
        "modified_at": {
          "type": "string",
          "example": "2024-01-10T12:00:00Z"
        },
        "name": {
          "type": "string",
          "example": "John Doe"
        },
        "status": {
          "type": "string",
          "example": "active"
        }
      }
    },
    "UserTenantItem": {
      "type": "object",
      "properties": {
        "billing_interval": {
          "type": "string"
        },
        "code": {
          "type": "string"
        },
        "contact_email": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "is_default": {
          "type": "boolean"
        },
        "name": {
          "type": "string"
        },
        "organization_id": {
          "type": "string"
        },
        "phone": {
          "type": "string"
        },
        "plan": {
          "type": "string"
        },
        "status": {
          "type": "string"
        }
      }
    },
    "UserTenantListResponse": {
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/UserTenantItem"
          }
        },
        "pagination": {
          "$ref": "#/definitions/response.PaginationInfo"
        }
      }
    }
  },
  "securityDefinitions": {
    "BearerAuth": {
      "type": "apiKey",
      "name": "Authorization",
      "in": "header"
    }
  }
}