Skip to main content
Prod AI builds secure access control into your app by default. When you describe who should see what, the coding agent puts authorization checks in the right place, filtering data in backend APIs using the authenticated user’s identity and adjusting the UI to match. This guide covers how in-app access control works and how to prompt for it.

How it works

User identity

Every backend API in Prod AI has access to the current user’s identity through ctx.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:
Backend — filtering data by user identity:
Frontend — conditional rendering based on group:
You don’t need to write any of this yourself. The coding agent generates it from your prompt. These examples are here so you can recognize the generated code and understand what it’s doing.

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 using ctx.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.
From this single prompt, Prod AI builds the backend API with ctx.user checks, filters the data query, and conditionally renders the button.

More examples

Gating an API:
Row-level security:
Multi-level access:
Frontend UX:

Tips for better results

Setting up groups

For in-app access control to work, your users need to be in the right groups: