Kommander.ai combines account authentication, organization membership, organization permissions, owner checks, widget identity verification, and internal admin flags. API routes should fail closed with 401 when there is no session and 403 when the session is authenticated but not allowed.
RBAC Flow
Organization Roles
| Role | Default permissions |
|---|---|
admin | Read and manage organization, members, invitations, billing, integrations, analytics, conversations, and knowledge base. Includes admin_access. |
manager | Manage members, invitations, integrations, analytics, conversations, and read knowledge base. |
user | Read organization, read/write conversations, and read knowledge base. |
viewer | Read organization, conversations, and knowledge base. |
guest | Read organization only. |
operator | Read organization, access analytics, read/write conversations, and read knowledge base. |
Custom member permission arrays may narrow or expand a member’s effective access. Endpoint checks should use the permission string, owner rule, or admin flag documented below instead of role names when the code supports granular permissions.
Endpoint Matrix
| Endpoint family | Methods | Required access | Notes |
|---|---|---|---|
/api/admin/* | All | Platform admin session with isAdmin: true | Internal admin surface. Organization roles do not grant access. |
/api/admin/auth | POST | Valid admin credentials and isAdmin: true user record | Issues admin session material for the admin console. |
/api/admin/client-assistants, /api/admin/client-assistants/[id], /api/admin/client-assistants/[id]/claim-link | GET, POST, PATCH, DELETE | Platform admin bearer token with isAdmin: true | Creates assistants for clients, sets their prices and trial, and makes or revokes claim links. Every write is audited. |
/api/organizations | GET | Authenticated user | Lists organizations visible to the signed-in user. |
/api/organizations | POST | Authenticated user | Creates an organization owned by the signed-in user. |
/api/organizations/[id] | PATCH | manage_organization or owner-equivalent service check | Updates organization metadata. |
/api/organizations/[id] | DELETE | Owner or service-approved organization manager | Soft-deletes the organization and reconciles billing links. |
/api/organizations/[id]/members | GET, POST, PATCH | manage_members | Reads, adds, or updates organization members. |
/api/organizations/[id]/members | DELETE | remove_users | Removes a member from the organization. |
/api/organizations/[id]/invitations | POST | invite_users | Creates organization invitations. |
/api/invitations/* | GET, POST | Valid invitation token or authenticated inviter, depending on route | Token routes validate invitation status and expiry. |
/api/organizations/[id]/integrations/engammo/* | All | manage_integrations | Includes configuration, FAQ sync, events, and secret rotation. |
/api/integrations/customer-data | GET | Authenticated user; organization member or owner when organizationId is supplied | Without organizationId, returns connections created by the user. |
/api/integrations/customer-data | POST | Authenticated user with organization member or owner access | Creates a customer data connector. |
/api/integrations/customer-data/[id] | GET, PATCH, DELETE | Authenticated user with access to the connector’s organization | Connector credentials are never returned in plaintext. |
/api/integrations/customer-data/[id]/openapi | POST | Authenticated user with access to the connector’s organization | Uploads and validates OpenAPI specs for OpenAPI customer data connectors. |
/api/integrations/customer-data/[id]/test | POST | Authenticated user with access to the connector’s organization | Runs bounded connector test calls. |
/api/settings/identity-verification | GET, POST | Organization owner or active organization member | Reads or creates widget identity verification settings for the target owner. |
/api/widget-clients/[id]/rotate-identity-secret | POST | Organization owner or active organization member | Rotates identity verification secrets for the target widget client. |
/api/organizations/[id]/subscribe | POST, PUT | Organization owner only | Creates or updates paid channel subscriptions. Refused (409) for client assistants, which are billed through their claim link. |
/api/organizations/[id]/subscribe/preview | GET | Organization owner only | Previews billing changes. |
/api/claim/[token] | POST | Authenticated user holding a live claim token; never the admin who prepared the assistant | Subscribes the user at the token’s terms and makes them owner. Token stored hashed, single use, 30 days; rate limited per user. |
/api/stripe/* | POST | Stripe webhook signature, checkout session, or authenticated billing context depending on route | Webhooks rely on provider signature verification, not user session. |
/api/subscription, /api/payment-methods, /api/billing-profile/* | GET, POST | Authenticated account owner | User-level billing views and payment-method management. |
/api/conversations/* | GET, POST, PATCH | Authenticated user scoped to accessible conversations | Organization-scoped reads must preserve conversation ownership and organization filters. |
/api/conversations/[id]/agent-message | PATCH | write_conversations on the conversation owner, and the caller is the message author (sentBy.userId) | Edits the text of an operator message already sent. Messages without a recorded author cannot be edited; internal-secret calls are refused. |
/api/widget-conversations/* | GET, POST | Widget client plus conversation identifier | Public widget traffic must remain scoped to the widget client and conversation. |
/api/kommander-rag-query, /api/kommander-rag-stream, /api/kommander-rag-callback | POST | Widget/API request context; customer data tools require verified identity | Public chat can run without identity; customer-specific tools cannot. |
/api/kommander-rag-trigger-whatsapp, /api/meta/[userId], /api/twilio/[userId] | POST | Channel-specific webhook verification and user or organization lookup | Webhook payloads must be scoped to the configured channel owner. |
/api/analytics/*, /api/dashboard/*, /api/operator/* | GET, POST | Authenticated user with analytics, dashboard, or operator access as implemented by the route | Use organization scope when a route accepts organizationId. |
/api/process-file, /api/mark-faq-edited | POST | Authenticated user scoped to the target assistant or organization | Uploaded training data should remain organization-scoped. |
Review Rules
- Prefer permission checks such as
manage_integrationsandmanage_membersover ad hoc role-name checks. - Keep platform admin access separate from organization
admin. - Billing subscription changes require the organization owner unless a route is explicitly an internal admin route.
- Public widget and webhook routes must authenticate the widget client or provider signature before trusting identifiers in the payload.
- Customer data tools require verified end-user identity with a non-empty
userHash. - Seat changes must update organization membership, role, status, and permission data; they should not be treated as billing entitlement changes unless an enterprise contract says otherwise.
Known Authorization Gaps To Review
Some routes use organization membership or owner checks where a stricter permission may be more appropriate. When modifying an endpoint, compare it against this matrix and tighten broad membership checks if the route changes sensitive configuration, credentials, billing, or customer data access.