2019-05-01 18:21:11 +00:00
|
|
|
---
|
|
|
|
layout: api
|
|
|
|
page_title: Config - HTTP API
|
|
|
|
description: |-
|
|
|
|
The /config endpoints are for managing centralized configuration
|
|
|
|
in Consul.
|
|
|
|
---
|
|
|
|
|
|
|
|
# Config HTTP Endpoint
|
|
|
|
|
|
|
|
The `/config` endpoints create, update, delete and query central configuration
|
|
|
|
entries registered with Consul. See the
|
2022-01-11 01:30:50 +00:00
|
|
|
[agent configuration](/docs/agent/config/config-files#enable_central_service_config)
|
2019-05-08 20:19:37 +00:00
|
|
|
for more information on how to enable this functionality for centrally
|
2020-10-14 15:23:05 +00:00
|
|
|
configuring services and [configuration entries docs](/docs/agent/config-entries) for a description
|
2019-05-08 20:19:37 +00:00
|
|
|
of the configuration entries content.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
## Apply Configuration
|
|
|
|
|
|
|
|
This endpoint creates or updates the given config entry.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | --------- | ------------------ |
|
|
|
|
| `PUT` | `/config` | `application/json` |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2022-03-30 21:16:26 +00:00
|
|
|
[blocking queries](/api-docs/features/blocking),
|
|
|
|
[consistency modes](/api-docs/features/consistency),
|
|
|
|
[agent caching](/api-docs/features/caching), and
|
2022-10-18 19:49:07 +00:00
|
|
|
[required ACLs](/api-docs/api-structure#authentication).
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------------------------------------------- |
|
|
|
|
| `NO` | `none` | `none` | `service:write`<br />`operator:write`<sup>1</sup> |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
<p>
|
|
|
|
<sup>1</sup> The ACL required depends on the config entry kind being updated:
|
|
|
|
</p>
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-10-14 15:23:05 +00:00
|
|
|
| Config Entry Kind | Required ACL |
|
|
|
|
| ------------------- | ------------------ |
|
|
|
|
| ingress-gateway | `operator:write` |
|
|
|
|
| proxy-defaults | `operator:write` |
|
|
|
|
| service-defaults | `service:write` |
|
|
|
|
| service-intentions | `intentions:write` |
|
|
|
|
| service-resolver | `service:write` |
|
|
|
|
| service-router | `service:write` |
|
|
|
|
| service-splitter | `service:write` |
|
|
|
|
| terminating-gateway | `operator:write` |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-01-15 17:29:35 +00:00
|
|
|
The corresponding CLI command is [`consul config write`](/commands/config/write).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Query Parameters
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `dc` `(string: "")` - Specifies the datacenter to query.
|
|
|
|
This parameter defaults to the datacenter of the agent being queried.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2019-05-08 20:19:37 +00:00
|
|
|
- `cas` `(int: 0)` - Specifies to use a Check-And-Set operation. If the index is
|
|
|
|
0, Consul will only store the entry if it does not already exist. If the index is
|
|
|
|
non-zero, the entry is only set if the current index matches the `ModifyIndex`
|
2019-05-01 18:21:11 +00:00
|
|
|
of that entry.
|
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the config entry you apply.
|
|
|
|
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
|
2020-02-07 20:01:04 +00:00
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
### Sample Payload
|
|
|
|
|
2021-06-13 00:53:50 +00:00
|
|
|
```json
|
2019-05-01 18:21:11 +00:00
|
|
|
{
|
|
|
|
"Kind": "service-defaults",
|
|
|
|
"Name": "web",
|
2019-09-21 15:17:02 +00:00
|
|
|
"Protocol": "http"
|
2019-05-01 18:21:11 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2019-05-01 18:21:11 +00:00
|
|
|
$ curl \
|
|
|
|
--request PUT \
|
|
|
|
--data @payload \
|
|
|
|
http://127.0.0.1:8500/v1/config
|
|
|
|
```
|
|
|
|
|
|
|
|
## Get Configuration
|
|
|
|
|
|
|
|
This endpoint returns a specific config entry.
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | --------------------- | ------------------ |
|
|
|
|
| `GET` | `/config/:kind/:name` | `application/json` |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2022-03-30 21:16:26 +00:00
|
|
|
[blocking queries](/api-docs/features/blocking),
|
|
|
|
[consistency modes](/api-docs/features/consistency),
|
|
|
|
[agent caching](/api-docs/features/caching), and
|
2022-10-18 19:49:07 +00:00
|
|
|
[required ACLs](/api-docs/api-structure#authentication).
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | -------------------------- |
|
2019-05-01 18:21:11 +00:00
|
|
|
| `YES` | `all` | `none` | `service:read`<sup>1</sup> |
|
|
|
|
|
|
|
|
<sup>1</sup> The ACL required depends on the config entry kind being read:
|
|
|
|
|
2020-10-14 15:23:05 +00:00
|
|
|
| Config Entry Kind | Required ACL |
|
|
|
|
| ------------------- | ----------------- |
|
|
|
|
| ingress-gateway | `service:read` |
|
|
|
|
| proxy-defaults | `<none>` |
|
|
|
|
| service-defaults | `service:read` |
|
|
|
|
| service-intentions | `intentions:read` |
|
|
|
|
| service-resolver | `service:read` |
|
|
|
|
| service-router | `service:read` |
|
|
|
|
| service-splitter | `service:read` |
|
|
|
|
| terminating-gateway | `service:read` |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-01-15 17:29:35 +00:00
|
|
|
The corresponding CLI command is [`consul config read`](/commands/config/read).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `kind` `(string: <required>)` - Specifies the kind of the entry to read.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `name` `(string: <required>)` - Specifies the name of the entry to read.
|
|
|
|
The name of the `proxy-defaults` config entry
|
2021-05-04 21:32:07 +00:00
|
|
|
must be `global`, and the name of the `mesh` config entry must be `mesh`.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Query Parameters
|
|
|
|
|
|
|
|
- `dc` `(string: "")` - Specifies the datacenter to query.
|
|
|
|
This parameter defaults to the datacenter of the agent being queried.
|
|
|
|
|
|
|
|
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the config entry you lookup
|
|
|
|
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
|
2020-02-07 20:01:04 +00:00
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2019-05-01 18:21:11 +00:00
|
|
|
$ curl \
|
|
|
|
--request GET \
|
|
|
|
http://127.0.0.1:8500/v1/config/service-defaults/web
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2020-04-06 20:27:35 +00:00
|
|
|
"Kind": "service-defaults",
|
|
|
|
"Name": "web",
|
|
|
|
"Protocol": "http",
|
|
|
|
"CreateIndex": 15,
|
|
|
|
"ModifyIndex": 35
|
2019-05-01 18:21:11 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## List Configurations
|
|
|
|
|
|
|
|
This endpoint returns all config entries of the given kind.
|
|
|
|
|
2022-03-19 20:32:38 +00:00
|
|
|
@include 'http_api_results_filtered_by_acls.mdx'
|
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| ------ | --------------- | ------------------ |
|
|
|
|
| `GET` | `/config/:kind` | `application/json` |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2022-03-30 21:16:26 +00:00
|
|
|
[blocking queries](/api-docs/features/blocking),
|
|
|
|
[consistency modes](/api-docs/features/consistency),
|
|
|
|
[agent caching](/api-docs/features/caching), and
|
2022-10-18 19:49:07 +00:00
|
|
|
[required ACLs](/api-docs/api-structure#authentication).
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | -------------------------- |
|
2019-05-01 18:21:11 +00:00
|
|
|
| `YES` | `all` | `none` | `service:read`<sup>1</sup> |
|
|
|
|
|
|
|
|
<sup>1</sup> The ACL required depends on the config entry kind being read:
|
|
|
|
|
2020-10-14 15:23:05 +00:00
|
|
|
| Config Entry Kind | Required ACL |
|
|
|
|
| ------------------- | ----------------- |
|
|
|
|
| ingress-gateway | `service:read` |
|
|
|
|
| proxy-defaults | `<none>` |
|
|
|
|
| service-defaults | `service:read` |
|
|
|
|
| service-intentions | `intentions:read` |
|
|
|
|
| service-resolver | `service:read` |
|
|
|
|
| service-router | `service:read` |
|
|
|
|
| service-splitter | `service:read` |
|
|
|
|
| terminating-gateway | `service:read` |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-01-15 17:29:35 +00:00
|
|
|
The corresponding CLI command is [`consul config list`](/commands/config/list).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `kind` `(string: <required>)` - Specifies the kind of the entry to list.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Query Parameters
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `dc` `(string: "")` - Specifies the datacenter to query.
|
|
|
|
This parameter defaults to the datacenter of the agent being queried.
|
|
|
|
|
|
|
|
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the config entries you lookup.
|
|
|
|
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
|
2020-02-07 20:01:04 +00:00
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2019-05-01 18:21:11 +00:00
|
|
|
$ curl \
|
|
|
|
--request GET \
|
|
|
|
http://127.0.0.1:8500/v1/config/service-defaults
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sample Response
|
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
2020-04-06 20:27:35 +00:00
|
|
|
{
|
|
|
|
"Kind": "service-defaults",
|
|
|
|
"Name": "db",
|
|
|
|
"Protocol": "tcp",
|
|
|
|
"CreateIndex": 16,
|
|
|
|
"ModifyIndex": 16
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Kind": "service-defaults",
|
|
|
|
"Name": "web",
|
|
|
|
"Protocol": "http",
|
|
|
|
"CreateIndex": 13,
|
|
|
|
"ModifyIndex": 13
|
|
|
|
}
|
2019-05-01 18:21:11 +00:00
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
## Delete Configuration
|
|
|
|
|
2019-11-06 19:30:44 +00:00
|
|
|
This endpoint deletes the given config entry.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
| Method | Path | Produces |
|
|
|
|
| -------- | --------------------- | ------------------ |
|
|
|
|
| `DELETE` | `/config/:kind/:name` | `application/json` |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
The table below shows this endpoint's support for
|
2022-03-30 21:16:26 +00:00
|
|
|
[blocking queries](/api-docs/features/blocking),
|
|
|
|
[consistency modes](/api-docs/features/consistency),
|
|
|
|
[agent caching](/api-docs/features/caching), and
|
2022-10-18 19:49:07 +00:00
|
|
|
[required ACLs](/api-docs/api-structure#authentication).
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
|
|
|
|
| ---------------- | ----------------- | ------------- | ------------------------------------------------- |
|
|
|
|
| `NO` | `none` | `none` | `service:write`<br />`operator:write`<sup>1</sup> |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
<sup>1</sup> The ACL required depends on the config entry kind being deleted:
|
|
|
|
|
2020-10-14 15:23:05 +00:00
|
|
|
| Config Entry Kind | Required ACL |
|
2020-12-08 23:24:36 +00:00
|
|
|
| ------------------- | ------------------ |
|
2020-10-14 15:23:05 +00:00
|
|
|
| ingress-gateway | `operator:write` |
|
|
|
|
| proxy-defaults | `operator:write` |
|
|
|
|
| service-defaults | `service:write` |
|
|
|
|
| service-intentions | `intentions:write` |
|
|
|
|
| service-resolver | `service:write` |
|
|
|
|
| service-router | `service:write` |
|
|
|
|
| service-splitter | `service:write` |
|
2020-12-08 23:24:36 +00:00
|
|
|
| terminating-gateway | `operator:write ` |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-01-15 17:29:35 +00:00
|
|
|
The corresponding CLI command is [`consul config delete`](/commands/config/delete).
|
2022-01-10 19:21:32 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Path Parameters
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `kind` `(string: <required>)` - Specifies the kind of the entry to delete.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
- `name` `(string: <required>)` - Specifies the name of the entry to delete.
|
|
|
|
The name of the `proxy-defaults` config entry
|
2021-05-04 21:32:07 +00:00
|
|
|
must be `global`, and the name of the `mesh` config entry must be `mesh`.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2022-05-10 15:51:11 +00:00
|
|
|
### Query Parameters
|
|
|
|
|
|
|
|
- `dc` `(string: "")` - Specifies the datacenter to query.
|
|
|
|
This parameter defaults to the datacenter of the agent being queried.
|
2020-02-07 20:01:04 +00:00
|
|
|
|
2021-11-01 16:42:01 +00:00
|
|
|
- `cas` `(int: 0)` - Specifies to use a Check-And-Set operation. Unlike `PUT`,
|
|
|
|
the index must be greater than 0 for Consul to take any action: a 0 index will
|
|
|
|
not delete the config entry. If the index is non-zero, the config entry is only
|
2022-05-10 15:51:11 +00:00
|
|
|
deleted if the index matches the `ModifyIndex` of that config entry.
|
|
|
|
|
|
|
|
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the namespace of the config entry you delete.
|
|
|
|
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
|
2021-11-01 16:42:01 +00:00
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
### Sample Request
|
|
|
|
|
2020-05-19 18:32:38 +00:00
|
|
|
```shell-session
|
2019-05-01 18:21:11 +00:00
|
|
|
$ curl \
|
|
|
|
--request DELETE \
|
|
|
|
http://127.0.0.1:8500/v1/config/service-defaults/web
|
|
|
|
```
|
2022-05-10 15:51:11 +00:00
|
|
|
|
|
|
|
## Methods to Specify Namespace <EnterpriseAlert inline />
|
|
|
|
|
|
|
|
Config endpoints
|
|
|
|
support several methods for specifying the namespace of configuration entry resources
|
|
|
|
with the following order of precedence:
|
|
|
|
1. `ns` query parameter
|
|
|
|
1. `X-Consul-Namespace` request header
|
|
|
|
1. Namespace is inherited from the namespace of the request's ACL token (if any)
|
|
|
|
1. The `default` namespace
|