{ "openapi": "3.1.0", "info": { "title": "AI-Native Business OS API - Identity", "version": "0.1.0", "summary": "Standalone OpenAPI 3.1 spec for the Identity domain.", "description": "Extracted from business_os_openapi.yaml.\nDomain: Identity.\nUsable independently for C++ code generation." }, "servers": [ { "url": "https://api.example.com", "description": "Cloudflare-routed production API" }, { "url": "http://localhost:3000", "description": "Local business node API" }, { "url": "http://business-node.local:3000", "description": "LAN local business node API" } ], "security": [ { "BearerAuth": [ ] } ], "tags": [ { "name": "Identity", "description": "Authentication, users, roles, and permissions." } ], "paths": { "/api/v1/auth/login": { "post": { "tags": [ "Identity" ], "summary": "Log in", "operationId": "login", "security": [ ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LoginRequest" } } } }, "responses": { "200": { "description": "OK. The access_token is a signed JWT containing claims: sub (userId), tenant (tenantId), org (orgId), and perms (array of permission strings in {domain}:{action} format, flattened from all user roles). TokenResponse.permissions in the response body provides the same flattened permission list for client convenience.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TokenResponse" } } } }, "401": { "description": "Invalid credentials", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } } }, "/api/v1/auth/refresh": { "post": { "tags": [ "Identity" ], "summary": "Refresh token", "operationId": "refreshToken", "security": [ ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RefreshTokenRequest" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TokenResponse" } } } }, "401": { "description": "Invalid refresh token", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } }, "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" } ] } }, "/api/v1/auth/logout": { "post": { "tags": [ "Identity" ], "summary": "Log out", "operationId": "logout", "responses": { "204": { "description": "Logged out" } }, "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" }, { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" } ] } }, "/api/v1/auth/me": { "get": { "tags": [ "Identity" ], "summary": "Get current user", "operationId": "getCurrentUser", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/User" } } } } }, "parameters": [ { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" } ] } }, "/api/v1/users": { "get": { "tags": [ "Identity" ], "summary": "List users", "description": "Returns a paginated list of users.", "operationId": "listUsers", "parameters": [ { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" }, { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 250, "default": 50 } }, { "name": "cursor", "in": "query", "schema": { "type": "string" } }, { "name": "q", "in": "query", "schema": { "type": "string" } }, { "name": "sort", "in": "query", "schema": { "type": "string" } }, { "name": "location_id", "in": "query", "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserPage" } } } }, "400": { "description": "Invalid query", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } }, "post": { "tags": [ "Identity" ], "summary": "Create User", "description": "Creates a new User.", "operationId": "createUser", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserCreate" } } } }, "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/User" } } } }, "400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } }, "409": { "description": "Conflict", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } }, "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" }, { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" } ] } }, "/api/v1/users/{userId}": { "get": { "tags": [ "Identity" ], "summary": "Get User", "operationId": "getUser", "parameters": [ { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" }, { "name": "userId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/User" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } }, "patch": { "tags": [ "Identity" ], "summary": "Update User", "operationId": "updateUser", "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" }, { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" }, { "name": "userId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UserUpdate" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/User" } } } }, "400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } }, "delete": { "tags": [ "Identity" ], "summary": "Delete User", "operationId": "deleteUser", "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" }, { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" }, { "name": "userId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "204": { "description": "Deleted" }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } } }, "/api/v1/roles": { "get": { "tags": [ "Identity" ], "summary": "List roles", "description": "Returns a paginated list of roles.", "operationId": "listRoles", "parameters": [ { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" }, { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 250, "default": 50 } }, { "name": "cursor", "in": "query", "schema": { "type": "string" } }, { "name": "q", "in": "query", "schema": { "type": "string" } }, { "name": "sort", "in": "query", "schema": { "type": "string" } }, { "name": "location_id", "in": "query", "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RolePage" } } } }, "400": { "description": "Invalid query", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } }, "post": { "tags": [ "Identity" ], "summary": "Create Role", "description": "Creates a new Role.", "operationId": "createRole", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RoleCreate" } } } }, "responses": { "201": { "description": "Created", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Role" } } } }, "400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } }, "409": { "description": "Conflict", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } }, "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" }, { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" } ] } }, "/api/v1/roles/{roleId}": { "get": { "tags": [ "Identity" ], "summary": "Get Role", "operationId": "getRole", "parameters": [ { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" }, { "name": "roleId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Role" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } }, "patch": { "tags": [ "Identity" ], "summary": "Update Role", "operationId": "updateRole", "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" }, { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" }, { "name": "roleId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RoleUpdate" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Role" } } } }, "400": { "description": "Validation error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } }, "delete": { "tags": [ "Identity" ], "summary": "Delete Role", "operationId": "deleteRole", "parameters": [ { "$ref": "#/components/parameters/IdempotencyKey" }, { "$ref": "#/components/parameters/TenantId" }, { "$ref": "#/components/parameters/OrganizationId" }, { "$ref": "#/components/parameters/LocationId" }, { "name": "roleId", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "204": { "description": "Deleted" }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } } } }, "components": { "securitySchemes": { "BearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" }, "ApiKeyAuth": { "type": "apiKey", "in": "header", "name": "X-API-Key" }, "WebhookSignature": { "type": "apiKey", "in": "header", "name": "X-BusinessOS-Signature" } }, "parameters": { "IdempotencyKey": { "name": "Idempotency-Key", "in": "header", "schema": { "type": "string" }, "description": "Idempotency key for safe retries." }, "LocationId": { "name": "X-Location-Id", "in": "header", "schema": { "type": "string", "format": "uuid" }, "description": "Location context." }, "OrganizationId": { "name": "X-Organization-Id", "in": "header", "schema": { "type": "string", "format": "uuid" }, "description": "Organization context." }, "TenantId": { "name": "X-Tenant-Id", "in": "header", "schema": { "type": "string", "format": "uuid" }, "description": "Tenant context for multi-tenant deployments." } }, "schemas": { "ErrorResponse": { "type": "object", "properties": { "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "details": { "type": "object", "additionalProperties": true }, "trace_id": { "type": "string" } }, "required": [ "code", "message" ] } }, "required": [ "error" ] }, "LoginRequest": { "type": "object", "properties": { "email": { "type": "string", "format": "email" }, "password": { "type": "string", "format": "password" }, "mfa_code": { "type": "string", "nullable": true } }, "required": [ "email", "password" ] }, "Pagination": { "type": "object", "properties": { "limit": { "type": "integer" }, "cursor": { "type": "string", "nullable": true }, "next_cursor": { "type": "string", "nullable": true }, "has_more": { "type": "boolean" }, "total": { "type": "integer", "nullable": true } }, "required": [ "limit", "has_more" ] }, "RefreshTokenRequest": { "type": "object", "properties": { "refresh_token": { "type": "string" } }, "required": [ "refresh_token" ] }, "Role": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "tenant_id": { "type": "string", "format": "uuid" }, "organization_id": { "type": "string", "format": "uuid" }, "location_id": { "type": "string", "format": "uuid", "nullable": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "deleted_at": { "type": "string", "format": "date-time", "nullable": true }, "metadata": { "type": "object", "additionalProperties": true }, "name": { "type": "string" }, "scope": { "type": "string", "enum": [ "tenant", "organization", "location" ] }, "permissions": { "type": "array", "items": { "type": "string" } } }, "required": [ "id", "tenant_id", "organization_id", "created_at", "updated_at", "name", "scope" ] }, "RoleCreate": { "type": "object", "properties": { "name": { "type": "string" }, "scope": { "type": "string" }, "permissions": { "type": "array", "items": { "type": "string" } } }, "required": [ "name", "scope" ] }, "RolePage": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/Role" } }, "pagination": { "$ref": "#/components/schemas/Pagination" } }, "required": [ "data", "pagination" ] }, "RoleUpdate": { "type": "object", "properties": { "name": { "type": "string" }, "scope": { "type": "string" }, "permissions": { "type": "array", "items": { "type": "string" } } }, "required": [ ] }, "TokenResponse": { "type": "object", "properties": { "access_token": { "type": "string" }, "refresh_token": { "type": "string" }, "token_type": { "type": "string", "default": "Bearer" }, "expires_in": { "type": "integer" }, "user": { "$ref": "#/components/schemas/User" }, "permissions": { "type": "array", "items": { "type": "string" }, "description": "Flattened list of all permission strings from all roles assigned to this user. Uses {domain}:{action} format (e.g. 'identity:read', 'hrm:write'). This is a convenience field — the same data is available via user.roles[].permissions[]." } }, "required": [ "access_token", "token_type", "expires_in", "user", "permissions" ] }, "User": { "type": "object", "properties": { "id": { "type": "string", "format": "uuid" }, "tenant_id": { "type": "string", "format": "uuid" }, "organization_id": { "type": "string", "format": "uuid" }, "location_id": { "type": "string", "format": "uuid", "nullable": true }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" }, "deleted_at": { "type": "string", "format": "date-time", "nullable": true }, "metadata": { "type": "object", "additionalProperties": true }, "email": { "type": "string", "format": "email" }, "display_name": { "type": "string" }, "status": { "type": "string", "enum": [ "invited", "active", "disabled", "locked" ] }, "person_id": { "type": "string", "format": "uuid", "nullable": true }, "roles": { "type": "array", "items": { "$ref": "#/components/schemas/Role" } }, "last_login_at": { "type": "string", "format": "date-time", "nullable": true } }, "required": [ "id", "tenant_id", "organization_id", "created_at", "updated_at", "email", "display_name", "status" ] }, "UserCreate": { "type": "object", "properties": { "email": { "type": "string", "format": "email" }, "display_name": { "type": "string" }, "person_id": { "type": "string", "format": "uuid" }, "role_ids": { "type": "array", "items": { "type": "string", "format": "uuid" } } }, "required": [ "email", "display_name" ] }, "UserPage": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/User" } }, "pagination": { "$ref": "#/components/schemas/Pagination" } }, "required": [ "data", "pagination" ] }, "UserUpdate": { "type": "object", "properties": { "email": { "type": "string", "format": "email" }, "display_name": { "type": "string" }, "person_id": { "type": "string", "format": "uuid" }, "role_ids": { "type": "array", "items": { "type": "string", "format": "uuid" } } }, "required": [ ] } } } }