---
title: "Update security group"
method: PUT
path: "/v1/security-groups/{securityGroupId}"
tags: ["Security groups"]
---

# Update security group

`PUT /v1/security-groups/{securityGroupId}`

## Request

- Base URL: `https://api.emma.ms/external`
- URL: `https://api.emma.ms/external/v1/security-groups/{securityGroupId}`
- Auth: HTTP bearer

This method updates a security group.

A security group refers to a set of rules that determine what network traffic is allowed to enter or leave a particular compute instance. It acts as a virtual firewall, controlling inbound and outbound traffic based on predefined rules.

Security groups operate based on predefined rules that allow traffic based on specified criteria, such as source IP address, destination IP address, port number, and protocol.

When editing a security group, you can add and delete the inbound and outbound rules. You can only define rules that allow traffic, not deny it. All traffic is denied except for explicitly allowed traffic.

Security groups control TCP, UDP and ICMP protocols, or all the selected protocols at once.

Both IPv4 and IPv6 addresses are supported in the 'ipRange' field.

All traffic in the selected protocol is allowed if the IP range in a rule is set to `0.0.0.0/0`.

## Path parameters

- `securityGroupId` integer, required

## Request body

- SecurityGroupRequest
  - `name` string, required: Name of the security group
  - `rules` SecurityGroupRuleRequest[], required: List of the inbound and outbound rules in the Security group
    - `direction` 'INBOUND' | 'OUTBOUND', required: Direction of the network traffic
    - `protocol` 'all' | 'TCP' | 'UDP' | 'ICMP', required: Network protocol
    - `ports` string, required: Allowed port or port range
    - `ipRange` string, required: Allowed IP or IP range

## Response `200`

Successful operation

- SecurityGroup
  - `id` integer: Security group id
  - `name` string: Security group name
  - `createdById` integer: ID of the user who created the security group
  - `createdByName` string: Name of the user who created the security group
  - `modifiedById` integer: ID of the user who last edited the security group
  - `modifiedByName` string: Name of the user who last edited the security group
  - `createdAt` string: Date and time of the security group's creation
  - `modifiedAt` string: Date and time of the security group's last update
  - `synchronizationStatus` 'SYNCHRONIZED' | 'DESYNCHRONIZED' | 'SYNCHRONIZING': Synchronization status of the security group. When you make changes in the rules the changes are propagated to the respective provider’s security groups. While this is happening the security groups have the status Synchronizing. After it is done the status changes to Synchronized. When another VM is added to the security group it will not be synchronized at first with the other VMs, therefore the status will be Desynchronized.
  - `recomposingStatus` 'RECOMPOSED' | 'RECOMPOSING': Recomposing status of the security group. When a new Virtual machine is added to the Security group it starts a synchronization process. During this process the Security group will have a Recomposing status.
  - `lastModificationErrorDescription` string: Text of the error when the Security group was last edited
  - `rules` SecurityGroupRule[]: List of the inbound and outbound rules in the Security group
    - `type` string: Type of the security group rule
    - `policy` string: Rule policy (all rules are allowing)
    - `direction` string: Direction of the network traffic: inbound or outbound.
    - `protocol` string: Network protocol of the rule
    - `ports` string: Allowed port or port range
    - `ipRange` string: Allowed IP or IP range
    - `isMutable` boolean: Indicates if the rule can be edited. Some security group rules are added by default, cannot be changed, and are marked as immutable.

## Other responses

- `400`: Bad request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not found
- `409`: Conflict
- `500`: Internal server error

---

[API](https://skmtc.dev/emma/apis/public-emma-api.md) - [All operations](https://skmtc.dev/emma/apis/public-emma-api/llms.txt) - [OpenAPI document](https://skmtc.dev/emma/apis/public-emma-api/revisions/9e55f0920078?raw)
