API key role bindings
API keys can receive roles through three methods:
- Direct assignment: Assign roles directly to the API key.
- IdP group assignment: Associate API keys with IdP groups to inherit group-based role assignment.
- Login policy assignment: Use OPA policies to assign roles based on API key attributes (this can include assignment based on IdP group membership).
Immediate role changes
Except for login policies, role assignments and changes to roles take effect immediately (they force re-authentication if needed).
API keys seat usage
API Keys are included in your seat count, where applicable. On the Free tier, API keys are counted against their own separate limit. On paid tiers, API keys are usually shared with the user seat limit.
All API Keys that were active in the last 30 days (rolling) count as a used seat.
However, IAM allows for personal API keys tied to a specific user. On paid tiers a person and all their personal API keys count as one seat in the rolling 30 day window, whether the person logs in or only their keys are used. On the Free tier each personal API key that was used in the last 30 days counts against the API key limit, like an organization key.
Assign roles
Assign roles to API keys directly using the web UI
Permission Scope
- Root Space Admins can create/modify/delete API keys and manage role bindings across all spaces
- Non-root Space Admins can view all API keys but only manage role bindings for spaces they administer; they cannot create/modify/delete API keys
- Verify you meet the prerequisites:
- The selected management strategy for your organization must be Identity Access Management.
- The key must exist in your Spacelift organization.
- You must have Space Admin permissions on the target space where you want to assign roles (or Root Space Admin permissions for all spaces).
- Spaces where you want to assign roles must exist.
- Navigate to API Key Management:
- Click your name in the bottom left corner of the Spacelift interface.
- Go to Organization Settings.
- Go to ** API Keys in the Identity Management section.
- Find the API key you want to assign roles to.
- Click on the API key row to open its details.
- Access role management:
- In the API key details page, click Manage Roles.
- This opens the role assignment interface for the API key.
- Assign roles:
- Select Role: Choose appropriate role for the automation.
- Select Space: Choose the space where the role applies.
- Save Assignment: Confirm the role assignment.
Refer to Spacelift Terraform provider documentation for more details.
Assign roles to API keys directly using login policies
- Verify you meet the prerequisites:
- The selected management strategy for your organization must be Login Policies.
- You must have appropriate permissions to create or modify login policies.
- Understanding of OPA/Rego policy language.
- Use the
roles rule to assign roles to users:
By key name
By key pattern
Separate keys per environment
Multi-environment keys
CI/CD pipeline keys
Conditional API key access
IP-restricted API keys
Assign roles to API keys using IdP groups
See IdP group role bindings for details on how to assign roles to IdP groups. Once a role is assigned to an IdP group, all actors (api keys and users that your identity provider reports as being members of that group) will inherit the assigned roles.
Remove an API key role binding
- Navigate to API Key Management:
- Click your name in the bottom left corner of the Spacelift interface.
- Go to Organization Settings.
- Go to API Keys in the Identity Management section.
- Find the API key you want to assign roles to.
- Click on the API key row to open its details.
- Access role management:
- In the API key details page, click Manage Roles.
- This opens the role assignment interface for the API key.
- Remove role assignment:
- Find the role assignment to remove.
- Click Unassign from the dropdown.
- Confirm the removal.
Multiple roles
Actors can have multiple roles across different spaces:
- Different roles in different spaces for varied access levels.
- Multiple roles in the same space (permissions are additive).
- Roles inherited from group membership plus individual assignments.
Find role IDs
To use custom roles in login policies, you need their role slugs:
- Navigate to Organization Settings → Access Control Center → Roles.
- Click on the custom role you want to use.
- Click Copy slug from the role detail page.
- Use this slug in your login policy.
Troubleshooting
API Key authentication failures
- Verify key is active and not expired.
- Ensure key is being used with correct endpoints.
- Validate key format and encoding.
Permission denied errors
- Confirm API key has required role assignments.
- Verify role includes necessary actions for the operation.
- Check if operation is being performed in correct space.
- Ensure space exists and API key has access.
Inconsistent behavior
- API key permissions don't require re-authentication.
- Changes to role assignments take effect immediately.
- Check for policy conflicts or syntax errors.
- Validate role IDs are correct in login policies.
Debugging
- Test API key authentication: You can create an interactive session with an API key (as if it was a user) to test the key's permissions and actions. To do that, go to
<your-spacelift-subdomain>.spacelift.io/apikeytoken and enter your API key.
- Check role assignments: Confirm key has correct roles in target spaces.
- Validate actions: Ensure assigned roles include required permissions.
- Test operations: Use API key to perform expected operations.
- Review audit Logs: Check for API key related errors or warnings.
- Policy validation: If using login policies, verify syntax and logic, use the sample and simulate feature.