This topic explains how to work with role scope and role attributes. A role scope is a resource type by which a role may be parameterized. When you define a role, you can optionally specify a role scope and the parameter, which is called a role attribute.
If multiple members or teams should have similar permissions, but work with different resources, then defining role scope using an attribute key lets you reuse the same role for many members or teams. This means the total number of roles in your account is much smaller, and much easier to maintain.
This topic includes:
When you create a new role, you can specify resources that the role can or cannot access in the following ways:
Role attributes are defined and assigned within LaunchDarkly. They cannot be passed through SAML assertions for single sign-on. For SAML-based SSO, LaunchDarkly supports mapping only the role, customRole, and teamKey attributes.
To define role scope using a role attribute when you create a new role policy:



You set the value of the role attribute when you assign this role to a member or team. In this example, you would enter values for one or more project keys when you assign this role. To learn how, read Set role attribute values, below.
To learn more about creating roles, read Creating roles and policies.
You set a role attribute value, or specific resource, when you assign a role to an account member or team. In the “Assign access” dialog, enter the values for the role attribute in the Resources field:

You can enter one or more values when you set the role attribute. For example, you can set the value of the role attribute to projectA (the project key of “Project A”) when you assign the role to one member, and then set the value of the role attribute to projectB and projectC (the project keys of “Project B” and “Project C”) when you assign the role to a different member.
You can also use the REST API: Custom roles.
In the REST API, use the syntax ${roleAttribute/<attributeKey>}, for example ${roleAttribute/developerProjectKey}, in your policy statements.
To learn more, read Assigning roles to members and Assigning roles to teams.
Without role scope, if you have two members who require a similar set of permissions, but require access to different flags, you need to define two roles, one for each member:
Given additional flags, or additional projects, the number of roles required increases rapidly, and quickly becomes unmanageable.
You can use role scope to define just one role. Then, you can assign the same role to both members.
Here’s the previous set of roles, rewritten to use the flagKey role attribute:
When you assign this role to each member, you set the value of flagKey to the specific flag that that member should have access to.
You can use multiple role attributes in a given role. For example, if you also wanted to parameterize the project, you could use a separate role attribute for that:
In this case, LaunchDarkly prompts you to set the value of both role attributes when you assign the role to a member.
For additional examples of roles defined using role attributes, read:
For some policy statements, you may need a combination of the advanced editor and the REST API to define a policy that uses role scope or to set role attribute values.
You can define a role scope for a view when you create a role.
The policy builder supports using the viewKey role attribute in a statement with a “view” resource scope. Here’s an example policy:

This statement allows access to all actions on the views specified by viewKey in the project specified by projectKey.
In the advanced editor, the statement looks like this:
You can also use a view role attribute in a flag scope statement. Here’s an example:
This statement allows access to all actions on flags in the project specified by projectKey, in all environments, provided the flags are linked to the view specified by viewKey.
If the viewKey role attribute is only used in a selector, LaunchDarkly may not prompt you to set its value when you assign this role to a member or team using the LaunchDarkly UI. If this happens, use the Modify an account member REST API to set the value of the role attribute.
Here’s an example request body that gives the viewKey role attribute a value of exampleView for a member:
When a member creates a feature flag, they can associate it with multiple views in a single request. A createFlag statement scoped to one view does not prevent a member from listing additional views in the same API call. This means that a member may be able to add a flag to a view that they do not have access to, as long as they are also adding it to a view they do have permission to add flags to. Access to the flag after it exists is still governed by your other policy statements.
You cannot use role attributes in tag-based policy statements.
For most role-scoping use cases, use views instead of tags. Views provide a supported way to group resources and assign access within a project. To learn more, read Onboarding to views and Use views in complex policy statements.