---
layout: docs
page_title: ACL rules
description: >-
  Roles are a named collection of ACL policies, service identities, and node identities. Learn how roles allow you to reuse and update access control policies without needing to distribute new tokens to users.
---

# ACL rules


## ACL Resource Rules

The `acl` resource controls access to ACL operations in the [ACL API](/consul/api-docs/acl). Only one `acl` rule is allowed per policy. The value is set to one of the [policy dispositions](#policy-dispositions).

The `acl = "write"` rule is also required to create snapshots. This is because all token secrets are contained within the snapshot.

Rules for ACL resources do not use labels.

In the following example, the `acl` rule is configured with `write` access to the ACL API.
The rule enables the operator to read or write ACLs, as well as discover the secret ID of any token.

<CodeTabs heading="Example acl rule">

```hcl
acl = "write"
```

```json
{
  "acl": "write"
}
```

</CodeTabs>

## Admin Partition Rules <EnterpriseAlert inline />

The `partition` and `partition_prefix` resource controls access to one or more admin partitions.
You can include any number of namespace rules inside the admin partition.

In the following example, the policy grants `write` access to the `ex-namespace`
namespace, as well as namespaces prefixed with `exns-` in the `example` partition.
The `mesh` and `peering` resources are also scoped to the admin partition rule, which grants
`write` access to the `mesh` and `peering` resources in the `example` partition.

In addition, the policy grants `read` access to the `ex-namespace` namespace, as
well as namespaces prefixed with `exns-` in all partitions containing the
`example-` prefix. Read access is granted for the `mesh` and `peering` resources
scoped within the associated partition.

<CodeTabs heading="Example admin partition rules">

```hcl
partition "example" {
  mesh = "write"
  peering = "write"

  node "my-node" {
    policy = "write"
  }

  namespace "ex-namespace" {
    policy = "write"
  }

  namespace_prefix "exns-" {
    policy = "write"
  }
}

partition_prefix "example-" {
  mesh = "read"
  peering = "read"

  node "my-node" {
    policy = "read"
  }

  namespace "ex-namespace" {
    policy = "read"
  }
}
```

```json
{
  "partition": {
    "example": {
      "mesh": "write",
      "node": {
        "my-node": {
          "policy": "write"
        }
      },
      "namespace": {
        "ex-namespace": {
          "policy": "write"
        }
      },
      "namespace_prefix": {
        "exns-": {
          "policy": "write"
        }
      }
    }
  },
  "partition_prefix": {
    "example-": {
      "mesh": "read",
      "node": {
        "my-node": {
          "policy": "read"
        }
      },
      "namespace": {
        "ex-namespace": {
          "policy": "read"
        }
      }
    }
  }
}
```

</CodeTabs>

## Agent Rules

The `agent` and `agent_prefix` resources control access to the utility operations in the [Agent API](/consul/api-docs/agent),
such as join and leave. All of the catalog-related operations are covered by the [`node` or `node_prefix`](#node-rules)
and [`service` or `service_prefix`](#service-rules) policies instead.

<CodeTabs heading="Example agent rules">

```hcl
agent "foo" {
  policy = "write"
}
agent_prefix "" {
  policy = "read"
}
agent_prefix "bar" {
  policy = "deny"
}
```

```json
{
  "agent": {
    "foo": {
      "policy": "write"
    }
  },
  "agent_prefix": {
    "": {
      "policy": "read"
    },
    "bar": {
      "policy": "deny"
    }
  }
}
```

</CodeTabs>

Agent rules are keyed by the node name they apply to. In the example above the rules
allow read-write access to the node with the _exact_ name `foo`, read-only access
to any node name by using the empty prefix, and denies all access to any node
name that starts with `bar`.

Since [Agent API](/consul/api-docs/agent) utility operations may be required before an agent is joined to
a cluster, or during an outage of the Consul servers or ACL datacenter, a special token may be
configured with [`acl.tokens.agent_recovery`](/consul/docs/reference/agent/configuration-file/acl#acl_tokens_agent_recovery) to allow
write access to these operations even if no ACL resolution capability is available.

## Event Rules

The `event` and `event_prefix` resources control access to event operations in the [Event API](/consul/api-docs/event), such as
firing events and listing events.

<CodeTabs heading="Example event rules">

```hcl
event_prefix "" {
  policy = "read"
}
event "deploy" {
  policy = "write"
}
```

```json
{
  "event_prefix": {
    "": {
      "policy": "read"
    }
  },
  "event": {
    "deploy": {
      "policy": "write"
    }
  }
}
```

</CodeTabs>

Event rules are labeled with the event name they apply to. In the example above, the rules allow
read-only access to any event, and firing of the "deploy" event.

The [`consul exec`](/consul/commands/exec) command uses events with the "\_rexec" prefix during
operation, so to enable this feature in a Consul environment with ACLs enabled, you will need to
give agents a token with access to this event prefix, in addition to configuring
[`disable_remote_exec`](/consul/docs/reference/agent/configuration-file/general#disable_remote_exec) to `false`.

## Identity Rules

Specify the resource label in identity rules to set the scope of the rule.
The resource label in the following example is empty. As a result, the rules allow read-only access to any workload identity name with the empty prefix.
The rules also allow read-write access to the `app` identity and deny all access to the `admin` identity:

<CodeTabs heading="Example identity rules">

```hcl
identity_prefix "" {
  policy = "read"
}
identity "app" {
  policy = "write"
}
identity "admin" {
  policy = "deny"
}
```

```json
{
  "identity_prefix": {
    "": {
      "policy": "read"
    }
  },
  "identity": {
    "app": {
      "policy": "write"
    },
    "admin": {
      "policy": "deny"
    }
  }
}
```

</CodeTabs>


## Key/Value Rules

The `key` and `key_prefix` resources control access to key/value store operations in the [KV API](/consul/api-docs/kv).

<CodeTabs heading="Example key rules">

```hcl
key_prefix "" {
  policy = "read"
}
key "foo" {
  policy = "write"
}
key "bar" {
  policy = "deny"
}
```

```json
{
  "key_prefix": {
    "": {
      "policy": "read"
    }
  },
  "key": {
    "foo": {
      "policy": "write"
    },
    "bar": {
      "policy": "deny"
    }
  }
}
```

</CodeTabs>

Key rules are labeled with the key name they apply to. In the example above, the rules allow read-only access
to any key name with the empty prefix rule, allow read-write access to the "foo" key, and deny access to the "bar" key.

### List Policy for Keys

Enable the `list` policy disposition (Consul 1.0+) by setting the
`acl.enable_key_list_policy` parameter to `true`. The disposition provides
recursive access to `key` entries. Refer to the [KV API](/consul/api-docs/kv#recurse)
documentation for additional information.

In the following example, `key` resources that start with `bar` may be listed.

<CodeTabs heading="Example 'key' rules">

```hcl
key_prefix "" {
 policy = "deny"
}

key_prefix "bar" {
 policy = "list"
}

key_prefix "baz" {
 policy = "read"
}
```

```json
{
  "key_prefix": {
    "": {
      "policy": "deny"
    },
    "bar": {
      "policy": "list"
    },
    "baz": {
      "policy": "read"
    }
  }
}
```

</CodeTabs>

In the example above, the rules allow reading the key "baz", and only allow recursive reads on the prefix "bar".

A token with `write` access on a prefix also has `list` access. A token with `list` access on a prefix also has `read` access on all its suffixes.

#### Sentinel Integration <EnterpriseAlert inline />

Consul Enterprise supports additional optional fields for key write policies for
[Sentinel](https://docs.hashicorp.com/sentinel/consul) integration.

```hcl
key "foo" {
  policy = "write"
  sentinel {
      code = <<EOF
import "strings"
main = rule { strings.has_suffix(value, "bar") }
EOF
      enforcementlevel = "hard-mandatory"
  }
}
```

For more detailed information, refer to  the [Consul Sentinel documentation](/consul/docs/secure/acl/sentinel).

## Keyring Rules

The `keyring` resource controls access to keyring operations in the [Keyring API](/consul/api-docs/operator/keyring). Only one keyring policy is allowed per rule set. The value is set to one of the policy dispositions, but may be read and updated.

<CodeTabs heading="Example keyring rule">

```hcl
keyring = "write"
```

```json
{
  "keyring": "write"
}
```

</CodeTabs>

## Mesh Rules

The `mesh` resource controls access to ingress gateways, terminating gateways, and mesh configuration entries.

In Consul Enterprise, mesh rules are scoped to an admin partition. Therefore, they can be nested in an
[admin partition rule](#admin-partition-rules) but not a [namespace rule](#namespace-rules).

The following rule grants read and write access:

<CodeTabs heading="Example mesh rule">

```hcl
mesh = "write"
```

```json
{
  "mesh": "write"
}
```

</CodeTabs>

Refer to  [Admin Partition Rules](#admin-partition-rules) for another example rule that uses the `mesh` resource.

## Namespace Rules <EnterpriseAlert inline />

The `namespace` and `namespace_prefix` resource controls access to Consul namespaces. Namespaces define a scope of resources for which ACL rules apply. ACL rules, themselves, can then be defined to only to apply to specific namespaces.

<Note title="Consul 1.7.0 and later">

The ability to add many types of resources to separate namespaces was added to [Consul Enterprise](https://www.hashicorp.com/consul) 1.7.0.

</Note>

The following examples describe how namespace rules can be defined in a policy:

<CodeTabs heading="Example namespace rules">

```hcl
namespace_prefix "" {
  # grants permission to create and edit all namespaces
  policy = "write"

  # grant service:read for all services in all namespaces
  service_prefix "" {
    policy = "read"
  }

  # grant node:read for all nodes in all namespaces
  node_prefix "" {
    policy = "read"
  }
}

namespace "foo" {
  # grants permission to manage ACLs only for the foo namespace
  acl = "write"

  # grants permission to create and edit the foo namespace
  policy = "write"

  # grants write permissions to the KV for namespace foo
  key_prefix "" {
    policy = "write"
  }

  # grants write permissions for sessions for namespace foo
  session_prefix "" {
    policy = "write"
  }

  # grants service:write for all services in the foo namespace
  service_prefix "" {
    policy = "write"
  }

  # grants node:read for all nodes
  node_prefix "" {
    policy = "read"
  }
}
```

```json
{
  "namespace_prefix": {
    "": {
      "policy": "write",
      "service_prefix": {
        "": {
          "policy": "read"
        }
      },
      "node_prefix": {
        "": {
          "policy": "read"
        }
      }
    }
  },
  "namespace": {
    "foo": {
      "acl": "write",
      "policy": "write",
      "key_prefix": {
        "": {
          "policy": "write"
        }
      },
      "session_prefix": {
        "": {
          "policy": "write"
        }
      },
      "service_prefix": {
        "": {
          "policy": "write"
        }
      },
      "node_prefix": {
        "": {
          "policy": "read"
        }
      }
    }
  }
}
```

</CodeTabs>

### Restrictions

The following restrictions apply when a rule is defined in any user-created namespace:

1. `operator` rules are not allowed.
2. `event` rules are not allowed.
3. `keyring` rules are not allowed.
4. `query` rules are not allowed.
5. `node` rules that attempt to grant `write` privileges are not allowed.

These restrictions do not apply to the `default` namespace created by Consul. In general all of the
above are permissions that only an operator should have and thus granting these permissions can
only be done within the default namespace.

### Implicit Namespacing

Rules and policies created within a namespace will inherit the namespace configuration.
This means that rules and policies will be implicitly namespaced and do not need additional configuration.
The restrictions outlined above will apply to these rules and policies. Additionally, rules and policies within a
specific namespace are prevented from accessing resources in another namespace.

## Node Rules

The `node` and `node_prefix` resources control access to the following API behaviors:

- node-level registration and read access to the [Catalog API](/consul/api-docs/catalog)
- service discovery with the [Health API](/consul/api-docs/health)
- filtering results in [Agent API](/consul/api-docs/agent) operations, such as fetching the list of cluster members.

You can use resource labels to scope the rule to a specific resource or set of resources.

The following example rule uses an empty prefix label, which provides read-only access to all nodes.
The rule also provides read-write access to the `app` node and denies all access to the `admin` node:

<CodeTabs heading="Example node rules">

```hcl
node_prefix "" {
  policy = "read"
}
node "app" {
  policy = "write"
}
node "admin" {
  policy = "deny"
}
```

```json
{
  "node_prefix": {
    "": {
      "policy": "read"
    }
  },
  "node": {
    "app": {
      "policy": "write"
    },
    "admin": {
      "policy": "deny"
    }
  }
}
```

</CodeTabs>

### Registering and Querying Node Information

Agents must be configured with `write` privileges for their own node name so that the agent can register their node metadata, tagged addresses, and other information in the catalog.
If configured incorrectly, the agent will print an error to the console when it tries to sync its state with the catalog.
Configure `write` access in the [`acl.tokens.agent`](/consul/docs/reference/agent/configuration-file/acl#acl_tokens_agent) parameter.

The [`acl.token.default`](/consul/docs/reference/agent/configuration-file/acl#acl_tokens_default) used by the agent should have `read` access to a given node so that the DNS interface can be queried.

Node rules are used to filter query results when reading from the catalog or retrieving information from the health endpoints. This allows for configurations where a token has access to a given service name, but only on an allowed subset of node names.

Consul agents check tokens locally when health checks are registered and when Consul performs periodic [anti-entropy](/consul/docs/concept/consistency) syncs.
These actions may required an ACL token to complete. Use the following methods to configure ACL tokens for registration events:

* Configure a global token in the [acl.tokens.default](/consul/docs/reference/agent/configuration-file/acl#acl_tokens_default) parameter.
  This allows a single token to be used during all check registration operations.
* Provide an ACL token with `service` and `check` definitions at registration time.
  This allows for greater flexibility and enables the use of multiple tokens on the same agent.
  Refer to the [services](/consul/docs/register/service/vm/define) and [checks](/consul/docs/register/health-check/vm) documentation for examples. You can also pass tokens to the [HTTP API](/consul/api-docs) for operations that require them.

### Reading Imported Nodes

Nodes rules affect read access to nodes with services exported by [`exported-services` configuration entries](/consul/docs/reference/config-entry/exported-services#reading-services), including nodes imported from [cluster peerings](/consul/docs/east-west/cluster-peering) or [admin partitions](/consul/docs/multi-tenant/admin-partition) (Enterprise-only).
Read access to all imported nodes is granted when either of the following rule sets are attached to a token:
- `service:write` is granted to any service.
- `node:read` is granted to all nodes.

For Consul Enterprise, either set of rules must be scoped to the requesting services's partition and at least one namespace.

You may need similarly scoped [Service Rules](#reading-imported-services) to read Consul data, depending on the endpoint (e.g. `/v1/health/service/:name`).
These permissions are satisfied when using a [service identity](/consul/docs/reference/acl/rule#service-identities).

Refer to [Reading Services](/consul/docs/reference/config-entry/exported-services#reading-services) for example ACL policies used to read imported services using the health endpoint.

## Operator Rules

The `operator` resource controls access to cluster-level operations in the
[Operator API](/consul/api-docs/operator), other than the [Keyring API](/consul/api-docs/operator/keyring).

Only one operator rule allowed per rule set. In the following example, the token may be used to query the operator endpoints for
diagnostic purposes but it will not make changes.

<CodeTabs heading="Example operator rule">

```hcl
operator = "read"
```

```json
{
  "operator": "read"
}
```

</CodeTabs>

## Peering Rules
The `peering` resource controls access to cluster peerings in the [Cluster Peering API](/consul/api-docs/peering).

In Consul Enterprise, peering rules are scoped to an admin partition. Therefore, they can be nested in an
[admin partition rule](#admin-partition-rules) but not a [namespace rule](#namespace-rules).

The following rule grants read and write access:

<CodeTabs heading="Example peering rule">

```hcl
peering = "write"
```

```json
{
  "peering": "write"
}
```

</CodeTabs>

For an example of how to apply rules for the `peering` resource alongside other rules, refer to the example configuration in [Admin Partition Rules](#admin-partition-rules).

## Prepared Query Rules

The `query` and `query_prefix` resources control access to create, update, and delete prepared queries in the
[Prepared Query API](/consul/api-docs/query). Specify the resource label in query rules to determine the scope of the rule.
The resource label in the following example is empty. As a result, the rules allow read-only access to query resources with any name.
The rules also grant read-write access to the query named `foo`, which allows control of the query namespace to be delegated based on ACLs:

<CodeTabs heading="Example query rules">

```hcl
query_prefix "" {
  policy = "read"
}
query "foo" {
  policy = "write"
}
```

```json
{
  "query_prefix": {
    "": {
      "policy": "read"
    }
  },
  "query": {
    "foo": {
      "policy": "write"
    }
  }
}
```

</CodeTabs>

Executing queries is subject to `node`/`node_prefix` and `service`/`service_prefix`
policies.

There are a few variations when using ACLs with prepared queries, each of which uses ACLs in one of two
ways: open, protected by unguessable IDs or closed, managed by ACL policies. These variations are covered
here, with examples:

- Static queries with no `Name` defined are not controlled by any ACL policies.
  These types of queries are meant to be ephemeral and not shared to untrusted
  clients, and they are only reachable if the prepared query ID is known. Since
  these IDs are generated using the same random ID scheme as ACL Tokens, it is
  infeasible to guess them. When listing all prepared queries, only a management
  token will be able to refer to  these types, though clients can read instances for
  which they have an ID. An example use for this type is a query built by a
  startup script, tied to a session, and written to a configuration file for a
  process to use via DNS.

- Static queries with a `Name` defined are controlled by the `query` and `query_prefix`
  ACL resources. Clients are required to have an ACL token with permissions on to
  access that query name. Clients can list or read queries for
  which they have "read" access based on their prefix, and similar they can
  update any queries for which they have "write" access. An example use for
  this type is a query with a well-known name (eg. `prod-primary-customer-db`)
  that is used and known by many clients to provide geo-failover behavior for
  a database.

- [Template queries](/consul/api-docs/query#prepared-query-templates)
  queries work like static queries with a `Name` defined, except that a catch-all
  template with an empty `Name` requires an ACL token that can write to any query
  prefix.

When prepared queries are executed via DNS lookups or HTTP requests, the ACL
checks are run against the service being queried, similar to how ACLs work with
other service lookups. There are several ways the ACL token is selected for this
check:

- If an ACL Token was captured when the prepared query was defined, it will be
  used to perform the service lookup. This allows queries to be executed by
  clients with lesser or even no ACL Token, so this should be used with care.

- If no ACL Token was captured, then the client's ACL Token will be used to
  perform the service lookup.

- If no ACL Token was captured and the client has no ACL Token, then the
  anonymous token will be used to perform the service lookup.

In the common case, the ACL Token of the invoker is used
to test the ability to look up a service. If a `Token` was specified when the
prepared query was created, the behavior changes and now the captured
ACL Token set by the definer of the query is used when looking up a service.

Capturing ACL Tokens is analogous to
[PostgreSQL's](http://www.postgresql.org/docs/current/static/sql-createfunction.html)
`SECURITY DEFINER` attribute which can be set on functions, and using the client's ACL
Token is similar to the complementary `SECURITY INVOKER` attribute.

Prepared queries were originally introduced in Consul 0.6.0. The ACL behavior remained
unchanged through version 0.6.3, but versions after 0.6.3 included changes that improve management of the
prepared query namespace.

These differences are outlined in the table below:

| Operation                          | Version <= 0.6.3                                                                                                                                                                                 | Version > 0.6.3                                                                                                                                                                                                                     |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Create static query without `Name` | The ACL Token used to create the prepared query is checked to make sure it can access the service being queried. This token is captured as the `Token` to use when executing the prepared query. | No ACL policies are used as long as no `Name` is defined. No `Token` is captured by default unless specifically supplied by the client when creating the query.                                                                     |
| Create static query with `Name`    | The ACL Token used to create the prepared query is checked to make sure it can access the service being queried. This token is captured as the `Token` to use when executing the prepared query. | The client token's `query` ACL policy is used to determine if the client is allowed to register a query for the given `Name`. No `Token` is captured by default unless specifically supplied by the client when creating the query. |
| Manage static query without `Name` | The ACL Token used to create the query or a token with management privileges must be supplied in order to perform these operations.                                                              | Any client with the ID of the query can perform these operations.                                                                                                                                                                   |
| Manage static query with a `Name`  | The ACL token used to create the query or a token with management privileges must be supplied in order to perform these operations.                                                              | Similar to create, the client token's `query` ACL policy is used to determine if these operations are allowed.                                                                                                                      |
| List queries                       | A token with management privileges is required to list any queries.                                                                                                                              | The client token's `query` ACL policy is used to determine which queries they can refer to . Only tokens with management privileges can refer to  prepared queries without `Name`.                                                              |
| Execute query                      | Since a `Token` is always captured when a query is created, that is used to check access to the service being queried. Any token supplied by the client is ignored.                              | The captured token, client's token, or anonymous token is used to filter the results, as described above.                                                                                                                           |

## Service Rules

The `service` and `service_prefix` resources control service-level registration and read access to the [Catalog API](/consul/api-docs/catalog) and service discovery with the [Health API](/consul/api-docs/health).
Specify the resource label in service rules to set the scope of the rule.
The resource label in the following example is empty. As a result, the rules allow read-only access to any service name with the empty prefix.
The rules also allow read-write access to the `app` service and deny all access to the `admin` service:

<CodeTabs heading="Example service rules">

```hcl
service_prefix "" {
  policy = "read"
}
service "app" {
  policy = "write"
}
service "admin" {
  policy = "deny"
}
```

```json
{
  "service_prefix": {
    "": {
      "policy": "read"
    }
  },
  "service": {
    "app": {
      "policy": "write"
    },
    "admin": {
      "policy": "deny"
    }
  }
}
```

</CodeTabs>

Consul's DNS interface is affected by restrictions on service rules. If the
[`acl.tokens.default`](/consul/docs/reference/agent/configuration-file/acl#acl_tokens_default) used by the agent does not have `read` access to a
given service, then the DNS interface will return no records when queried for it.

When reading from the catalog or retrieving information from the health endpoints, service rules are
used to filter the results of the query.

Service rules come into play when using the [Agent API](/consul/api-docs/agent) to register services or
checks. The agent will check tokens locally as a service or check is registered, and Consul also
performs periodic [anti-entropy](/consul/docs/concept/consistency) syncs, which may require an
ACL token to complete. To accommodate this, Consul provides two methods of configuring ACL tokens
to use for registration events:

1. Using the [acl.tokens.default](/consul/docs/reference/agent/configuration-file/acl#acl_tokens_default) configuration
   directive. This allows a single token to be configured globally and used
   during all service and check registration operations.
2. Providing an ACL token with service and check definitions at registration
   time. This allows for greater flexibility and enables the use of multiple
   tokens on the same agent. Examples of what this looks like are available for
   both [services](/consul/docs/register/service/vm/define) and
   [checks](/consul/docs/register/health-check/vm). Tokens may also be passed to the [HTTP
   API](/consul/api-docs) for operations that require them. Note that all tokens
   passed to an agent are persisted on local disk to allow recovery from
   restarts. Refer to [`-data-dir` flag
   documentation](/consul/docs/architecture/backend) for information about securing
   access.

In addition to ACLs, in Consul 0.9.0 and later, the agent must be configured with
[`enable_script_checks`](/consul/docs/reference/agent/configuration-file/general#enable_script_checks) or
[`enable_local_script_checks`](/consul/docs/reference/agent/configuration-file/general#enable_local_script_checks)
set to `true` in order to enable script checks.

### Reading Imported Services

Service rules affect read access to services exported by [`exported-services` configuration entries](/consul/docs/reference/config-entry/exported-services#reading-services), including services exported between [cluster peerings](/consul/docs/east-west/cluster-peering) or [admin partitions](/consul/docs/multi-tenant/admin-partition) (Enterprise-only).
Read access to all imported services is granted when either of the following rule sets are attached to a token:
- `service:write` is granted to any service.
- `service:read` is granted to all services.

For Consul Enterprise, either set of rules must be scoped to the requesting services's partition and at least one namespace.

You may need similarly scoped [Node Rules](#reading-imported-nodes) to read Consul data, depending on the endpoint (e.g. `/v1/health/service/:name`).
These permissions are satisfied when using a [service identity](/consul/docs/reference/acl/rule#service-identities).

Refer to [Reading Services](/consul/docs/reference/config-entry/exported-services#reading-services) for example ACL policies used to read imported services using the health endpoint.

### Intentions

Service rules are also used to grant read or write access to intentions. The
following policy provides read-write access to the "app" service, and explicitly
grants `intentions:read` access to view intentions associated with the "app" service.

<CodeTabs heading="Example service rule with intentions">

```hcl
service "app" {
  policy = "write"
  intentions = "read"
}
```

```json
{
  "service": {
    "app": {
      "policy": "write",
      "intentions": "read"
    }
  }
}
```

</CodeTabs>

Refer to [ACL requirements for intentions](/consul/docs/secure-mesh/intention/create#acl-requirements)
for more information about managing intentions access with service rules.

## Session Rules

The `session` and `session_prefix` resources controls access to [Session API](/consul/api-docs/session) operations.

Specify the resource label in session rules to set the scope of the rule.
The resource label in the following example is empty. As a result, the rules allow read-only access to all sessions.
The rules also allow creating sessions on the node named `app` and deny all access to any sessions on the `admin` node:

<CodeTabs heading="Example session rules">

```hcl
session_prefix "" {
  policy = "read"
}
session "app" {
  policy = "write"
}
session "admin" {
  policy = "deny"
}
```

```json
{
  "session_prefix": {
    "": {
      "policy": "read"
    }
  },
  "session": {
    "app": {
      "policy": "write"
    },
    "admin": {
      "policy": "deny"
    }
  }
}
```

</CodeTabs>
