2020-03-16 13:42:39 +00:00
---
2020-09-01 15:14:13 +00:00
layout: commands
2020-04-07 18:55:19 +00:00
page_title: 'Commands: Namespace Create'
2023-01-26 18:42:13 +00:00
description: |
The `consul namespace create` command generates a new namespace in Consul Enterprise. Policies, roles, and metadata can be assigned when creating a namespace.
2020-03-16 13:42:39 +00:00
---
# Consul Namespace Create
Command: `consul namespace create`
2023-01-25 16:52:43 +00:00
Corresponding HTTP API Endpoint: [\[PUT\] /v1/namespace](/consul/api-docs/namespaces#create-a-namespace)
2022-01-10 17:40:11 +00:00
2020-04-23 22:13:18 +00:00
<EnterpriseAlert />
2020-04-07 18:55:19 +00:00
This `namespace create` command creates a namespaces using the CLI parameters provided.
2020-03-16 13:42:39 +00:00
This was added in Consul Enterprise 1.7.2.
2023-01-25 16:52:43 +00:00
The table below shows this command's [required ACLs](/consul/api-docs/api-structure#authentication). Configuration of
[blocking queries](/consul/api-docs/features/blocking) and [agent caching](/consul/api-docs/features/caching)
2022-01-10 21:44:56 +00:00
are not supported from commands, but may be from the corresponding HTTP endpoint.
| ACL Required |
| ---------------- |
| `operator:write` |
2020-03-16 13:42:39 +00:00
## Usage
Usage: `consul namespace create -name <namespace name> [options]`
Request a namespace to be created. Construction of the namespace definition is handled by this command
from the CLI arguments.
#### Command Options
2020-04-07 18:55:19 +00:00
- `-default-policy-id=<value>` - ID of a policy from the default namespace to inject for all tokens
in this namespace. May be specified multiple times.
2020-03-16 13:42:39 +00:00
2020-04-07 18:55:19 +00:00
- `-default-policy-name=<value>` - Name of a policy from the default namespace to inject for all
2021-11-01 22:50:42 +00:00
tokens in this namespace. May be specified multiple times. The ACL token used with
2023-01-25 16:52:43 +00:00
this command must have [`acl:write` access](/consul/docs/security/acl/acl-rules#acl-resource-rules) to the linked policy.
2020-03-16 13:42:39 +00:00
2020-04-07 18:55:19 +00:00
- `-default-role-id=<value>` - ID of a role from the default namespace to inject for all tokens in
2021-11-01 22:50:42 +00:00
this namespace. May be specified multiple times. The ACL token used with
2023-01-25 16:52:43 +00:00
this command must have [`acl:write` access](/consul/docs/security/acl/acl-rules#acl-resource-rules) to the linked role.
2020-03-16 13:42:39 +00:00
2020-04-07 18:55:19 +00:00
- `-default-role-name=<value>` - Name of a role from the default namespace to inject for all tokens
in this namespace. May be specified multiple times.
2020-03-16 13:42:39 +00:00
2020-04-07 18:55:19 +00:00
- `-description=<string>` - A description of the namespace.
2020-03-16 13:42:39 +00:00
2020-04-07 18:55:19 +00:00
- `-format=<string>` - How to output the results. The choices are: pretty or json
2020-03-16 13:42:39 +00:00
2020-04-07 18:55:19 +00:00
- `-meta=<value>` - Metadata to set on the namespace, formatted as key=value. This flag
may be specified multiple times to set multiple meta fields
2020-03-16 13:42:39 +00:00
2020-04-07 18:55:19 +00:00
- `-name=<string>` - The namespace's name. This flag is required.
2020-03-16 13:42:39 +00:00
2020-04-07 18:55:19 +00:00
- `-show-meta` - Indicates that namespace metadata such as the raft indices should
be shown for the namespace
2020-03-16 13:42:39 +00:00
2022-07-27 06:17:11 +00:00
#### API Options
@include 'http_api_partition_options.mdx'
@include 'http_api_options_client.mdx'
@include 'http_api_options_server.mdx'
2020-03-16 13:42:39 +00:00
## Examples
Create a new Namespace:
2020-05-19 18:32:38 +00:00
```shell-session
2020-03-16 13:42:39 +00:00
$ consul namespace create -name "team-1"
Name: team-1
```
Showing Raft Metadata:
2020-05-19 18:32:38 +00:00
```shell-session
2020-03-16 13:42:39 +00:00
$ consul namespace create -name team-1 -show-meta
Name: team-1
Create Index: 339
Modify Index: 344
```
JSON Format:
2020-05-19 18:32:38 +00:00
```shell-session
2020-03-16 13:42:39 +00:00
$ consul namespace create -name team2 -description "Example Namespace" -meta "team-id=574407f3-8b26-4c84-8e51-028bb8cbdd37" -format=json
{
"Name": "team2",
"Description": "Example Namespace",
"Meta": {
"team-id": "574407f3-8b26-4c84-8e51-028bb8cbdd37"
},
"CreateIndex": 352,
"ModifyIndex": 352
}
```