2018-05-29 21:07:40 +00:00
---
layout: api
page_title: Intentions - Connect - HTTP API
description: |-
The /connect/intentions endpoint provide tools for managing intentions via
Consul's HTTP API.
---
# Intentions - Connect HTTP API
The `/connect/intentions` endpoint provide tools for managing
2023-01-25 16:52:43 +00:00
[intentions](/consul/docs/connect/intentions).
2018-05-29 21:07:40 +00:00
2020-10-14 15:23:05 +00:00
-> **1.9.0 and later:** Reading and writing intentions has been
migrated to the
2023-01-25 16:52:43 +00:00
[`service-intentions`](/consul/docs/connect/config-entries/service-intentions)
2020-10-14 15:23:05 +00:00
config entry kind.
2020-12-18 00:11:36 +00:00
## Upsert Intention by Name ((#upsert-intention-by-name))
2020-10-14 15:23:05 +00:00
-> **1.9.0+:** This API is available in Consul versions 1.9.0 and later.
This endpoint creates a new intention and returns `true` if it was created
successfully.
The name and destination pair must be unique. If another intention matches the
name and destination, the creation will replace the previous intention.
~> The intentions created by this endpoint will not be assigned the following
fields: `ID`, `CreatedAt`, `UpdatedAt`. Additionally, the `Meta` field cannot
be persisted using this endpoint and will require editing the enclosing
`service-intentions` config entry for the destination.
| Method | Path | Produces |
| ------ | --------------------------- | ------------------ |
| `PUT` | `/connect/intentions/exact` | `application/json` |
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2020-10-14 15:23:05 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ------------------------------ |
2023-03-24 22:16:06 +00:00
| `NO` | `none` | `none` | `intentions:write` <p> Define intention rules in the `service` policy. Refer to [ACL requirements for intentions](/consul/docs/connect/intentions/create-manage-intentions#acl-requirements) for additional information.</p> |
2020-10-14 15:23:05 +00:00
2023-01-25 16:52:43 +00:00
The corresponding CLI command is [`consul intention create -replace`](/consul/commands/intention/create#replace).
2022-01-10 19:21:32 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
- `source` `(string: <required>)` - Specifies the source service
2023-01-25 16:52:43 +00:00
according to the [source naming conventions](/consul/commands/intention#source-and-destination-naming).
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
- `destination` `(string: <required>)` - Specifies the destination service
2023-01-25 16:52:43 +00:00
according to the [destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the default namespace
to use when `source` or `destination` query parameters do not include a namespace
2023-01-25 16:52:43 +00:00
as shown in the [source and destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2022-05-10 15:51:11 +00:00
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
### JSON Request Body Schema
2020-10-14 15:23:05 +00:00
- `SourceType` `(string: "")` - The type for the `SourceName` value.
This can be only "consul" today to represent a Consul service. If not
provided, this will be defaulted to "consul".
- `Action` `(string: "")` - For an L4 intention this is required, and should be
set to one of "allow" or "deny" for the action that should be taken if
this intention matches a request.
This should be omitted for an L7 intention as it is mutually exclusive with
the `Permissions` field.
- `Permissions` `(array<IntentionPermission>)` - The list of all [additional L7
2023-01-25 16:52:43 +00:00
attributes](/consul/docs/connect/config-entries/service-intentions#intentionpermission)
2020-10-14 15:23:05 +00:00
that extend the intention match criteria.
Permission precedence is applied top to bottom. For any given request the
first permission to match in the list is terminal and stops further
evaluation. As with L4 intentions, traffic that fails to match any of the
provided permissions in this intention will be subject to the default
intention behavior is defined by the default [ACL
2023-01-25 16:52:43 +00:00
policy](/consul/docs/agent/config/config-files#acl_default_policy).
2020-10-14 15:23:05 +00:00
This should be omitted for an L4 intention as it is mutually exclusive with
the `Action` field.
- `Description` `(string: "")` - Description for the intention. This is not
used by Consul, but is presented in API responses to assist tooling.
### Sample Payload
```json
{
"SourceType": "consul",
"Action": "allow"
}
```
### Sample Request
```shell-session
$ curl \
--request PUT \
--data @payload.json \
2022-01-12 23:05:01 +00:00
"http://127.0.0.1:8500/v1/connect/intentions/exact?source=web&destination=db"
2020-10-14 15:23:05 +00:00
```
### Sample Response
```json
true
```
## Create Intention with ID
-> **Deprecated** - This endpoint is deprecated in Consul 1.9.0 in favor of
[upserting by name](#upsert-intention-by-name) or editing the
2023-01-25 16:52:43 +00:00
[`service-intentions`](/consul/docs/connect/config-entries/service-intentions) config
2020-10-14 15:23:05 +00:00
entry for the destination.
2018-05-29 21:07:40 +00:00
This endpoint creates a new intention and returns its ID if it was created
successfully.
The name and destination pair must be unique. If another intention matches
the name and destination, the creation will fail. You must either update the
existing intention or delete it prior to creating a new one.
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | --------------------- | ------------------ |
| `POST` | `/connect/intentions` | `application/json` |
2018-05-29 21:07:40 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2018-05-29 21:07:40 +00:00
2020-04-06 20:27:35 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ------------------------------ |
2023-03-24 22:16:06 +00:00
| `NO` | `none` | `none` | `intentions:write` <p> Define intention rules in the `service` policy. Refer to [ACL requirements for intentions](/consul/docs/connect/intentions/create-manage-intentions#acl-requirements) for additional information.</p> |
2018-05-29 21:07:40 +00:00
2023-01-25 16:52:43 +00:00
The corresponding CLI command is [`consul intention create`](/consul/commands/intention/create).
2022-01-10 19:21:32 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the default namespace
to use when `SourceNS` or `DestinationNS` request body parameters do not include a namespace
2023-01-25 16:52:43 +00:00
as shown in the [source and destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2022-05-10 15:51:11 +00:00
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
### JSON Request Body Schema
2018-05-29 21:07:40 +00:00
- `SourceName` `(string: <required>)` - The source of the intention.
For a `SourceType` of `consul` this is the name of a Consul service. The
2022-05-10 15:51:11 +00:00
service does not need to be registered.
2018-05-29 21:07:40 +00:00
2020-06-26 21:59:15 +00:00
- `SourceNS` `(string: "")` <EnterpriseAlert inline /> - The namespace for the
2020-07-08 23:09:00 +00:00
`SourceName` parameter.
2020-06-26 21:59:15 +00:00
2018-05-29 21:07:40 +00:00
- `DestinationName` `(string: <required>)` - The destination of the intention.
The intention destination is always a Consul service, unlike the source.
2022-05-10 15:51:11 +00:00
The service does not need to be registered.
2018-05-29 21:07:40 +00:00
2020-06-26 21:59:15 +00:00
- `DestinationNS` `(string: "")` <EnterpriseAlert inline /> - The namespace for the
2020-07-08 23:09:00 +00:00
`DestinationName` parameter.
2020-06-26 21:59:15 +00:00
2020-10-14 15:23:05 +00:00
- `SourceType` `(string: "")` - The type for the `SourceName` value.
This can be only "consul" today to represent a Consul service. If not
provided, this will be defaulted to "consul".
2018-05-29 21:07:40 +00:00
- `Action` `(string: <required>)` - This is one of "allow" or "deny" for
the action that should be taken if this intention matches a request.
2020-06-26 21:59:15 +00:00
- `Description` `(string: "")` - Description for the intention. This is not
2020-10-14 15:23:05 +00:00
used by Consul, but is presented in API responses to assist tooling.
2018-05-29 21:07:40 +00:00
- `Meta` `(map<string|string>: nil)` - Specifies arbitrary KV metadata pairs.
### Sample Payload
```json
{
"SourceName": "web",
"DestinationName": "db",
"SourceType": "consul",
"Action": "allow"
}
```
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2018-05-29 21:07:40 +00:00
$ curl \
--request POST \
--data @payload.json \
2018-08-28 16:07:15 +00:00
http://127.0.0.1:8500/v1/connect/intentions
2018-05-29 21:07:40 +00:00
```
### Sample Response
```json
{
"ID": "8f246b77-f3e1-ff88-5b48-8ec93abf3e05"
}
```
2020-10-14 15:23:05 +00:00
## Update Intention by ID
2018-05-29 21:07:40 +00:00
2020-10-14 15:23:05 +00:00
-> **Deprecated** - This endpoint is deprecated in Consul 1.9.0 in favor of
[upserting by name](#upsert-intention-by-name) or editing the
2023-01-25 16:52:43 +00:00
[`service-intentions`](/consul/docs/connect/config-entries/service-intentions) config
2020-10-14 15:23:05 +00:00
entry for the destination.
This endpoint updates an intention with the given values.
2018-05-29 21:07:40 +00:00
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | --------------------------- | ------------------ |
2020-10-14 15:23:05 +00:00
| `PUT` | `/connect/intentions/:uuid` | `application/json` |
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2020-10-14 15:23:05 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ------------------------------ |
2023-03-24 22:16:06 +00:00
| `NO` | `none` | `none` | `intentions:write`<p> Define intention rules in the `service` policy. Refer to [ACL requirements for intentions](/consul/docs/connect/intentions/create-manage-intentions#acl-requirements) for additional information.</p> |
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
This endpoint supports the same parameters as the [create an intention](#create-intention-with-id) endpoint.
Additional parameters unique to this endpoint include:
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
- `uuid` `(string: <required>)` - Specifies the UUID of the intention to update.
2020-10-14 15:23:05 +00:00
### Sample Payload
```json
{
"SourceName": "web",
"DestinationName": "other-db",
"SourceType": "consul",
"Action": "allow"
}
```
### Sample Request
```shell-session
$ curl \
--request PUT \
--data @payload.json \
http://127.0.0.1:8500/v1/connect/intentions/e9ebc19f-d481-42b1-4871-4d298d3acd5c
```
2020-12-18 00:11:36 +00:00
## Read Specific Intention by Name ((##read-specific-intention-by-name))
2020-10-14 15:23:05 +00:00
This endpoint reads a specific intention by its unique source and destination.
| Method | Path | Produces |
| ------ | --------------------------- | ------------------ |
| `GET` | `/connect/intentions/exact` | `application/json` |
2018-05-29 21:07:40 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2018-05-29 21:07:40 +00:00
2020-04-06 20:27:35 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ----------------------------- |
2023-03-24 22:16:06 +00:00
| `YES` | `all` | `none` | `intentions:read`<p> Define intention rules in the `service` policy. Refer to [ACL requirements for intentions](/consul/docs/connect/intentions/create-manage-intentions#acl-requirements) for additional information.</p> |
2018-05-29 21:07:40 +00:00
2023-01-25 16:52:43 +00:00
The corresponding CLI command is [`consul intention get`](/consul/commands/intention/get).
2022-01-10 19:21:32 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
2018-05-29 21:07:40 +00:00
2022-05-10 15:51:11 +00:00
- `source` `(string: <required>)` - Specifies the source service
2023-01-25 16:52:43 +00:00
according to the [source naming conventions](/consul/commands/intention#source-and-destination-naming).
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
- `destination` `(string: <required>)` - Specifies the destination service
2023-01-25 16:52:43 +00:00
according to the [destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2020-10-14 15:23:05 +00:00
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the default namespace
to use when `source` or `destination` query parameters do not include a namespace
2023-01-25 16:52:43 +00:00
as shown in the [source and destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2022-05-10 15:51:11 +00:00
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2018-05-29 21:07:40 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2018-05-29 21:07:40 +00:00
$ curl \
2020-10-14 15:23:05 +00:00
http://127.0.0.1:8500/v1/connect/intentions/exact?source=web&destination=db
2018-05-29 21:07:40 +00:00
```
### Sample Response
```json
{
"Description": "",
"SourceNS": "default",
"SourceName": "web",
"DestinationNS": "default",
"DestinationName": "db",
"SourceType": "consul",
"Action": "allow",
"Meta": {},
2018-06-07 04:18:32 +00:00
"Precedence": 9,
2018-05-29 21:07:40 +00:00
"CreateIndex": 11,
"ModifyIndex": 11
}
```
2020-10-14 15:23:05 +00:00
## Read Specific Intention by ID
2020-06-26 21:59:15 +00:00
2020-12-08 23:24:36 +00:00
-> **Deprecated** - This endpoint is deprecated in Consul 1.9.0 in favor of
[reading by name](#read-specific-intention-by-name) or by viewing the
2023-01-25 16:52:43 +00:00
[`service-intentions`](/consul/docs/connect/config-entries/service-intentions)
2020-10-14 15:23:05 +00:00
config entry for the destination.
This endpoint reads a specific intention.
2020-06-26 21:59:15 +00:00
| Method | Path | Produces |
| ------ | --------------------------- | ------------------ |
2020-10-14 15:23:05 +00:00
| `GET` | `/connect/intentions/:uuid` | `application/json` |
2020-06-26 21:59:15 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2020-06-26 21:59:15 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ----------------------------- |
2023-03-24 22:16:06 +00:00
| `YES` | `all` | `none` | `intentions:read`<p> Define intention rules in the `service` policy. Refer to [ACL requirements for intentions](/consul/docs/connect/intentions/create-manage-intentions#acl-requirements) for additional information.</p> |
2020-06-26 21:59:15 +00:00
2023-01-25 16:52:43 +00:00
The corresponding CLI command is [`consul intention get`](/consul/commands/intention/get).
2022-01-10 19:21:32 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
2020-06-26 21:59:15 +00:00
2022-05-10 15:51:11 +00:00
- `uuid` `(string: <required>)` - Specifies the UUID of the intention to read.
2020-06-26 21:59:15 +00:00
### Sample Request
```shell-session
$ curl \
2020-10-14 15:23:05 +00:00
http://127.0.0.1:8500/v1/connect/intentions/e9ebc19f-d481-42b1-4871-4d298d3acd5c
2020-06-26 21:59:15 +00:00
```
### Sample Response
```json
{
"ID": "e9ebc19f-d481-42b1-4871-4d298d3acd5c",
"Description": "",
"SourceNS": "default",
"SourceName": "web",
"DestinationNS": "default",
"DestinationName": "db",
"SourceType": "consul",
"Action": "allow",
"Meta": {},
"Precedence": 9,
"CreatedAt": "2018-05-21T16:41:27.977155457Z",
"UpdatedAt": "2018-05-21T16:41:27.977157724Z",
"CreateIndex": 11,
"ModifyIndex": 11
}
```
2018-05-29 21:07:40 +00:00
## List Intentions
This endpoint lists all intentions.
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` | `/connect/intentions` | `application/json` |
2018-05-29 21:07:40 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2018-05-29 21:07:40 +00:00
2020-04-06 20:27:35 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ----------------------------- |
2023-03-24 22:16:06 +00:00
| `YES` | `all` | `none` | `intentions:read`<p> Define intention rules in the `service` policy. Refer to [ACL requirements for intentions](/consul/docs/connect/intentions/create-manage-intentions#acl-requirements) for additional information.</p> |
2018-05-29 21:07:40 +00:00
2023-01-25 16:52:43 +00:00
The corresponding CLI command is [`consul intention list`](/consul/commands/intention/list).
2022-01-10 19:21:32 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
2020-04-07 15:48:44 +00:00
- `filter` `(string: "")` - Specifies the expression used to filter the
queries results prior to returning the data.
2020-07-08 23:09:00 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the
namespace to list intentions from.
2020-06-26 21:59:15 +00:00
The `*` wildcard may be used to list intentions from all namespaces.
2022-05-10 15:51:11 +00:00
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2020-06-26 21:59:15 +00:00
2018-05-29 21:07:40 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2018-05-29 21:07:40 +00:00
$ curl \
2020-04-07 15:48:44 +00:00
'http://127.0.0.1:8500/v1/connect/intentions?filter=SourceName==web'
2018-05-29 21:07:40 +00:00
```
### Sample Response
```json
[
{
"Description": "",
"SourceNS": "default",
"SourceName": "web",
"DestinationNS": "default",
"DestinationName": "db",
"SourceType": "consul",
"Action": "allow",
"Meta": {},
2018-06-07 04:18:32 +00:00
"Precedence": 9,
2018-05-29 21:07:40 +00:00
"CreateIndex": 11,
"ModifyIndex": 11
}
]
```
2020-04-07 15:48:44 +00:00
### Filtering
The filter will be executed against each Intention in the result list with
the following selectors and filter operations being supported:
2020-04-13 17:38:44 +00:00
| Selector | Supported Operations |
| ----------------- | -------------------------------------------------- |
| `Action` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Description` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `DestinationNS` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `DestinationName` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `ID` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Meta` | Is Empty, Is Not Empty, In, Not In |
| `Meta.<any>` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `Precedence` | Equal, Not Equal |
| `SourceNS` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `SourceName` | Equal, Not Equal, In, Not In, Matches, Not Matches |
| `SourceType` | Equal, Not Equal, In, Not In, Matches, Not Matches |
2020-04-07 15:48:44 +00:00
2020-12-18 00:11:36 +00:00
## Delete Intention by Name ((#delete-intention-by-name))
2018-05-29 21:07:40 +00:00
2020-10-14 15:23:05 +00:00
-> **1.9.0+:** This API is available in Consul versions 1.9.0 and later.
2018-05-29 21:07:40 +00:00
2020-10-14 15:23:05 +00:00
This endpoint deletes a specific intention by its unique source and destination.
| Method | Path | Produces |
| -------- | --------------------------- | ------------------ |
| `DELETE` | `/connect/intentions/exact` | `application/json` |
2018-05-29 21:07:40 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2018-05-29 21:07:40 +00:00
2020-12-08 23:24:36 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ------------------------------ |
2023-03-24 22:16:06 +00:00
| `NO` | `none` | `none` | `intentions:write`<p> Define intention rules in the `service` policy. Refer to [ACL requirements for intentions](/consul/docs/connect/intentions/create-manage-intentions#acl-requirements) for additional information.</p> |
2018-05-29 21:07:40 +00:00
2023-01-25 16:52:43 +00:00
The corresponding CLI command is [`consul intention delete`](/consul/commands/intention/delete).
2022-01-10 19:21:32 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
2018-05-29 21:07:40 +00:00
2022-05-10 15:51:11 +00:00
- `source` `(string: <required>)` - Specifies the source service
2023-01-25 16:52:43 +00:00
according to the [source naming conventions](/consul/commands/intention#source-and-destination-naming).
2018-05-29 21:07:40 +00:00
2022-05-10 15:51:11 +00:00
- `destination` `(string: <required>)` - Specifies the destination service
2023-01-25 16:52:43 +00:00
according to the [destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2018-05-29 21:07:40 +00:00
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the default namespace
to use when `source` or `destination` query parameters do not include a namespace
2023-01-25 16:52:43 +00:00
as shown in the [source and destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2022-05-10 15:51:11 +00:00
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2018-05-29 21:07:40 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2018-05-29 21:07:40 +00:00
$ curl \
2020-10-14 15:23:05 +00:00
--request DELETE \
http://127.0.0.1:8500/v1/connect/intentions/exact?source=web&destination=db
2018-05-29 21:07:40 +00:00
```
2020-10-14 15:23:05 +00:00
## Delete Intention by ID
-> **Deprecated** - This endpoint is deprecated in Consul 1.9.0 in favor of
[deleting by name](#delete-intention-by-name) or editing the
2023-01-25 16:52:43 +00:00
[`service-intentions`](/consul/docs/connect/config-entries/service-intentions) config
2020-10-14 15:23:05 +00:00
entry for the destination.
2018-05-29 21:07:40 +00:00
This endpoint deletes a specific intention.
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| -------- | --------------------------- | ------------------ |
| `DELETE` | `/connect/intentions/:uuid` | `application/json` |
2018-05-29 21:07:40 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2018-05-29 21:07:40 +00:00
2020-04-06 20:27:35 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ------------------------------ |
2023-03-24 22:16:06 +00:00
| `NO` | `none` | `none` | `intentions:write`<p> Define intention rules in the `service` policy. Refer to [ACL requirements for intentions](/consul/docs/connect/intentions/create-manage-intentions#acl-requirements) for additional information.</p> |
2018-05-29 21:07:40 +00:00
2023-01-25 16:52:43 +00:00
The corresponding CLI command is [`consul intention delete`](/consul/commands/intention/delete).
2022-01-10 19:21:32 +00:00
2022-05-10 15:51:11 +00:00
### Path Parameters
2018-05-29 21:07:40 +00:00
2022-05-10 15:51:11 +00:00
- `uuid` `(string: <required>)` - Specifies the UUID of the intention to delete.
2018-05-29 21:07:40 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2018-05-29 21:07:40 +00:00
$ curl \
--request DELETE \
2018-08-28 16:07:15 +00:00
http://127.0.0.1:8500/v1/connect/intentions/e9ebc19f-d481-42b1-4871-4d298d3acd5c
2018-05-29 21:07:40 +00:00
```
## Check Intention Result
This endpoint evaluates the intentions for a specific source and destination
2020-10-14 15:23:05 +00:00
and returns whether the connection would be authorized or not given the current
Consul configuration and set of intentions.
2021-06-16 20:13:32 +00:00
-> **Note:** This endpoint will always evaluate intentions with `Permissions`
2020-12-08 23:24:36 +00:00
defined as _deny_ intentions during. This endpoint is only suited for
2020-10-14 15:23:05 +00:00
networking layer 4 (e.g. TCP) integration.
For performance and reliability reasons it is desirable to implement intention
enforcement by listing [intentions that match the
2023-01-25 16:52:43 +00:00
destination](/consul/api-docs/connect/intentions#list-matching-intentions) and representing
2020-10-14 15:23:05 +00:00
them in the native configuration of the proxy itself (such as RBAC for Envoy).
2018-05-29 21:07:40 +00:00
This endpoint will work even if the destination service has
`intention = "deny"` specifically set, because the resulting API response
does not contain any information about the intention itself.
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | --------------------------- | ------------------ |
| `GET` | `/connect/intentions/check` | `application/json` |
2018-05-29 21:07:40 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2018-05-29 21:07:40 +00:00
2020-04-06 20:27:35 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | ------------- | ----------------------------- |
2023-03-24 22:16:06 +00:00
| `NO` | `none` | `none` | `intentions:read`<p> Define intention rules in the `service` policy. Refer to [ACL requirements for intentions](/consul/docs/connect/intentions/create-manage-intentions#acl-requirements) for additional information.</p> |
2018-05-29 21:07:40 +00:00
2023-01-25 16:52:43 +00:00
The corresponding CLI command is [`consul intention check`](/consul/commands/intention/check).
2022-01-10 19:21:32 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
2018-05-29 21:07:40 +00:00
2022-05-10 15:51:11 +00:00
- `source` `(string: <required>)` - Specifies the source service
2023-01-25 16:52:43 +00:00
according to the [source naming conventions](/consul/commands/intention#source-and-destination-naming).
2018-05-29 21:07:40 +00:00
2022-05-10 15:51:11 +00:00
- `destination` `(string: <required>)` - Specifies the destination service
2023-01-25 16:52:43 +00:00
according to the [destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2020-06-26 21:59:15 +00:00
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the default namespace
to use when `source` or `destination` query parameters do not include a namespace
2023-01-25 16:52:43 +00:00
as shown in the [source and destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2022-05-10 15:51:11 +00:00
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2018-05-29 21:07:40 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2018-05-29 21:07:40 +00:00
$ curl \
2022-01-12 23:05:01 +00:00
"http://127.0.0.1:8500/v1/connect/intentions/check?source=web&destination=db"
2018-05-29 21:07:40 +00:00
```
### Sample Response
```json
{
"Allowed": true
}
```
- `Allowed` is true if the connection would be allowed, false otherwise.
## List Matching Intentions
This endpoint lists the intentions that match a given source or destination.
The intentions in the response are in evaluation order.
2020-04-06 20:27:35 +00:00
| Method | Path | Produces |
| ------ | --------------------------- | ------------------ |
| `GET` | `/connect/intentions/match` | `application/json` |
2018-05-29 21:07:40 +00:00
The table below shows this endpoint's support for
2023-01-25 16:52:43 +00:00
[blocking queries](/consul/api-docs/features/blocking),
[consistency modes](/consul/api-docs/features/consistency),
[agent caching](/consul/api-docs/features/caching), and
[required ACLs](/consul/api-docs/api-structure#authentication).
2018-05-29 21:07:40 +00:00
2020-10-14 15:23:05 +00:00
| Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
| ---------------- | ----------------- | -------------------- | ----------------------------- |
2023-03-24 22:16:06 +00:00
| `YES` | `all` | `background refresh` | `intentions:read`<p> Define intention rules in the `service` policy. Refer to [ACL requirements for intentions](/consul/docs/connect/intentions/create-manage-intentions#acl-requirements) for additional information.</p> |
2018-05-29 21:07:40 +00:00
2023-01-25 16:52:43 +00:00
The corresponding CLI command is [`consul intention match`](/consul/commands/intention/match).
2022-01-10 19:21:32 +00:00
2022-05-10 15:51:11 +00:00
### Query Parameters
2018-05-29 21:07:40 +00:00
- `by` `(string: <required>)` - Specifies whether to match the "name" value
by "source" or "destination".
2022-05-10 15:51:11 +00:00
- `name` `(string: <required>)` - Specifies a name to match
2023-01-25 16:52:43 +00:00
according to the [source and destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2022-05-10 15:51:11 +00:00
You can repeat this parameter for batching multiple matches.
2020-06-26 21:59:15 +00:00
2022-05-10 15:51:11 +00:00
- `ns` `(string: "")` <EnterpriseAlert inline /> - Specifies the default namespace
to use when the `name` query parameter does not include a namespace
2023-01-25 16:52:43 +00:00
as shown in the [source and destination naming conventions](/consul/commands/intention#source-and-destination-naming).
2022-05-10 15:51:11 +00:00
You can also [specify the namespace through other methods](#methods-to-specify-namespace).
2018-05-29 21:07:40 +00:00
### Sample Request
2020-05-19 18:32:38 +00:00
```shell-session
2018-05-29 21:07:40 +00:00
$ curl \
2022-01-12 23:05:01 +00:00
"http://127.0.0.1:8500/v1/connect/intentions/match?by=source&name=web"
2018-05-29 21:07:40 +00:00
```
### Sample Response
```json
{
"web": [
{
"Description": "",
"SourceNS": "default",
"SourceName": "web",
"DestinationNS": "default",
"DestinationName": "db",
"SourceType": "consul",
"Action": "deny",
"Meta": {},
"CreateIndex": 12,
"ModifyIndex": 12
},
{
"Description": "",
"SourceNS": "default",
"SourceName": "web",
"DestinationNS": "default",
"DestinationName": "*",
"SourceType": "consul",
"Action": "allow",
"Meta": {},
"CreateIndex": 11,
"ModifyIndex": 11
}
]
}
```
2022-05-10 15:51:11 +00:00
## Methods to Specify Namespace <EnterpriseAlert inline />
Connect intention endpoints
support several methods for specifying the namespace of intention 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