ACL Templated Policy HTTP API
The /acl/templated-policy
endpoints read,
preview, and list ACL templated policies in Consul.
For more information on how to setup ACLs, refer to the following resources:
Read a templated policy by name
This endpoint reads an ACL policy with the given ID.
Method | Path | Produces |
---|---|---|
GET | /acl/templated-policy/name/:name | application/json |
The following table shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
NO | none | none | acl:read |
The corresponding CLI command is consul acl templated-policy read -name=<string>
.
Path parameters
name
(string: <required>)
- Specifies the name of the ACL policy to read.
Sample request
Sample response
Preview a templated policy
The preview
endpoint shows the policy created from a templated policy. The endpoint helps you understand what templated variables are required or are missing from your request.
Method | Path | Produces |
---|---|---|
POST | /acl/templated-policy/preview/:name | application/json |
The following table shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
NO | none | none | acl:read |
The corresponding CLI command is consul acl templated-policy preview
.
Path parameters
name
(string: <required>)
- Specifies the name of the ACL templated policy to preview.
Query parameters
ns
(string: "")
Enterprise - Specifies the namespace that the policy created from the template applies to. You can also specify the namespace through other methods.
JSON request body schema
Name
(string: <optional>)
- Specifies the value of thename
variable in the templated policy variables.
Partition
(string: "")
- Enterprise The partition to use. If not provided, the partition is inferred from the request's ACL token, or defaults to thedefault
partition.
Sample payload
Sample request
Sample response
List templated policies
Call the templated-policies
endpoint with a GET
method to list all templated ACL policies.
Method | Path | Produces |
---|---|---|
GET | /acl/templated-policies | application/json |
The following table shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
No | none | none | acl:read |
The corresponding CLI command is consul acl templated-policy list
.
Query parameters
This endpoint does not accept query parameters.
Sample Request
Sample response
Methods to specify namespace Enterprise
You can employ several methods to specify the namespace in calls to templated ACL policy endpoints. Consul applies the following order of precedence to determine the namespace:
Namespace
field of the JSON request body. This method only applies to create and update endpointsns
query parameter.X-Consul-Namespace
request header.- Namespace inherited from the namespace of the request's ACL token.
- The
default
namespace.