---
type: api
title: Create a ruleset
description: Creates a ruleset that consists of a set of rules.
url: https://www.elastic.co/docs/api/doc/cloud-enterprise/v4/operation/operation-create-traffic-filter-ruleset
resource: https://www.elastic.co/docs/api/doc/cloud-enterprise/v4/operation/operation-create-traffic-filter-ruleset
products:
  - Elastic Cloud Enterprise
---

# Create a ruleset

Authentication: required

## Paths

- `POST` `/deployments/traffic-filter/rulesets`

## Description

Creates a ruleset that consists of a set of rules.

## Request body

The specification for traffic filter ruleset.

`application/json`

- `name` (string) — required
  Name of the ruleset
- `description` (string) — optional
  Description of the ruleset
- `type` (string) — required
  Type of the ruleset
- `include_by_default` (boolean) — required
  Should the ruleset be automatically included in the new deployments
- `region` (string) — required
  The ruleset can be attached only to deployments in the specific region
- `rules` (object[]) — required
  List of rules
  - `id` (string) — optional
    The rule ID
  - `remote_cluster_org_id` (string) — optional
    The remote cluster organization ID
  - `remote_cluster_id` (string) — optional
    The remote cluster ID
  - `description` (string) — optional
    Description of the rule
  - `source` (string) — optional
    Allowed traffic filter source: IP address, CIDR mask, or VPC endpoint ID
  - `azure_endpoint_name` (string) — optional
    Name of the Azure Private Endpoint to allow connections from
  - `azure_endpoint_guid` (string) — optional
    Resource GUID of the Azure Private Endpoint to allow connections from
  - `egress_rule` (object) — optional
    The rule detail for a traffic filter egress rule.
    - `target` (string) — required
      Allowed traffic filter egress target: IP address or CIDR mask
    - `ports` (integer[] · format: int32) — optional
      A list of target ports for an egress rule
    - `protocol` (enum) — required
      The target protocol for an egress rule
      Values: `all`, `tcp`, `udp`

## Responses

#### `201`

The ruleset definition is valid and the creation has started.

`application/json`

- `id` (string)
  The new ruleset ID
#### `500`

Error creating the traffic filter ruleset. (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" \
  -u "${USERNAME}:${PASSWORD}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "string",
    "type": "string",
    "include_by_default": false,
    "region": "string",
    "rules": [
      {}
    ]
  }'
```

## Response examples

#### 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
{
  "id": "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"
      ]
    }
  ]
}
```

