---
title: Command Restriction
description: Set limitations on who can execute specific Mergify commands.
---

In some scenarios, you might want to restrict who can use Mergify commands to
ensure they're executed only by authorized individuals. The command
restrictions feature allows you to define a set of users or teams who are
permitted to use specific Mergify commands.

## How Restrictions Work

With command restrictions, you can use
[conditions](/configuration/conditions) to define the valid context that is
authorized to run a specific command. This could be a list of allowed users or
teams, or even attributes related to the pull request itself.

The restrictions are configured with the top-level key `commands_restrictions`
which can specify restrictions for each command.

### Examples

To limit backport commands for pull requests coming from the `main` branch:

```yaml
commands_restrictions:
  backport:
    conditions:
      - base = main
```

To limit backport commands usage to a specific team (or user):

```yaml
commands_restrictions:
  backport:
    conditions:
      - sender = @team
```

To limit backport commands for users with a specific permission on the
repository:

```yaml
commands_restrictions:
  backport:
    conditions:
      - sender-permission >= write
```

## Default Restrictions

| Key name | Value type | Default | Description |
| --- | --- | --- | --- |
| `backport` | Command Restrictions | `{"conditions":["sender-permission >= write"]}` |  |
| `copy` | Command Restrictions | `{"conditions":["sender-permission >= write"]}` |  |
| `dequeue` | Command Restrictions | `{"conditions":["sender-permission >= write"]}` |  |
| `queue` | Command Restrictions | `{"conditions":["sender-permission >= write"]}` |  |
| `rebase` | Command Restrictions | `{"conditions":[{"or":["sender-permission >= write","sender = {{author}}"]}]}` |  |
| `refresh` | Command Restrictions | `{"conditions":[{"or":["sender-permission >= write","sender = {{author}}"]}]}` |  |
| `requeue` | Command Restrictions | `{"conditions":["sender-permission >= write"]}` |  |
| `squash` | Command Restrictions | `{"conditions":[{"or":["sender-permission >= write","sender = {{author}}"]}]}` |  |
| `update` | Command Restrictions | `{"conditions":[{"or":["sender-permission >= write","sender = {{author}}"]}]}` |  |

### Command Restriction Format

| Key name | Value type | Description |
| --- | --- | --- |
| `conditions` | List of conditions |  |
