# dokploy_user_permissions (Resource)

The permissions of one member of the active organization: what a user with the `member` role can see and do. An admin or the owner has every permission, and Dokploy ignores these flags for them.

~> **Destroying this resource resets every permission to the Dokploy default: no access.** The user account stays.

~> The API key's user must be the owner of the organization; Dokploy refuses the call otherwise.

## Example Usage

```terraform
# Permissions of a member that was invited in the Dokploy UI. The lookup by
# email gives the user id.
data "dokploy_user" "contractor" {
  email = "contractor@example.com"
}

resource "dokploy_user_permissions" "contractor" {
  user_id = data.dokploy_user.contractor.id

  accessed_projects     = [dokploy_project.app.id]
  accessed_environments = [dokploy_environment.staging.id]

  can_create_services = true
  can_delete_services = false
  can_access_docker   = true
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `user_id` (String) Id of the user: `dokploy_user.id`, or the `id` of the `dokploy_user` data source for a user that was invited in the UI.

### Optional

- `accessed_environments` (Set of String) Ids of the environments that the user can open. Defaults to an empty set.
- `accessed_git_providers` (Set of String) Ids of the git providers that the user can use. Defaults to an empty set.
- `accessed_projects` (Set of String) Ids of the projects that the user can open. Defaults to an empty set.
- `accessed_servers` (Set of String) Ids of the remote servers that the user can use. Defaults to an empty set.
- `accessed_services` (Set of String) Ids of the services (applications, composes, databases) that the user can open. Defaults to an empty set.
- `can_access_api` (Boolean) Let the user generate API keys and read the API docs. Defaults to `false`.
- `can_access_docker` (Boolean) Let the user open the Docker container views. Defaults to `false`.
- `can_access_git_providers` (Boolean) Let the user manage git providers. Defaults to `false`.
- `can_access_ssh_keys` (Boolean) Let the user manage SSH keys. Defaults to `false`.
- `can_access_traefik_files` (Boolean) Let the user edit the Traefik configuration files. Defaults to `false`.
- `can_create_environments` (Boolean) Let the user create environments. Defaults to `false`.
- `can_create_projects` (Boolean) Let the user create projects. Defaults to `false`.
- `can_create_services` (Boolean) Let the user create services. Defaults to `false`.
- `can_delete_environments` (Boolean) Let the user delete environments. Defaults to `false`.
- `can_delete_projects` (Boolean) Let the user delete projects. Defaults to `false`.
- `can_delete_services` (Boolean) Let the user delete services. Defaults to `false`.

### Read-Only

- `id` (String) Same as `user_id`.
- `member_id` (String) Id of the membership record.

## Import

Import is supported using the following syntax:

The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:

```shell
# Import by the user id.
terraform import dokploy_user_permissions.contractor rM64isnUKMgqgOnwm7zE3
```