---
type: api
title: Create ruleset association
description: Applies the ruleset to the specified deployment.
url: https://www.elastic.co/docs/api/doc/cloud-enterprise/v3/operation/operation-create-traffic-filter-ruleset-association
resource: https://www.elastic.co/docs/api/doc/cloud-enterprise/v3/operation/operation-create-traffic-filter-ruleset-association
products:
  - Elastic Cloud Enterprise
---

# Create ruleset association

Authentication: required

## Paths

- `POST` `/deployments/traffic-filter/rulesets/{ruleset_id}/associations`

#### Path parameters

- `ruleset_id` (string) — required
  The mandatory ruleset ID.

## Description

Applies the ruleset to the specified deployment.

## Request body

Mandatory ruleset association description

`application/json`

- `entity_type` (string) — required
  Type of the traffic filter ruleset association, such as 'deployment', 'cluster'
- `id` (string) — required
  ID of the entity, such as the deployment ID or Elasticsearch cluster ID.

## Responses

#### `200`

Create association request was valid and the association already exists

`application/json`

Type: `object`

#### `201`

Create association request was valid and the association has been created

`application/json`

Type: `object`

#### `404`

The traffic filter ruleset specified by {ruleset_id} cannot be found. (code: `traffic_filter.not_found`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

#### `500`

Creation failed. (code: `traffic_filter.request_execution_failed`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

## Code examples

#### curl

```curl
curl -X POST "${API_URL}/deployments/traffic-filter/rulesets/${RULESET_ID}/associations" \
  -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{
    "entity_type": "string",
    "id": "string"
  }'
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{}
```

#### 201

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{}
```

#### 404

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "errors": [
    {
      "code": "string",
      "message": "string",
      "fields": [
        "string"
      ]
    }
  ]
}
```

#### 500

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "errors": [
    {
      "code": "string",
      "message": "string",
      "fields": [
        "string"
      ]
    }
  ]
}
```

