2017-08-23 23:56:05 +00:00
---
layout: api
page_title: ACL Tokens - HTTP API
2020-02-06 23:45:31 +00:00
description: The /acl/token/ endpoints are used to configure and manage ACL tokens.
2017-08-23 23:56:05 +00:00
---
# ACL Tokens HTTP API
The `/acl/bootstrap`, `/acl/tokens`, and `/acl/token/` endpoints are used to manage ACL tokens.
2020-09-29 16:48:32 +00:00
For more details about ACLs, please see the [ACL Guide](https://learn.hashicorp.com/collections/nomad/access-control).
2017-08-23 23:56:05 +00:00
## Bootstrap Token
2022-06-03 11:37:24 +00:00
This endpoint is used to bootstrap the ACL system and provide the initial management token.
An operator created token can be provided in the body of the request to bootstrap the cluster
if required. If no header is provided the cluster will return a generated management token.
The provided token should be presented in a UUID format.
2017-09-10 23:18:39 +00:00
This request is always forwarded to the authoritative region. It can only be invoked once
2020-09-29 16:48:32 +00:00
until a [bootstrap reset](https://learn.hashicorp.com/tutorials/nomad/access-control-bootstrap#re-bootstrap-acl-system) is performed.
2017-08-23 23:56:05 +00:00
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ---------------- | ------------------ |
| `POST` | `/acl/bootstrap` | `application/json` |
2017-08-23 23:56:05 +00:00
The table below shows this endpoint's support for
2020-03-20 22:24:56 +00:00
[blocking queries](/api-docs#blocking-queries) and
[required ACLs](/api-docs#acls).
2017-08-23 23:56:05 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | ------------ |
| `NO` | `none` |
2017-08-23 23:56:05 +00:00
### Sample Request
2020-05-01 20:02:21 +00:00
```shell-session
2017-08-23 23:56:05 +00:00
$ curl \
--request POST \
2018-01-29 16:27:52 +00:00
https://localhost:4646/v1/acl/bootstrap
2017-08-23 23:56:05 +00:00
```
### Sample Response
```json
{
2020-02-06 23:45:31 +00:00
"AccessorID": "b780e702-98ce-521f-2e5f-c6b87de05b24",
"SecretID": "3f4a0fcd-7c42-773c-25db-2d31ba0c05fe",
"Name": "Bootstrap Token",
"Type": "management",
"Policies": null,
"Global": true,
"CreateTime": "2017-08-23T22:47:14.695408057Z",
"CreateIndex": 7,
"ModifyIndex": 7
2017-08-23 23:56:05 +00:00
}
```
2022-06-03 11:37:24 +00:00
### Sample Operator Payload
```json
{
"BootstrapSecret": "2b778dd9-f5f1-6f29-b4b4-9a5fa948757a"
}
```
### Sample Request With Operator Token
```shell-session
$ curl \
--request POST \
--data @root-token.json \
https://localhost:4646/v1/acl/bootstrap
```
### Sample Response With Operator Token
```json
{
"AccessorID": "b780e702-98ce-521f-2e5f-c6b87de05b24",
"SecretID": "2b778dd9-f5f1-6f29-b4b4-9a5fa948757a",
"Name": "Bootstrap Token",
"Type": "management",
"Policies": null,
"Global": true,
"CreateTime": "2017-08-23T22:47:14.695408057Z",
"CreateIndex": 7,
"ModifyIndex": 7
}
```
2017-08-23 23:56:05 +00:00
## List Tokens
This endpoint lists all ACL tokens. This lists the local tokens and the global
tokens which have been replicated to the region, and may lag behind the authoritative region.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ------------- | ------------------ |
| `GET` | `/acl/tokens` | `application/json` |
2017-08-23 23:56:05 +00:00
The table below shows this endpoint's support for
2020-03-20 22:24:56 +00:00
[blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and
[required ACLs](/api-docs#acls).
2017-08-23 23:56:05 +00:00
| Blocking Queries | Consistency Modes | ACL Required |
| ---------------- | ----------------- | ------------ |
| `YES` | `all` | `management` |
2019-10-08 18:05:12 +00:00
### Parameters
2022-03-12 00:44:52 +00:00
- `global` `(bool: false)` - If true, only return ACL tokens that are
replicated globally to all regions.
2019-10-08 18:05:12 +00:00
- `prefix` `(string: "")` - Specifies a string to filter ACL tokens based on an
2019-10-08 22:11:56 +00:00
accessor ID prefix. Because the value is decoded to bytes, the prefix must
have an even number of hexadecimal characters (0-9a-f). This is specified as
a query string parameter.
2017-08-23 23:56:05 +00:00
2022-03-14 14:58:42 +00:00
- `next_token` `(string: "")` - This endpoint supports paging. The `next_token`
parameter accepts a string which identifies the next expected ACL token. This
value can be obtained from the `X-Nomad-NextToken` header from the previous
response.
- `per_page` `(int: 0)` - Specifies a maximum number of ACL tokens to return
for this request. If omitted, the response is not paginated. The value of the
`X-Nomad-NextToken` header of the last response can be used as the
`next_token` of the next request to fetch additional pages.
- `filter` `(string: "")` - Specifies the [expression](/api-docs#filtering)
used to filter the results. Consider using pagination or a query parameter to
reduce resource used to serve the request.
2022-03-12 00:44:52 +00:00
- `reverse` `(bool: false)` - Specifies the list of returned ACL tokens should
be sorted in the reverse order. By default ACL tokens are returned sorted in
chronological order (older ACL tokens first), or in lexicographical order by
their ID if the `prefix` or `global` query parameters are used.
2017-08-23 23:56:05 +00:00
### Sample Request
2020-05-01 20:02:21 +00:00
```shell-session
2017-08-23 23:56:05 +00:00
$ curl \
2018-01-29 16:27:52 +00:00
https://localhost:4646/v1/acl/tokens
2017-08-23 23:56:05 +00:00
```
2020-05-01 20:02:21 +00:00
```shell-session
2019-10-08 18:05:12 +00:00
$ curl \
--request POST \
2019-10-11 14:28:44 +00:00
https://localhost:4646/v1/acl/tokens?prefix=3da2ed52
2019-10-08 18:05:12 +00:00
```
2017-08-23 23:56:05 +00:00
### Sample Response
```json
[
{
"AccessorID": "b780e702-98ce-521f-2e5f-c6b87de05b24",
"Name": "Bootstrap Token",
"Type": "management",
"Policies": null,
"Global": true,
"CreateTime": "2017-08-23T22:47:14.695408057Z",
"CreateIndex": 7,
"ModifyIndex": 7
}
]
```
## Create Token
This endpoint creates an ACL Token. If the token is a global token, the request
is forwarded to the authoritative region.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ------------ | ------------------ |
| `POST` | `/acl/token` | `application/json` |
2017-08-23 23:56:05 +00:00
The table below shows this endpoint's support for
2020-03-20 22:24:56 +00:00
[blocking queries](/api-docs#blocking-queries) and
[required ACLs](/api-docs#acls).
2017-08-23 23:56:05 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | ------------ |
| `NO` | `management` |
2017-08-23 23:56:05 +00:00
### Parameters
- `Name` `(string: <optional>)` - Specifies the human readable name of the token.
- `Type` `(string: <required>)` - Specifies the type of token. Must be either `client` or `management`.
- `Policies` `(array<string>: <required>)` - Must be null or blank for `management` type tokens, otherwise must specify at least one policy for `client` type tokens.
- `Global` `(bool: <optional>)` - If true, indicates this token should be replicated globally to all regions. Otherwise, this token is created local to the target region.
### Sample Payload
```json
{
2020-02-06 23:45:31 +00:00
"Name": "Readonly token",
"Type": "client",
"Policies": ["readonly"],
"Global": false
2017-08-23 23:56:05 +00:00
}
```
### Sample Request
2020-05-01 20:02:21 +00:00
```shell-session
2017-08-23 23:56:05 +00:00
$ curl \
--request POST \
--data @payload.json \
2018-01-29 16:27:52 +00:00
https://localhost:4646/v1/acl/token
2017-08-23 23:56:05 +00:00
```
### Sample Response
```json
{
"AccessorID": "aa534e09-6a07-0a45-2295-a7f77063d429",
"SecretID": "8176afd3-772d-0b71-8f85-7fa5d903e9d4",
"Name": "Readonly token",
"Type": "client",
2020-02-06 23:45:31 +00:00
"Policies": ["readonly"],
2017-08-23 23:56:05 +00:00
"Global": false,
"CreateTime": "2017-08-23T23:25:41.429154233Z",
"CreateIndex": 52,
"ModifyIndex": 52
}
```
## Update Token
This endpoint updates an existing ACL Token. If the token is a global token, the request
is forwarded to the authoritative region. Note that a token cannot be switched from global
to local or visa versa.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ------------------------- | ------------------ |
| `POST` | `/acl/token/:accessor_id` | `application/json` |
2017-08-23 23:56:05 +00:00
The table below shows this endpoint's support for
2020-03-20 22:24:56 +00:00
[blocking queries](/api-docs#blocking-queries) and
[required ACLs](/api-docs#acls).
2017-08-23 23:56:05 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | ------------ |
| `NO` | `management` |
2017-08-23 23:56:05 +00:00
### Parameters
- `AccessorID` `(string: <required>)` - Specifies the token (by accessor) that is being updated. Must match payload body and request path.
- `Name` `(string: <optional>)` - Specifies the human readable name of the token.
- `Type` `(string: <required>)` - Specifies the type of token. Must be either `client` or `management`.
- `Policies` `(array<string>: <required>)` - Must be null or blank for `management` type tokens, otherwise must specify at least one policy for `client` type tokens.
### Sample Payload
```json
{
2020-02-06 23:45:31 +00:00
"AccessorID": "aa534e09-6a07-0a45-2295-a7f77063d429",
"Name": "Read-write token",
"Type": "client",
"Policies": ["readwrite"]
2017-08-23 23:56:05 +00:00
}
```
### Sample Request
2020-05-01 20:02:21 +00:00
```shell-session
2017-08-23 23:56:05 +00:00
$ curl \
--request POST \
--data @payload.json \
2018-01-29 16:27:52 +00:00
https://localhost:4646/v1/acl/token/aa534e09-6a07-0a45-2295-a7f77063d429
2017-08-23 23:56:05 +00:00
```
### Sample Response
```json
{
"AccessorID": "aa534e09-6a07-0a45-2295-a7f77063d429",
"SecretID": "8176afd3-772d-0b71-8f85-7fa5d903e9d4",
"Name": "Read-write token",
"Type": "client",
2020-02-06 23:45:31 +00:00
"Policies": ["readwrite"],
2017-08-23 23:56:05 +00:00
"Global": false,
"CreateTime": "2017-08-23T23:25:41.429154233Z",
"CreateIndex": 52,
"ModifyIndex": 64
}
```
## Read Token
This endpoint reads an ACL token with the given accessor. If the token is a global token
which has been replicated to the region it may lag behind the authoritative region.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ------------------------- | ------------------ |
| `GET` | `/acl/token/:accessor_id` | `application/json` |
2017-08-23 23:56:05 +00:00
The table below shows this endpoint's support for
2020-03-20 22:24:56 +00:00
[blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and
[required ACLs](/api-docs#acls).
2017-08-23 23:56:05 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | Consistency Modes | ACL Required |
| ---------------- | ----------------- | -------------------------------------------------- |
2017-09-27 20:42:56 +00:00
| `YES` | `all` | `management` or a SecretID matching the AccessorID |
2017-08-23 23:56:05 +00:00
### Sample Request
2020-05-01 20:02:21 +00:00
```shell-session
2017-08-23 23:56:05 +00:00
$ curl \
2018-01-29 16:27:52 +00:00
https://localhost:4646/v1/acl/token/aa534e09-6a07-0a45-2295-a7f77063d429
2017-08-23 23:56:05 +00:00
```
### Sample Response
2017-10-13 20:10:26 +00:00
```json
{
"AccessorID": "aa534e09-6a07-0a45-2295-a7f77063d429",
"SecretID": "8176afd3-772d-0b71-8f85-7fa5d903e9d4",
"Name": "Read-write token",
"Type": "client",
2020-02-06 23:45:31 +00:00
"Policies": ["readwrite"],
2017-10-13 20:10:26 +00:00
"Global": false,
"CreateTime": "2017-08-23T23:25:41.429154233Z",
"CreateIndex": 52,
"ModifyIndex": 64
}
```
## Read Self Token
This endpoint reads the ACL token given by the passed SecretID. If the token is a global token
which has been replicated to the region it may lag behind the authoritative region.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ----------------- | ------------------ |
| `GET` | `/acl/token/self` | `application/json` |
2017-10-13 20:10:26 +00:00
The table below shows this endpoint's support for
2020-03-20 22:24:56 +00:00
[blocking queries](/api-docs#blocking-queries), [consistency modes](/api-docs#consistency-modes) and
[required ACLs](/api-docs#acls).
2017-10-13 20:10:26 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | Consistency Modes | ACL Required |
| ---------------- | ----------------- | ------------------- |
2017-10-13 20:10:26 +00:00
| `YES` | `all` | Any valid ACL token |
### Sample Request
2020-05-01 20:02:21 +00:00
```shell-session
2017-10-13 20:10:26 +00:00
$ curl \
2017-10-16 18:29:08 +00:00
--header "X-Nomad-Token: 8176afd3-772d-0b71-8f85-7fa5d903e9d4" \
2018-01-29 16:27:52 +00:00
https://localhost:4646/v1/acl/token/self
2017-10-13 20:10:26 +00:00
```
### Sample Response
2017-08-23 23:56:05 +00:00
```json
{
"AccessorID": "aa534e09-6a07-0a45-2295-a7f77063d429",
"SecretID": "8176afd3-772d-0b71-8f85-7fa5d903e9d4",
"Name": "Read-write token",
"Type": "client",
2020-02-06 23:45:31 +00:00
"Policies": ["readwrite"],
2017-08-23 23:56:05 +00:00
"Global": false,
"CreateTime": "2017-08-23T23:25:41.429154233Z",
"CreateIndex": 52,
"ModifyIndex": 64
}
```
## Delete Token
This endpoint deletes the ACL token by accessor. This request is forwarded to the
authoritative region for global tokens.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| -------- | ------------------------- | -------------- |
| `DELETE` | `/acl/token/:accessor_id` | `(empty body)` |
2017-08-23 23:56:05 +00:00
The table below shows this endpoint's support for
2020-03-20 22:24:56 +00:00
[blocking queries](/api-docs#blocking-queries) and
[required ACLs](/api-docs#acls).
2017-08-23 23:56:05 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | ------------ |
| `NO` | `management` |
2017-08-23 23:56:05 +00:00
### Parameters
- `accessor_id` `(string: <required>)` - Specifies the ACL token accessor ID.
### Sample Request
2020-05-01 20:02:21 +00:00
```shell-session
2017-08-23 23:56:05 +00:00
$ curl \
--request DELETE \
2018-01-29 16:27:52 +00:00
https://localhost:4646/v1/acl/token/aa534e09-6a07-0a45-2295-a7f77063d429
2017-08-23 23:56:05 +00:00
```
2021-02-25 21:41:00 +00:00
## Upsert One-Time Token
This endpoint creates a one-time token for the ACL token provided in the
`X-Nomad-Token` header. Returns 403 if the token header is not set.
2021-03-31 13:43:17 +00:00
| Method | Path | Produces |
| ------ | -------------------- | ------------------ |
| `POST` | `/acl/token/onetime` | `application/json` |
2021-02-25 21:41:00 +00:00
The table below shows this endpoint's support for
[blocking queries](/api-docs#blocking-queries) and
[required ACLs](/api-docs#acls).
| Blocking Queries | ACL Required |
| ---------------- | ------------ |
| `NO` | `any` |
### Sample Request
```shell-session
$ curl \
--request POST \
-H "X-Nomad-Token: aa534e09-6a07-0a45-2295-a7f77063d429" \
https://localhost:4646/v1/acl/token/onetime
```
### Sample Response
```json
{
"Index": 15,
"OneTimeToken": {
"AccessorID": "b780e702-98ce-521f-2e5f-c6b87de05b24",
"CreateIndex": 7,
"ExpiresAt": "2017-08-23T22:47:14.695408057Z",
"ModifyIndex": 7,
"OneTimeSecretID": "3f4a0fcd-7c42-773c-25db-2d31ba0c05fe"
}
}
```
## Exchange One-Time Token
This endpoint exchanges a one-time token for the original ACL token used to
create it.
2021-03-31 13:43:17 +00:00
| Method | Path | Produces |
| ------ | ----------------------------- | ------------------ |
| `POST` | `/acl/token/onetime/exchange` | `application/json` |
2021-02-25 21:41:00 +00:00
The table below shows this endpoint's support for
[blocking queries](/api-docs#blocking-queries) and
[required ACLs](/api-docs#acls).
| Blocking Queries | ACL Required |
| ---------------- | ------------ |
| `NO` | `any` |
### Sample Request
```shell-session
$ curl \
--request POST \
-d '{ "OneTimeSecretID": "aa534e09-6a07-0a45-2295-a7f77063d429" } \
https://localhost:4646/v1/acl/token/onetime/exchange
```
### Sample Response
```json
{
"Index": 17,
"Token": {
"AccessorID": "b780e702-98ce-521f-2e5f-c6b87de05b24",
"CreateIndex": 7,
"CreateTime": "2017-08-23T22:47:14.695408057Z",
"Global": true,
"Hash": "UhZESkSFGFfX7eBgq5Uwph30OctbUbpe8+dlH2i4whA=",
"ModifyIndex": 7,
"Name": "Developer token",
2021-03-31 13:43:17 +00:00
"Policies": ["developer"],
2021-02-25 21:41:00 +00:00
"SecretID": "3f4a0fcd-7c42-773c-25db-2d31ba0c05fe",
"Type": "client"
}
}
```