ACL Token HTTP API
The /acl/token
endpoints create, read,
update, list, clone and delete ACL tokens in Consul.
For more information on how to setup ACLs, refer to the following resources:
Create a Token
This endpoint creates a new ACL token.
Method | Path | Produces |
---|---|---|
PUT | /acl/token | application/json |
The table below 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:write |
The corresponding CLI command is consul acl token create
.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the token you create. You can also specify the namespace through other methods.
JSON Request Body Schema
AccessorID
(string: "")
- Specifies a UUID to use as the token's Accessor ID. If not specified a UUID will be generated for this field. Added in v1.5.0.SecretID
(string: "")
- Specifies a UUID to use as the token's Secret ID. If not specified a UUID will be generated for this field. Added in v1.5.0. Note: The SecretID is used to authorize operations against Consul and should be generated from an appropriate cryptographic source.Description
(string: "")
- Free form human readable description of the token.Policies
(array<PolicyLink>)
- The list of policies that should be applied to the token. A PolicyLink is an object with an "ID" and/or "Name" field to specify a policy. With the PolicyLink, tokens can be linked to policies either by the policy name or by the policy ID. When policies are linked by name they will be internally resolved to the policy ID. With linking tokens internally by IDs, Consul enables policy renaming without breaking tokens.Roles
(array<RoleLink>)
- The list of roles that should be applied to the token. A RoleLink is an object with an "ID" and/or "Name" field to specify a role. With the RoleLink, tokens can be linked to roles either by the role name or by the role ID. When roles are linked by name they will be internally resolved to the role ID. With linking tokens internally by IDs, Consul enables role renaming without breaking tokens. Added in Consul 1.5.0.TemplatedPolicies
(list of maps)
- The list of templated policies that should be applied to the role.TemplateName
(string: <required>)
- The templated policy name.TemplateVariables
(map of strings|maps: <optional>)
- The templated policy variables. Not all templated policies require variables.
ServiceIdentities
(array<ServiceIdentity>)
- The list of service identities that should be applied to the token. Added in Consul 1.5.0.ServiceName
(string: <required>)
- The name of the service. The name must be no longer than 256 characters, must start and end with a lowercase alphanumeric character, and can only contain lowercase alphanumeric characters as well as-
and_
.Datacenters
(array<string>)
- Specifies the datacenters the effective policy is valid within. When no datacenters are provided the effective policy is valid in all datacenters including those which do not yet exist but may in the future.
NodeIdentities
(array<NodeIdentity>)
- The list of node identities that should be applied to the token. Added in Consul 1.8.1.NodeName
(string: <required>)
- The name of the node. The name must be no longer than 256 characters, must start and end with a lowercase alphanumeric character, and can only contain lowercase alphanumeric characters as well as-
and_
.Datacenter
(string: <required>)
- Specifies the nodes datacenter. This will result in effective policy only being valid in that datacenter.
Local
(bool: false)
- If true, indicates that the token should not be replicated globally and instead be local to the current datacenter.ExpirationTime
(time: "")
- If set this represents the point after which a token should be considered revoked and is eligible for destruction. The default unset value represents NO expiration. This value must be between 1 minute and 24 hours in the future. Added in Consul 1.5.0.ExpirationTTL
(duration: 0s)
- This is a convenience field and if set will initialize theExpirationTime
field to a value ofCreateTime + ExpirationTTL
. This field is not persisted beyond its initial use. Can be specified in the form of"60s"
or"5m"
(i.e., 60 seconds or 5 minutes, respectively). This value must be no smaller than 1 minute and no longer than 24 hours. Added in Consul 1.5.0.Namespace
(string: "")
Enterprise - Specifies the namespace of the token you create. This field takes precedence over thens
query parameter, one of several other methods to specify the namespace.
Partition
(string: "")
- Enterprise The admin 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
Read a Token
This endpoint reads an ACL token with the given Accessor ID.
Method | Path | Produces |
---|---|---|
GET | /acl/token/:AccessorID | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
YES | all | none | acl:read |
The corresponding CLI command is consul acl token read
.
Path Parameters
AccessorID
(string: <required>)
- Specifies the accessor ID of the token you lookup.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the token you lookup. You can also specify the namespace through other methods.expanded
(bool: false)
- If this field is set, the contents of all policies and roles affecting the token will also be returned.
partition
(string: "")
Enterprise - The admin partition to use. If not provided, the partition is inferred from the request's ACL token, or defaults to thedefault
partition.
Sample Request
Sample Response
Note If the token used for accessing the API has acl:write
permissions,
then the SecretID
will contain the tokens real value. Only when accessed with
a token with only acl:read
permissions will the SecretID
be redacted. This
is to prevent privilege escalation whereby having acl:read
privileges allows
for reading other secrets which given even more permissions.
Sample response when setting the expanded
parameter:
Read Self Token
This endpoint returns the ACL token details that matches the secret ID
specified with the X-Consul-Token
header or the token
query parameter.
Method | Path | Produces |
---|---|---|
GET | /acl/token/self | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
YES | all | none | none |
Note - This endpoint requires no specific privileges as it is just retrieving the data for a token that you must already possess its secret.
The corresponding CLI command is consul acl token read -self
.
Sample Request
Sample Response
Update a Token
This endpoint updates an existing ACL token.
Method | Path | Produces |
---|---|---|
PUT | /acl/token/:AccessorID | application/json |
The table below 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:write |
The corresponding CLI command is consul acl token update
.
Path Parameters
AccessorID
(string: <required>)
- Specifies the accessor ID of the token you update.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the token you update. You can also specify the namespace through other methods.
JSON Request Body Schema
AccessorID
(string: "")
- Specifies the accessor ID of the token being updated. This field is required in the URL path but may also be specified in the JSON body. If specified in both places then they must be an exact match. This field is immutable. If not present in the body and only in the URL then it will be filled in by Consul.SecretID
(string: "")
- Specifies the secret ID of the token being updated. This field is immutable so if present in the body then it must match the existing value. If not present then the value will be filled in by Consul.Description
(string: "")
- Free form human readable description of this token.Policies
(array<PolicyLink>)
- This is the list of policies that should be applied to this token. A PolicyLink is an object with an "ID" and/or "Name" field to specify a policy. With the PolicyLink tokens can be linked to policies either by the policy name or by the policy ID. When policies are linked by name they will internally be resolved to the policy ID. With linking tokens internally by IDs, Consul enables policy renaming without breaking tokens.Roles
(array<RoleLink>)
- The list of roles that should be applied to the token. A RoleLink is an object with an "ID" and/or "Name" field to specify a role. With the RoleLink, tokens can be linked to roles either by the role name or by the role ID. When roles are linked by name they will be internally resolved to the role ID. With linking tokens internally by IDs, Consul enables role renaming without breaking tokens.ServiceIdentities
(array<ServiceIdentity>)
- The list of service identities that should be applied to the token. Added in Consul 1.5.0.ServiceName
(string: <required>)
- The name of the service. The name must be no longer than 256 characters, must start and end with a lowercase alphanumeric character, and can only contain lowercase alphanumeric characters as well as-
and_
.Datacenters
(array<string>)
- Specifies the datacenters the effective policy is valid within. When no datacenters are provided the effective policy is valid in all datacenters including those which do not yet exist but may in the future.
NodeIdentities
(array<NodeIdentity>)
- The list of node identities that should be applied to the token. Added in Consul 1.8.1.NodeName
(string: <required>)
- The name of the node. The name must be no longer than 256 characters, must start and end with a lowercase alphanumeric character, and can only contain lowercase alphanumeric characters as well as-
and_
.Datacenter
(string: <required>)
- Specifies the nodes datacenter. This will result in effective policy only being valid in that datacenter.
Local
(bool: false)
- If true, indicates that this token should not be replicated globally and instead be local to the current datacenter. This value must match the existing value or the request will return an error.AuthMethod
(string: "")
- Specifies the name of the auth method that created this token. This field is immutable so if present in the body then it must match the existing value. If not present then the value will be filled in by Consul.ExpirationTime
(time: "")
- Specifies the expiration time for the token being updated. This field is immutable so if present in the body then it must match the existing value. If not present then the value will be filled in by Consul.Namespace
(string: "")
Enterprise - Specifies the namespace of the token you update. This field takes precedence over thens
query parameter, one of several other methods to specify the namespace.
Partition
(string: "")
- Enterprise The admin 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
Clone a Token
This endpoint clones an existing ACL token.
Method | Path | Produces |
---|---|---|
PUT | /acl/token/:AccessorID/clone | application/json |
The table below 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:write |
The corresponding CLI command is consul acl token clone
.
Path Parameters
AccessorID
(string: <required>)
- The accessor ID of the token to clone.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the token you clone. You can also specify the namespace through other methods.
JSON Request Body Schema
Description
(string: "")
- Free form human readable description for the cloned token.Namespace
(string: "")
Enterprise - Specifies the namespace of the token you clone. This field takes precedence over thens
query parameter, one of several other methods to specify the namespace.
Partition
(string: "")
- Enterprise The admin 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
Delete a Token
This endpoint deletes an ACL token.
Method | Path | Produces |
---|---|---|
DELETE | /acl/token/:AccessorID | application/json |
Even though the return type is application/json, the value is either true or false, indicating whether the delete succeeded.
The table below 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:write |
The corresponding CLI command is consul acl token delete
.
Path Parameters
AccessorID
(string: <required>)
- Specifies the accessor ID of the ACL token to delete.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the token you delete. You can also specify the namespace through other methods.
partition
(string: "")
Enterprise - The admin partition to use. If not provided, the partition is inferred from the request's ACL token, or defaults to thedefault
partition.
Sample Request
Sample Response
List Tokens
This endpoint lists all the ACL tokens.
Method | Path | Produces |
---|---|---|
GET | /acl/tokens | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
YES | all | none | acl:read |
The corresponding CLI command is consul acl token list
.
Query Parameters
policy
(string: "")
- Filters the token list to those tokens that are linked with this specific policy ID.role
(string: "")
- Filters the token list to those tokens that are linked with this specific role ID.servicename
(string: "")
- Filters the token list to those tokens that are linked with this specific service name in their service identity.authmethod
(string: "")
- Filters the token list to those tokens that are linked with this specific named auth method.authmethod-ns
(string: "")
Enterprise - Specifies the namespace of theauthmethod
used for token lookup. If not provided, the namespace provided by thens
parameter or through other methods will be used.ns
(string: "")
Enterprise - Return only the tokens in the specified namespace. The namespace may be specified as '*' to return results for all namespaces. You can also specify the namespace through other methods.
partition
(string: "")
Enterprise - The admin partition to use. If not provided, the partition is inferred from the request's ACL token, or defaults to thedefault
partition.
Sample Request
Sample Response
Note If the token used for accessing the API has acl:write
permissions,
then the SecretID
will contain the tokens real value. Only when accessed with
a token with only acl:read
permissions will the SecretID
be redacted. This
is to prevent privilege escalation whereby having acl:read
privileges allows
for reading other secrets which given even more permissions.
Methods to specify namespace Enterprise
ACL token endpoints support several methods for specifying the namespace of the ACL token resources with the following order of precedence:
Namespace
field of the JSON request body - only applies to create and update endpointsns
query parameterX-Consul-Namespace
request header- Namespace is inherited from the namespace of the request's ACL token (if any)
- The
default
namespace