Restores `agents-access` (**Coder Agents User**) as a built-in organization role and adds it to every organization's `default_org_member_roles`. Members keep Coder Agents by default, and admins can now restrict it per organization by removing the role from the defaults and granting it through IdP role sync or direct assignment. Since #28186, chat permissions lived in the organization-member floor, so the only way to limit Coder Agents was narrowing per-model access lists, which did not hide the feature. - Migration 000602 appends `agents-access` to every organization's defaults, so upgrading keeps every member's access. New organizations get it from `rbac.DefaultOrgMemberRoles()`. - Service accounts do not inherit the role from the defaults (`GetAuthorizationUserRoles`), so they still need an explicit grant for chat. - Owners and Organization Admins keep chat access regardless of defaults. Chats shared with a user stay readable without the role. - Role sync is unchanged. It does not store default roles, so after the default is removed a mapped user gets `agents-access` at their next sign-in. - The retired-role mechanism (`IsRetiredRoleName`) is removed. - `PATCH /api/v2/organizations/{organization}` rejects duplicate `default_org_member_roles` entries (the CLI already de-duplicated them). - Custom organization role requests treat built-in role names case-insensitively, since custom role names are stored lowercase and `Agents-Access` would otherwise become an undeletable shadow of the built-in role. - The Agents permission alert tells restricted members their chats are kept, and the model selector for users without chat permission no longer claims that no models are configured. Docs add "Control who can use Coder Agents" to the Agents getting-started guide. **NOTE**: Migration 000602 deletes custom roles named `agents-access`, which the built-in role would shadow. The down migration does not restore them. Stored member grants of `agents-access` from the earlier built-in role or a deleted custom role stay and now grant chat access. ## Validation - Remote dogfood [UAT](https://dogfood.cdr.dev/agents/e1c18dc6-f6f0-49a1-b6cd-6ce014b51a86) passed onfb441dfae5, covering case variants of built-in role names on create, update, delete, default roles, and member grants. The previous round, ona6fef66b3f, passed the upgrade from main5dde49dffbon a fresh database.6b7f107e0bonly changes wording (docs, comments, UI copy, CLI help) and did not go through UAT. - Local: rbac, dbauthz, idpsync, migrations (chain including 000602 down and up), querier, httpmw, provisionerdserver, coderd and enterprise chat, role, and organization tests, chatd, toolsdk, CLI; frontend vitest, story tests, biome, oxlint, tsc. ## Known issues (not changed here) - Sending from a chat page that was already open when access was removed shows a generic 404 panel until reload. - The members page role editor is not locked for OIDC users under org role sync; the API rejects the change with 400. - Creating a custom role named after a system role (`organization-member`, `organization-service-account`) returns 400 with a raw database unique-constraint error. <details> <summary>Review record</summary> - Remote UAT (UAT Critic sub-agent `6636c855ec`): round 1 on8bec029d35passed with issues, fixed ind7ba937a10and e0f16e1a45f; round 2 ona6fef66b3fpassed; round 3 onfb441dfae5passed. - Codex: round 1 ona6fef66b3ffound one P2 (case variants of built-in role names), fixed infb441dfae5with a red-green test. Rounds 2 and 3 onfb441dfae5found no major issues. - mafredri onfb441dfae5(PR text only): nine wording suggestions applied in 6b7f107e0b9; NOTE extended for stored grants; description trimmed. - Frontend: FE1 to FE10 and coder-frontend-review checkpoints self-audited. </details> > 🤖 This PR was opened by [Xum](https://mux.coder.com) on behalf of @ibetitsmike.
7.0 KiB
title
| title |
|---|
| Organizations (Premium) |
Note
Organizations requires a Premium license. For more details, contact your account team.
Organizations can be used to segment and isolate resources inside a Coder deployment for different user groups or projects.
Example
Here is an example of how one could use organizations to run a Coder deployment with multiple platform teams, all with unique resources:
For more information about how to use organizations, visit the organizations best practices guide.
The default organization
All Coder deployments start with one organization called coder. All new users
are added to this organization by default.
To edit the organization details, select Admin settings from the top bar, then Organizations:
From there, you can manage the name, icon, description, users, and groups:
Additional organizations
Any additional organizations have unique admins, users, templates, provisioners, groups, and workspaces. Each organization must have at least one dedicated provisioner since the built-in provisioners only apply to the default organization.
You can configure organization/role/group sync from your identity provider to avoid manually assigning users to organizations.
How to create an organization
Prerequisites
- Coder v2.16+ deployment with Premium license and Organizations enabled (contact your account team) for more details.
- User with
Ownerrole
1. Create the organization
To create a new organization:
-
Select Admin settings from the top bar, then Organizations.
-
Select the current organization to expand the organizations dropdown, then select Create Organization:
-
Enter the details and select Save to continue:
In this example, we'll create the data-platform org.
Next deploy a provisioner and template for this organization.
2. Deploy a provisioner
Provisioners are organization-scoped and are responsible for executing Terraform/OpenTofu to provision the infrastructure for workspaces and testing templates. Before creating templates, we must deploy at least one provisioner as the built-in provisioners are scoped to the default organization.
-
Using Coder CLI, run the following command to create a key that will be used to authenticate the provisioner:
coder provisioner keys create data-cluster-key --org data-platform Successfully created provisioner key data-cluster! Save this authentication token, it will not be shown again. < key omitted > -
Start the provisioner with the key on your desired platform.
In this example, start the provisioner using the Coder CLI on a host with Docker. For instructions on using other platforms like Kubernetes, see our provisioner documentation.
export CODER_URL=https://<your-coder-url> export CODER_PROVISIONER_DAEMON_KEY=<key> coder provisionerd start --org <org-name>
3. Create a template
Once you've started a provisioner, you can create a template. You'll notice the Create Template screen now has an organization dropdown:
4. Add members
From Admin settings, select Organizations, then Members to add members to your organization. Once added, members will be able to see the organization-specific templates.
5. Create a workspace
Now, users in the data platform organization will see the templates related to their organization. Users can be in multiple organizations.
Default member roles
Note
Editing default member roles requires a Premium license. (learn more).
Each organization carries a default_org_member_roles list of built-in role
names. Coder unions this list into every member's effective roles at request
time, so changes propagate to all current and future members on their next
request without re-issuing tokens or editing per-user role assignments.
The default value is ["organization-workspace-access", "agents-access"].
With that default, every organization member can read, build, ssh into, and
execute commands in workspaces they own, and can use Coder Agents. Removing
organization-workspace-access from the list creates organization members
that cannot create or use workspaces unless the role is assigned to them
directly, which is useful for restricted accounts that should only hold the
minimal member permissions. Removing agents-access limits Coder Agents to
members who hold the role directly. Refer to
Control who can use Coder Agents.
Service accounts don't inherit agents-access from this list. Assign the
role to a service account directly to let it use Coder Agents.
To edit the default roles in the dashboard, go to Admin settings > Organizations > Roles > Default Roles.
From the CLI, use coder organizations edit:
coder organizations edit --org <organization> \
--default-org-member-roles organization-workspace-access,agents-access,organization-template-admin
The flag replaces the current list rather than adding to it, and accepts a
comma-separated list of built-in role names. Pass an empty value to remove
every role. Removing a role prompts for confirmation unless you pass
--yes.
You can also set default_org_member_roles via
PATCH /organizations/{organization}.
Limitations
default_org_member_rolesaccepts built-in role names only. Custom organization roles are rejected; assign them directly to members instead.- Removing a role from the list removes it from every member that does not hold the role through a direct assignment, including existing members. Review the per-organization audit log if you need to trace who changed the defaults.



