---
title: "Create a Security Group rule"
method: POST
path: "/security-group/{id}/rules"
tags: ["security-group"]
---

# Create a Security Group rule

`POST /security-group/{id}/rules`

## Request

- Base URL: `https://api-ch-gva-2.exoscale.com/v2`
- URL: `https://api-ch-gva-2.exoscale.com/v2/security-group/{id}/rules`
- Auth: none declared
- TypeScript: <https://skmtc.dev/exoscale/apis/exoscale-api/docs/security-group/:id/rules/post.ts> (a function with typed inputs; its response is checked against the schema)

## Path parameters

- `id` string, uuid, required

## Request body

- object
  - `flow-direction` 'ingress' | 'egress', required: Network flow direction to match
  - `description` string: Security Group rule description
  - `network` string: CIDR-formatted network allowed
  - `security-group` SecurityGroupResource: Security Group
    - `id` string, uuid: Security Group ID
    - `name` string: Security Group name
    - `visibility` 'private' | 'public': Whether this points to a public security group. This is only valid when in the context of a rule addition which uses a public security group as a source or destination.
  - `protocol` 'tcp' | 'esp' | 'icmp' | 'udp' | 'gre' | 'ah' | 'ipip' | 'icmpv6', required: Network protocol
  - `icmp` object: ICMP details (default: -1 (ANY))
    - `code` integer, nullable
    - `type` integer, nullable
  - `start-port` integer: Start port of the range
  - `end-port` integer: End port of the range

## Response `200`

200

- Operation: Operation
  - `id` string, uuid: Operation ID
  - `reason` 'incorrect' | 'unknown' | 'unavailable' | 'forbidden' | 'busy' | 'fault' | 'partial' | 'not-found' | 'interrupted' | 'unsupported' | 'conflict': Operation failure reason
  - `reference` object: Related resource reference
    - `id` string, uuid: Reference ID
    - `link` string: Link to the referenced resource
    - `command` string: Command name
  - `message` string: Operation message
  - `state` 'failure' | 'pending' | 'success' | 'timeout': Operation status

## Changes

- **2025-08-10** `814bf1ccd925`: 2 info
  - the request property `icmp/code` became nullable
  - the request property `icmp/type` became nullable
- **2023-02-03** `6e9809fd1444`: 1 breaking, 2 warning, 3 info
  - the `security-group/name` request property's minLength was increased from `0` to `1`
  - the `description` request property's maxLength was set to `255`
  - the `security-group/name` request property's maxLength was set to `255`
  - added the new optional request property `security-group/visibility`
  - …2 more

[Operation history](https://skmtc.dev/exoscale/apis/exoscale-api/changes/security-group/:id/rules/post.md)

---

[API](https://skmtc.dev/exoscale/apis/exoscale-api.md) - [All operations](https://skmtc.dev/exoscale/apis/exoscale-api/llms.txt) - [OpenAPI document](https://skmtc.dev/exoscale/apis/exoscale-api/revisions/63da6f74c845?raw)
