# Update a Network Security Group

{% hint style="info" %}
**Note:** Only contract administrators, owners, and users with permissions to the VDC concerned can create and manage NSGs via API.
{% endhint %}

{% hint style="info" %}
**Prerequisite:** You need an IONOS Cloud account with API credentials configured with the appropriate permissions.
{% endhint %}

{% hint style="info" %}
**Note:** User-created Virtual Machines (VMs) can be Default or Custom NSG members, but you cannot add nodes from the Managed Kubernetes node pools or suspended Cubes.
{% endhint %}

To update a NSG, you need to use the following [<mark style="color:blue;">Cloud API</mark>](https://api.ionos.com/docs/cloud/) `PUT`or `PATCH` request providing the `datacenterId`, `securityGroupId`and the required properties:

`PUT(PATCH) /datacenters/{datacenterId}/securitygroups/{securityGroupId}`

### Request

```bash
curl --location --request PUT 'https://api.ionos.com/cloudapi/v6/datacenters/5a88aa8b-8aa1-51f6-XXd1-XXXXXe9f31/securitygroups/b3f55c2d-a89e-4008-8213-92e0428e2555' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic YYXabCDeFmLMO0c2hyYUBpb25vcy5jb206I1Bha2lzdGFuXzE=' \
--data '{
    "properties": {
        "name": "NSG",
        "description": "updated to true"
    }

}'
```

### Response

**202 Accepted**

```json
{
    "id": "bxxxx-axXX-0008-8888-99k0444e5555",
    "type": "security-group",
    "href": "https://api.ionos.com/cloudapi/v6/datacenters/5a88aa8b-8aa1-51f6-XXd1-XXXXXe9f31/securitygroups/bxxxx-axXX-0008-8888-99k0444e5555",
    "metadata": {
        "etag": "e15475860e9c6e1136ba1b2153297f31",
        "createdDate": "2024-05-17T15:11:11Z",
        "createdBy": "test.test@ionos.com",
        "createdByUserId": "a5af0375-1c1d-4387-9ef1-6ee95d30e54a",
        "lastModifiedDate": "2024-05-21T18:02:41Z",
        "lastModifiedBy": "test.test@ionos.com",
        "lastModifiedByUserId": "a5af0375-1c1d-4387-9ef1-6ee95d30e54a",
        "state": "BUSY"
    },
    "properties": {
        "name": "NSG",
        "description": "updated to true"
    },
    "entities": {
        "rules": {
            "id": "b3f55c2d-a89e-4008-8213-92e0428e2555/rules",
            "type": "collection",
            "href": "https://api.ionos.com/cloudapi/v6/datacenters/5a88aa8b-8aa1-51f6-XXd1-XXXXXe9f31/securitygroups/bxxxx-axXX-0008-8888-99k0444e5555/rules"
        },
        "servers": {
            "id": "b3f55c2d-a89e-4008-8213-92e0428e2555/servers",
            "type": "collection",
            "href": "https://api.ionos.com/cloudapi/v6/datacenters/5a88aa8b-8aa1-51f6-XXd1-XXXXXe9f31/securitygroups/bxxxx-axXX-0008-8888-99k0444e5555/servers"
        },
        "nics": {
            "id": "b3f55c2d-a89e-4008-8213-92e0428e2555/nics",
            "type": "collection",
            "href": "https://api.ionos.com/cloudapi/v6/datacenters/5a88aa8b-8aa1-51f6-XXd1-XXXXXe9f31/securitygroups/bxxxx-axXX-0008-8888-99k0444e5555/nics"
        }
    }
}
```

{% hint style="info" %}
**Note:** For CloudAPI, some resources are created asynchronously. You can check for the progress via the **Status URL** that is returned in the response header of the **POST** or **PUT** call.
{% endhint %}
