2019-05-01 18:21:11 +00:00
|
|
|
---
|
|
|
|
layout: api
|
|
|
|
page_title: Config - HTTP API
|
2020-04-07 18:55:19 +00:00
|
|
|
sidebar_title: 'Config'
|
2019-05-01 18:21:11 +00:00
|
|
|
sidebar_current: api-config
|
|
|
|
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
|
|
|
|
[agent configuration](/docs/agent/options.html#enable_central_service_config)
|
2019-05-08 20:19:37 +00:00
|
|
|
for more information on how to enable this functionality for centrally
|
|
|
|
configuring services and [configuration entries docs](/docs/agent/config_entries.html) for a description
|
|
|
|
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
|
|
|
|
[blocking queries](/api/features/blocking.html),
|
|
|
|
[consistency modes](/api/features/consistency.html),
|
|
|
|
[agent caching](/api/features/caching.html), and
|
|
|
|
[required ACLs](/api/index.html#authentication).
|
|
|
|
|
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
|
|
|
|
|
|
|
| Config Entry Kind | Required ACL |
|
|
|
|
| ----------------- | ---------------- |
|
|
|
|
| service-defaults | `service:write` |
|
|
|
|
| proxy-defaults | `operator:write` |
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
- `dc` `(string: "")` - Specifies the datacenter to query. This will default to
|
|
|
|
the datacenter of the agent being queried. This is specified as part of the
|
|
|
|
URL as a query parameter.
|
|
|
|
|
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.
|
|
|
|
|
2020-03-09 20:51:21 +00:00
|
|
|
- `ns` `(string: "")` - **(Enterprise Only)** Specifies the namespace the config
|
2020-04-06 20:27:35 +00:00
|
|
|
entry will apply to. This value may be provided by either the `ns` URL query
|
|
|
|
parameter or in the `X-Consul-Namespace` header. If not provided at all,
|
|
|
|
the namespace will be inherited from the request's ACL token or will default
|
2020-02-07 20:01:04 +00:00
|
|
|
to the `default` namespace. Added in Consul 1.7.0.
|
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
### Sample Payload
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
|
|
|
"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
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ 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
|
|
|
|
[blocking queries](/api/features/blocking.html),
|
|
|
|
[consistency modes](/api/features/consistency.html),
|
|
|
|
[agent caching](/api/features/caching.html), and
|
|
|
|
[required ACLs](/api/index.html#authentication).
|
|
|
|
|
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-04-06 20:27:35 +00:00
|
|
|
| Config Entry Kind | Required ACL |
|
|
|
|
| ----------------- | -------------- |
|
|
|
|
| service-defaults | `service:read` |
|
|
|
|
| proxy-defaults | `<none>` |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
- `dc` `(string: "")` - Specifies the datacenter to query. This will default to
|
|
|
|
the datacenter of the agent being queried. This is specified as part of the
|
|
|
|
URL as a query parameter.
|
|
|
|
|
|
|
|
- `kind` `(string: <required>)` - Specifies the kind of the entry to read. This
|
2019-05-08 20:19:37 +00:00
|
|
|
is specified as part of the URL.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
- `name` `(string: <required>)` - Specifies the name of the entry to read. This
|
2019-05-08 20:19:37 +00:00
|
|
|
is specified as part of the URL.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
- `ns` `(string: "")` - **(Enterprise Only)** Specifies the namespace to query.
|
|
|
|
This value may be provided by either the `ns` URL query parameter or in the
|
|
|
|
`X-Consul-Namespace` header. If not provided at all, the namespace will be inherited from
|
2020-03-09 20:51:21 +00:00
|
|
|
the request's ACL token or will default to the `default` namespace. Added in Consul 1.7.0.
|
2020-02-07 20:01:04 +00:00
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
### Sample Request
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ 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.
|
|
|
|
|
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
|
|
|
|
[blocking queries](/api/features/blocking.html),
|
|
|
|
[consistency modes](/api/features/consistency.html),
|
|
|
|
[agent caching](/api/features/caching.html), and
|
|
|
|
[required ACLs](/api/index.html#authentication).
|
|
|
|
|
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-04-06 20:27:35 +00:00
|
|
|
| Config Entry Kind | Required ACL |
|
|
|
|
| ----------------- | -------------- |
|
|
|
|
| service-defaults | `service:read` |
|
|
|
|
| proxy-defaults | `<none>` |
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
- `dc` `(string: "")` - Specifies the datacenter to query. This will default to
|
|
|
|
the datacenter of the agent being queried. This is specified as part of the
|
|
|
|
URL as a query parameter.
|
|
|
|
|
|
|
|
- `kind` `(string: <required>)` - Specifies the kind of the entry to list. This
|
2019-05-08 20:19:37 +00:00
|
|
|
is specified as part of the URL.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
- `ns` `(string: "")` - **(Enterprise Only)** Specifies the namespace to query.
|
|
|
|
This value may be provided by either the `ns` URL query parameter or in the
|
|
|
|
`X-Consul-Namespace` header. If not provided at all, the namespace will be inherited from
|
2020-03-09 20:51:21 +00:00
|
|
|
the request's ACL token or will default to the `default` namespace. Added in Consul 1.7.0.
|
2020-02-07 20:01:04 +00:00
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
### Sample Request
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ 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
|
|
|
|
[blocking queries](/api/features/blocking.html),
|
|
|
|
[consistency modes](/api/features/consistency.html),
|
|
|
|
[agent caching](/api/features/caching.html), and
|
|
|
|
[required ACLs](/api/index.html#authentication).
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
| Config Entry Kind | Required ACL |
|
|
|
|
| ----------------- | ---------------- |
|
|
|
|
| service-defaults | `service:write` |
|
|
|
|
| proxy-defaults | `operator:write` |
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
|
|
|
- `dc` `(string: "")` - Specifies the datacenter to query. This will default to
|
|
|
|
the datacenter of the agent being queried. This is specified as part of the
|
|
|
|
URL as a query parameter.
|
|
|
|
|
|
|
|
- `kind` `(string: <required>)` - Specifies the kind of the entry to delete. This
|
2019-05-08 20:19:37 +00:00
|
|
|
is specified as part of the URL.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
|
|
|
- `name` `(string: <required>)` - Specifies the name of the entry to delete. This
|
2019-05-08 20:19:37 +00:00
|
|
|
is specified as part of the URL.
|
2019-05-01 18:21:11 +00:00
|
|
|
|
2020-04-06 20:27:35 +00:00
|
|
|
- `ns` `(string: "")` - **(Enterprise Only)** Specifies the namespace to delete from.
|
|
|
|
This value may be provided by either the `ns` URL query parameter or in the
|
2020-03-09 20:51:21 +00:00
|
|
|
`X-Consul-Namespace` header. If not provided at all, the namespace will be inherited
|
|
|
|
from the request's ACL token or will default to the `default` namespace. Added in Consul 1.7.0.
|
2020-02-07 20:01:04 +00:00
|
|
|
|
2019-05-01 18:21:11 +00:00
|
|
|
### Sample Request
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ curl \
|
|
|
|
--request DELETE \
|
|
|
|
http://127.0.0.1:8500/v1/config/service-defaults/web
|
|
|
|
```
|