> ## Documentation Index
> Fetch the complete documentation index at: https://docs.forest.app/llms.txt
> Use this file to discover all available pages before exploring further.

# forest roles:apply

> Update role permissions on an environment from a CSV file

# forest roles:apply

Apply a wide-format CSV of role permissions, as produced by [`forest roles:export`](https://docs.forest.app/reference/cli/roles-export), to an environment. The CLI compares the file with the current permissions, prints the number of changes per role, and applies them once you confirm.

## Usage

```bash theme={null}
forest roles:apply <FILE> --env <ENVIRONMENT> [options]
```

## Arguments

| Argument | Description |
| - | - |
| `FILE` | Path to the CSV file (required) |

## Options

| Option | Description |
| - | - |
| `-e, --env` | Name of the environment to apply to (required) |
| `-F, --force` | Apply without asking for confirmation |
| `-p, --projectId` | The ID of the project to work on |

## Behavior

* Each row updates the role named in its `role` column. Roles absent from the file keep their permissions.
* `roles:apply` updates existing roles only. If a row names a role that does not exist, the command stops before changing anything: create the role first with [`forest roles:create`](https://docs.forest.app/reference/cli/roles-create).
* Only the columns present in the file are applied: removing a column leaves that permission unchanged, it does not revoke it.
* Cells must be `true` or `false`. The `hasConditions` columns are read-only and ignored.
* Permissions are matched by collection and action name, so a file exported from one environment applies to another environment whose schema differs.
* Running the same file again makes no change. If the command fails halfway, run it again to finish.

## Example

```bash theme={null}
# Export, edit, then apply to the same environment
forest roles:export --env Production --output roles.csv
# ... edit roles.csv ...
forest roles:apply roles.csv --env Production

# Reuse production permissions on a new environment
forest roles:export -e Production -o roles.csv
forest roles:apply roles.csv -e staging --force
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.