2018-08-17 12:17:11 -04:00
|
|
|
|
---
|
2020-01-17 19:18:09 -05:00
|
|
|
|
layout: api
|
|
|
|
|
|
page_title: /sys/namespaces - HTTP API
|
|
|
|
|
|
description: The `/sys/namespaces` endpoint is used manage namespaces in Vault.
|
2018-08-17 12:17:11 -04:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
# `/sys/namespaces`
|
|
|
|
|
|
|
2024-09-19 21:28:58 -04:00
|
|
|
|
@include 'alerts/enterprise-only.mdx'
|
|
|
|
|
|
|
2018-08-17 12:17:11 -04:00
|
|
|
|
The `/sys/namespaces` endpoint is used manage namespaces in Vault.
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
## List namespaces
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
|
|
|
|
|
This endpoints lists all the namespaces.
|
|
|
|
|
|
|
2020-01-17 19:18:09 -05:00
|
|
|
|
| Method | Path |
|
|
|
|
|
|
| :----- | :---------------- |
|
|
|
|
|
|
| `LIST` | `/sys/namespaces` |
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2020-05-21 13:18:17 -04:00
|
|
|
|
```shell-session
|
2018-08-17 12:17:11 -04:00
|
|
|
|
$ curl \
|
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
|
-X LIST \
|
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample response
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
|
|
|
|
|
```json
|
2022-12-08 15:05:34 -05:00
|
|
|
|
{
|
|
|
|
|
|
"data": {
|
|
|
|
|
|
"key_info": {
|
|
|
|
|
|
"bar/": {
|
|
|
|
|
|
"custom_metadata": {},
|
|
|
|
|
|
"id": "HWmNL",
|
|
|
|
|
|
"path": "bar/"
|
|
|
|
|
|
},
|
|
|
|
|
|
"foo/": {
|
|
|
|
|
|
"custom_metadata": {},
|
|
|
|
|
|
"id": "5q39x",
|
|
|
|
|
|
"path": "foo/"
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
"keys": [
|
|
|
|
|
|
"bar/",
|
|
|
|
|
|
"foo/"
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-08-17 12:17:11 -04:00
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
## Create namespace
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2021-09-21 09:15:51 -04:00
|
|
|
|
This endpoint creates a namespace at the given path.
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2020-01-17 19:18:09 -05:00
|
|
|
|
| Method | Path |
|
|
|
|
|
|
| :----- | :---------------------- |
|
|
|
|
|
|
| `POST` | `/sys/namespaces/:path` |
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
|
|
|
|
- `path` `(string: <required>)` – Specifies the path where the namespace
|
2021-09-21 09:15:51 -04:00
|
|
|
|
will be created.
|
2022-08-09 14:10:41 -04:00
|
|
|
|
- `custom_metadata` `(map<string|string>: nil)` - A map of arbitrary string to string valued user-provided metadata meant
|
|
|
|
|
|
to describe the namespace.
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample payload
|
2022-08-09 14:10:41 -04:00
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"custom_metadata": {
|
|
|
|
|
|
"foo": "abc",
|
|
|
|
|
|
"bar": "123"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2020-05-21 13:18:17 -04:00
|
|
|
|
```shell-session
|
2018-08-17 12:17:11 -04:00
|
|
|
|
$ curl \
|
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
|
--request POST \
|
2022-08-09 14:10:41 -04:00
|
|
|
|
--data @payload.json \
|
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/ns1
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
## Patch namespace
|
2022-08-09 14:10:41 -04:00
|
|
|
|
|
|
|
|
|
|
This endpoint patches an existing namespace at the specified path.
|
|
|
|
|
|
|
|
|
|
|
|
| Method | Path |
|
|
|
|
|
|
| :------- | :---------------------- |
|
|
|
|
|
|
| `PATCH` | `/sys/namespaces/:path` |
|
|
|
|
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
|
|
|
|
- `path` `(string: <required>)` – Specifies the path of the existing namespace.
|
|
|
|
|
|
- `custom_metadata` `(map<string|string>: nil)` - A map of arbitrary string to string valued user-provided metadata meant
|
|
|
|
|
|
to describe the namespace.
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample payload
|
2022-08-09 14:10:41 -04:00
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"custom_metadata": {
|
|
|
|
|
|
"foo": "abc",
|
|
|
|
|
|
"bar": "123"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request
|
2022-08-09 14:10:41 -04:00
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
|
$ curl \
|
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
|
--header "Content-Type: application/merge-patch+json"
|
|
|
|
|
|
--request PATCH \
|
|
|
|
|
|
--data @payload.json \
|
2018-08-17 12:17:11 -04:00
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/ns1
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
## Delete namespace
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
|
|
|
|
|
This endpoint deletes a namespace at the specified path.
|
|
|
|
|
|
|
2020-01-17 19:18:09 -05:00
|
|
|
|
| Method | Path |
|
|
|
|
|
|
| :------- | :---------------------- |
|
|
|
|
|
|
| `DELETE` | `/sys/namespaces/:path` |
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2020-05-21 13:18:17 -04:00
|
|
|
|
```shell-session
|
2018-08-17 12:17:11 -04:00
|
|
|
|
$ curl \
|
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
|
--request DELETE \
|
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/ns1
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
## Read namespace information
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2021-11-09 17:43:17 -05:00
|
|
|
|
This endpoint gets the metadata for the given namespace path.
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2020-01-17 19:18:09 -05:00
|
|
|
|
| Method | Path |
|
|
|
|
|
|
| :----- | :---------------------- |
|
|
|
|
|
|
| `GET` | `/sys/namespaces/:path` |
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
2020-05-21 13:18:17 -04:00
|
|
|
|
```shell-session
|
2018-08-17 12:17:11 -04:00
|
|
|
|
$ curl \
|
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/ns1
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample response
|
2018-08-17 12:17:11 -04:00
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"id": "gsudj",
|
2022-08-09 14:10:41 -04:00
|
|
|
|
"path": "ns1/",
|
|
|
|
|
|
"custom_metadata": {
|
|
|
|
|
|
"foo": "abc",
|
|
|
|
|
|
"bar": "123"
|
|
|
|
|
|
}
|
2018-08-17 12:17:11 -04:00
|
|
|
|
}
|
|
|
|
|
|
```
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
## Lock namespace
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
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
|
2023-01-25 19:12:15 -05:00
|
|
|
|
[API Locked Response](/vault/docs/concepts/namespace-api-lock#api-locked-response).
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
| Method | Path |
|
|
|
|
|
|
| :----- | :---------------------- |
|
|
|
|
|
|
| `POST` | `/sys/namespaces/api-lock/lock/:subpath` |
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request - current namespace
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
|
$ curl \
|
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
|
--request POST \
|
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/api-lock/lock
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample response - current namespace
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"unlock_key": "<unlock key for current/ns/path>"
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request - X-Vault-Namespace
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```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
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample response - X-Vault-Namespace
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"unlock_key": "<unlock key for some/path>"
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request - descendant of current namespace
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
|
$ curl \
|
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
|
--request POST \
|
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/api-lock/lock/some/descendant/subpath
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample response - descendant of current namespace
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"unlock_key": "<unlock key for current/ns/path/some/descendant/subpath>"
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
## Unlock namespace
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
This endpoint unlocks the api for the current namespace path or optional subpath.
|
|
|
|
|
|
|
|
|
|
|
|
| Method | Path |
|
|
|
|
|
|
| :----- | :---------------------- |
|
|
|
|
|
|
| `POST` | `/sys/namespaces/api-lock/unlock/:subpath` |
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample payload - current namespace Non-Root
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"unlock_key": "<unlock key for current/ns/path>"
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request - current namespace Non-Root
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
|
$ curl \
|
|
|
|
|
|
--header "X-Vault-Token: ..." \
|
|
|
|
|
|
--request POST \
|
|
|
|
|
|
--data @payload.json \
|
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/api-lock/unlock
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request - current namespace root
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```shell-session
|
|
|
|
|
|
$ curl \
|
|
|
|
|
|
--header "X-Vault-Token: <some root token>" \
|
|
|
|
|
|
--request POST \
|
|
|
|
|
|
http://127.0.0.1:8200/v1/sys/namespaces/api-lock/unlock
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample payload - descendant namespace Non-Root
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"unlock_key": "<unlock key for current/ns/path/some/descendant/subpath>"
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2023-06-30 19:22:07 -04:00
|
|
|
|
### Sample request - descendant namespace Non-Root
|
2021-11-09 17:43:17 -05:00
|
|
|
|
|
|
|
|
|
|
```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
|
|
|
|
|
|
```
|