How it works
User identity
Every backend API in Prod AI has access to the current user’s identity throughctx.user. This is populated from the authenticated session and can’t be modified by the end user or passed in from the frontend.
When you ask the coding agent to restrict access, it uses
ctx.user in backend API code to gate access or filter data. This is the secure path because the identity comes from the server, not the browser.
Groups
Groups are the main building block for access control. They map to your identity provider (Okta, Azure AD, etc.) via SCIM sync, or can be managed manually in Organization Settings. For example, a user in the"finance-admins" group might see all invoices, while a user in "finance-viewers" can only see their own department’s records.
Backend vs. frontend checks
Prod AI apps enforce access control in two layers:
Backend checks are the security boundary. Frontend checks improve the experience by not showing users things they can’t access. Both layers are generated automatically when you describe the access behavior you want.
What gets generated
When you describe access control requirements, Prod AI generates code like the following. Backend — gating an entire API:Common patterns
Role-gated API access
Restrict an entire API to users in a specific group. If the user isn’t in the group, the API returns an error before accessing any data. Good for: Admin dashboards, sensitive operations (delete, export), management tools.Row-level security
Filter query results usingctx.user.email or ctx.user.userId so users only see their own data.
Good for: Multi-tenant apps, “my orders” views, user-specific dashboards.
Feature-level gating
Return different fields or allow different mutations depending on the user’s group, without blocking the entire API. Good for: APIs that serve multiple roles (viewers see read-only data, editors can update).Frontend conditional rendering
Hide buttons, tabs, or pages for users who don’t have access. The coding agent pairs this with backend enforcement automatically. Good for: Navigation menus, action buttons, admin-only sections.How to prompt for access control
Describe who and what
Specify which group should have access and what they should (or shouldn’t) see. Be specific about group names.ctx.user checks, filters the data query, and conditionally renders the button.
More examples
Gating an API:Tips for better results
Setting up groups
For in-app access control to work, your users need to be in the right groups:- SCIM sync (recommended): Sync groups from your IdP (Okta, Azure AD) automatically. See Manage users and groups with SCIM.
- Manual management: Create and assign groups in Organization Settings. See Managing user groups.