2018-08-17 16:17:11 +00:00
|
|
|
|
---
|
2020-01-18 00:18:09 +00:00
|
|
|
|
layout: api
|
|
|
|
|
page_title: /sys/namespaces - HTTP API
|
|
|
|
|
description: The `/sys/namespaces` endpoint is used manage namespaces in Vault.
|
2018-08-17 16:17:11 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# `/sys/namespaces`
|
|
|
|
|
|
|
|
|
|
The `/sys/namespaces` endpoint is used manage namespaces in Vault.
|
|
|
|
|
|
|
|
|
|
## List Namespaces
|
|
|
|
|
|
|
|
|
|
This endpoints lists all the namespaces.
|
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
|
| Method | Path |
|
|
|
|
|
| :----- | :---------------- |
|
|
|
|
|
| `LIST` | `/sys/namespaces` |
|
2018-08-17 16:17:11 +00:00
|
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
|
```shell-session
|
2018-08-17 16:17:11 +00:00
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
-X LIST \
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
|
|
```json
|
2020-01-18 00:18:09 +00:00
|
|
|
|
["ns1/", "ns2/"]
|
2018-08-17 16:17:11 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Create Namespace
|
|
|
|
|
|
2021-09-21 13:15:51 +00:00
|
|
|
|
This endpoint creates a namespace at the given path.
|
2018-08-17 16:17:11 +00:00
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
|
| Method | Path |
|
|
|
|
|
| :----- | :---------------------- |
|
|
|
|
|
| `POST` | `/sys/namespaces/:path` |
|
2018-08-17 16:17:11 +00:00
|
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
|
|
- `path` `(string: <required>)` – Specifies the path where the namespace
|
2021-09-21 13:15:51 +00:00
|
|
|
|
will be created.
|
2018-08-17 16:17:11 +00:00
|
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
|
```shell-session
|
2018-08-17 16:17:11 +00:00
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
--request POST \
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/ns1
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Delete Namespace
|
|
|
|
|
|
|
|
|
|
This endpoint deletes a namespace at the specified path.
|
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
|
| Method | Path |
|
|
|
|
|
| :------- | :---------------------- |
|
|
|
|
|
| `DELETE` | `/sys/namespaces/:path` |
|
2018-08-17 16:17:11 +00:00
|
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
|
```shell-session
|
2018-08-17 16:17:11 +00:00
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
--request DELETE \
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/ns1
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Read Namespace Information
|
|
|
|
|
|
2021-11-09 22:43:17 +00:00
|
|
|
|
This endpoint gets the metadata for the given namespace path.
|
2018-08-17 16:17:11 +00:00
|
|
|
|
|
2020-01-18 00:18:09 +00:00
|
|
|
|
| Method | Path |
|
|
|
|
|
| :----- | :---------------------- |
|
|
|
|
|
| `GET` | `/sys/namespaces/:path` |
|
2018-08-17 16:17:11 +00:00
|
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
|
2020-05-21 17:18:17 +00:00
|
|
|
|
```shell-session
|
2018-08-17 16:17:11 +00:00
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/ns1
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"id": "gsudj",
|
|
|
|
|
"path": "ns1/"
|
|
|
|
|
}
|
|
|
|
|
```
|
2021-11-09 22:43:17 +00:00
|
|
|
|
|
|
|
|
|
## Lock Namespace
|
|
|
|
|
|
|
|
|
|
This endpoint locks the API for the current namespace path or optional subpath.
|
|
|
|
|
The behavior when interacting with Vault from a locked namespace is described in
|
|
|
|
|
[API Locked Response](/docs/concepts/namespace-api-lock#api-locked-response).
|
|
|
|
|
|
|
|
|
|
| Method | Path |
|
|
|
|
|
| :----- | :---------------------- |
|
|
|
|
|
| `POST` | `/sys/namespaces/api-lock/lock/:subpath` |
|
|
|
|
|
|
|
|
|
|
### Sample Request - Current Namespace
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
--request POST \
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/api-lock/lock
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Response - Current Namespace
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"unlock_key": "<unlock key for current/ns/path>"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Request - X-Vault-Namespace
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
--header "X-Vault-Namespace: some/path
|
|
|
|
|
--request POST \
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/api-lock/lock
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Response - X-Vault-Namespace
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"unlock_key": "<unlock key for some/path>"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Request - Descendant of Current Namespace
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
--request POST \
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/api-lock/lock/some/descendant/subpath
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Response - Descendant of Current Namespace
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"unlock_key": "<unlock key for current/ns/path/some/descendant/subpath>"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Unlock Namespace
|
|
|
|
|
|
|
|
|
|
This endpoint unlocks the api for the current namespace path or optional subpath.
|
|
|
|
|
|
|
|
|
|
| Method | Path |
|
|
|
|
|
| :----- | :---------------------- |
|
|
|
|
|
| `POST` | `/sys/namespaces/api-lock/unlock/:subpath` |
|
|
|
|
|
|
|
|
|
|
### Sample Payload - Current Namespace Non-Root
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"unlock_key": "<unlock key for current/ns/path>"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Request - Current Namespace Non-Root
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
--request POST \
|
|
|
|
|
--data @payload.json \
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/api-lock/unlock
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Request - Current Namespace Root
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: <some root token>" \
|
|
|
|
|
--request POST \
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/api-lock/unlock
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Payload - Descendant Namespace Non-Root
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
{
|
|
|
|
|
"unlock_key": "<unlock key for current/ns/path/some/descendant/subpath>"
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Sample Request - Descendant Namespace Non-Root
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
$ curl \
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
--request POST \
|
|
|
|
|
--data @payload.json \
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/api-lock/unlock/some/descendant/path
|
|
|
|
|
```
|