---
title: "Güvenlik grupları — API başvurusu"
description: "Ağ güvenlik duvarı ek hizmeti olan sunucular için yeniden kullanılabilir izin listeleri (AWS security group modeli). Sunucu başına en çok 5 grup; Gyro"
url: https://www.gyrohosting.com/developers/tr/api/security-groups.html
language: tr
openapi: https://www.gyrohosting.com/developers/openapi.json
api_version: 2.30.0
---

# Güvenlik grupları

Ağ güvenlik duvarı ek hizmeti olan sunucular için yeniden kullanılabilir izin listeleri (AWS security group modeli). Sunucu başına en çok 5 grup; Gyro kuralları ve gelişmiş sıralı kurallarınızdan sonra değerlendirilir; grup olup gelişmiş kural yoksa gelen trafik varsayılan olarak kapalıdır. Kurallar sunucunun kural hakkından düşer. SSH/RDP erişimini kesebilecek değişiklik 5 dakikalık deneme olarak uygulanır: onaylayın.

Base URL: `https://www.gyrohosting.com/api/v1/client` · OpenAPI: https://www.gyrohosting.com/developers/openapi.json


## GET /cloud/security-groups

**Güvenlik gruplarını listele** · operationId `listSecurityGroups` · scope `cloud_read` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/listSecurityGroups.json




### Yanıtlar

- **200**: Groups
- **401**: Missing, invalid or revoked key

### Örnekler

```bash
curl -s 'https://www.gyrohosting.com/api/v1/client/cloud/security-groups' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro security-group list
```
```hcl
# kaynak gyro_security_group: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/security_group
# Reusable allow lists (AWS security group model). Stateful: replies to allowed connections pass automatically.
resource "gyro_security_group" "web" {
  name        = "web"
  description = "HTTP/HTTPS for everyone"

  rule {
    type = "http"
  }
  rule {
    type = "https"
  }
}

resource "gyro_security_group" "admin" {
  name = "admin"

  rule {
    type        = "ssh"
    source      = ["203.0.113.10/32"]
    description = "office"
  }
  rule {
    type   = "custom_tcp"
    port   = "8000-8100"
    source = ["198.51.100.0/24"]
  }
  # outbound: a group without outbound rules does not restrict outbound traffic
  rule {
    direction = "out"
    type      = "all"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.get("https://www.gyrohosting.com/api/v1/client/cloud/security-groups", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/security-groups", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## POST /cloud/security-groups

**Güvenlik grubu oluştur** · operationId `createSecurityGroup` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/createSecurityGroup.json

Ad hesap içinde benzersiz (2-64 karakter). `rules` verilmezse grupta tek giden kural (tüm trafik) olur, gelen kural olmaz.


### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `name` (zorunlu) | string |  |
| `description` | string |  |
| `rules` | array<SecurityGroupRule> |  |

### Yanıtlar

- **201**: Created
- **401**: Missing, invalid or revoked key
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X POST 'https://www.gyrohosting.com/api/v1/client/cloud/security-groups' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "string", "description": "string", "rules": [{"id": "string", "direction": "in", "type": "ssh", "protocol": "tcp", "port": "8080", "source": ["203.0.113.10/32"], "description": "string"}]}'
```
```bash
gyro security-group create --help    # tüm seçenekler
```
```hcl
# kaynak gyro_security_group: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/security_group
# Reusable allow lists (AWS security group model). Stateful: replies to allowed connections pass automatically.
resource "gyro_security_group" "web" {
  name        = "web"
  description = "HTTP/HTTPS for everyone"

  rule {
    type = "http"
  }
  rule {
    type = "https"
  }
}

resource "gyro_security_group" "admin" {
  name = "admin"

  rule {
    type        = "ssh"
    source      = ["203.0.113.10/32"]
    description = "office"
  }
  rule {
    type   = "custom_tcp"
    port   = "8000-8100"
    source = ["198.51.100.0/24"]
  }
  # outbound: a group without outbound rules does not restrict outbound traffic
  rule {
    direction = "out"
    type      = "all"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.post("https://www.gyrohosting.com/api/v1/client/cloud/security-groups", headers=h, json={"name": "string", "description": "string", "rules": [{"id": "string", "direction": "in", "type": "ssh", "protocol": "tcp", "port": "8080", "source": ["203.0.113.10/32"], "description": "string"}]}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/security-groups", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"name": "string", "description": "string", "rules": [{"id": "string", "direction": "in", "type": "ssh", "protocol": "tcp", "port": "8080", "source": ["203.0.113.10/32"], "description": "string"}]}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## GET /cloud/security-groups/{sg}

**Güvenlik grubunu getir** · operationId `getSecurityGroup` · scope `cloud_read` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/getSecurityGroup.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `sg` (zorunlu) | path | string |  |

### Yanıtlar

- **200**: Group
- **401**: Missing, invalid or revoked key
- **404**: Not found — also returned for objects owned by someone else

### Örnekler

```bash
curl -s 'https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro security-group get
```
```hcl
# kaynak gyro_security_group: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/security_group
# Reusable allow lists (AWS security group model). Stateful: replies to allowed connections pass automatically.
resource "gyro_security_group" "web" {
  name        = "web"
  description = "HTTP/HTTPS for everyone"

  rule {
    type = "http"
  }
  rule {
    type = "https"
  }
}

resource "gyro_security_group" "admin" {
  name = "admin"

  rule {
    type        = "ssh"
    source      = ["203.0.113.10/32"]
    description = "office"
  }
  rule {
    type   = "custom_tcp"
    port   = "8000-8100"
    source = ["198.51.100.0/24"]
  }
  # outbound: a group without outbound rules does not restrict outbound traffic
  rule {
    direction = "out"
    type      = "all"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.get("https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## PATCH /cloud/security-groups/{sg}

**Güvenlik grubunun adını / açıklamasını değiştir** · operationId `updateSecurityGroup` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/updateSecurityGroup.json

Yalnız görünen ad ve açıklama değişir; grup kimliği ve kuralları aynı kalır.


### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `sg` (zorunlu) | path | string |  |

### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `name` | string |  |
| `description` | string |  |

### Yanıtlar

- **200**: Group
- **401**: Missing, invalid or revoked key
- **404**: Not found — also returned for objects owned by someone else
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X PATCH 'https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "string", "description": "string"}'
```
```bash
gyro security-group update --help    # tüm seçenekler
```
```hcl
# kaynak gyro_security_group: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/security_group
# Reusable allow lists (AWS security group model). Stateful: replies to allowed connections pass automatically.
resource "gyro_security_group" "web" {
  name        = "web"
  description = "HTTP/HTTPS for everyone"

  rule {
    type = "http"
  }
  rule {
    type = "https"
  }
}

resource "gyro_security_group" "admin" {
  name = "admin"

  rule {
    type        = "ssh"
    source      = ["203.0.113.10/32"]
    description = "office"
  }
  rule {
    type   = "custom_tcp"
    port   = "8000-8100"
    source = ["198.51.100.0/24"]
  }
  # outbound: a group without outbound rules does not restrict outbound traffic
  rule {
    direction = "out"
    type      = "all"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.patch("https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1", headers=h, json={"name": "string", "description": "string"}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1", {
  method: "PATCH",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"name": "string", "description": "string"}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## DELETE /cloud/security-groups/{sg}

**Güvenlik grubunu sil** · operationId `deleteSecurityGroup` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/deleteSecurityGroup.json

Yalnız hiçbir sunucuya bağlı olmayan grup (422 err_sg_attached).


### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `sg` (zorunlu) | path | string |  |

### Yanıtlar

- **200**: Deleted
- **401**: Missing, invalid or revoked key
- **404**: Not found — also returned for objects owned by someone else
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X DELETE 'https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro security-group delete
```
```hcl
# kaynak gyro_security_group: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/security_group
# Reusable allow lists (AWS security group model). Stateful: replies to allowed connections pass automatically.
resource "gyro_security_group" "web" {
  name        = "web"
  description = "HTTP/HTTPS for everyone"

  rule {
    type = "http"
  }
  rule {
    type = "https"
  }
}

resource "gyro_security_group" "admin" {
  name = "admin"

  rule {
    type        = "ssh"
    source      = ["203.0.113.10/32"]
    description = "office"
  }
  rule {
    type   = "custom_tcp"
    port   = "8000-8100"
    source = ["198.51.100.0/24"]
  }
  # outbound: a group without outbound rules does not restrict outbound traffic
  rule {
    direction = "out"
    type      = "all"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.delete("https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1", {
  method: "DELETE",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## PUT /cloud/security-groups/{sg}/rules

**Güvenlik grubunun kurallarını değiştir** · operationId `putSecurityGroupRules` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/putSecurityGroupRules.json

Tam değiştirme (gelen + giden), en çok 60 kural. Bağlı tüm sunuculara uygulanır. Bağlı bir sunucuda herhangi bir kaynağın SSH (22) / RDP (3389) erişimini kaldırıyor ya da daraltıyorsa veya çağıran adresi kesiyorsa 5 dakikalık deneme olur (`trial: true`, `trial_seconds_left`) - panel, CLI ve Terraform ile aynı kural: .../confirm ile onaylayın, yoksa önceki kurallar döner. Sunucunun kuralları (kendi + bağlı tüm gruplar) hakkına sığmalı (422 err_sg_quota).


### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `sg` (zorunlu) | path | string |  |

### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `rules` (zorunlu) | array<SecurityGroupRule> |  |

### Yanıtlar

- **200**: Group (trial, corrections)
- **401**: Missing, invalid or revoked key
- **404**: Not found — also returned for objects owned by someone else
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X PUT 'https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1/rules' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"rules": [{"type": "https", "source": ["0.0.0.0/0"]}, {"type": "ssh", "source": ["203.0.113.10/32"], "description": "office"}, {"direction": "out", "type": "all", "source": ["0.0.0.0/0"]}]}'
```
```bash
gyro security-group rules set --help    # tüm seçenekler
```
```hcl
# kaynak gyro_security_group: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/security_group
# Reusable allow lists (AWS security group model). Stateful: replies to allowed connections pass automatically.
resource "gyro_security_group" "web" {
  name        = "web"
  description = "HTTP/HTTPS for everyone"

  rule {
    type = "http"
  }
  rule {
    type = "https"
  }
}

resource "gyro_security_group" "admin" {
  name = "admin"

  rule {
    type        = "ssh"
    source      = ["203.0.113.10/32"]
    description = "office"
  }
  rule {
    type   = "custom_tcp"
    port   = "8000-8100"
    source = ["198.51.100.0/24"]
  }
  # outbound: a group without outbound rules does not restrict outbound traffic
  rule {
    direction = "out"
    type      = "all"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.put("https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1/rules", headers=h, json={"rules": [{"type": "https", "source": ["0.0.0.0/0"]}, {"type": "ssh", "source": ["203.0.113.10/32"], "description": "office"}, {"direction": "out", "type": "all", "source": ["0.0.0.0/0"]}]}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1/rules", {
  method: "PUT",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"rules": [{"type": "https", "source": ["0.0.0.0/0"]}, {"type": "ssh", "source": ["203.0.113.10/32"], "description": "office"}, {"direction": "out", "type": "all", "source": ["0.0.0.0/0"]}]}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## POST /cloud/security-groups/{sg}/confirm

**Kural denemesini kalıcı yap** · operationId `confirmSecurityGroup` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/confirmSecurityGroup.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `sg` (zorunlu) | path | string |  |

### Yanıtlar

- **200**: Group
- **401**: Missing, invalid or revoked key
- **404**: Not found — also returned for objects owned by someone else
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X POST 'https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1/confirm' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro security-group confirm
```
```hcl
# kaynak gyro_security_group: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/security_group
# Reusable allow lists (AWS security group model). Stateful: replies to allowed connections pass automatically.
resource "gyro_security_group" "web" {
  name        = "web"
  description = "HTTP/HTTPS for everyone"

  rule {
    type = "http"
  }
  rule {
    type = "https"
  }
}

resource "gyro_security_group" "admin" {
  name = "admin"

  rule {
    type        = "ssh"
    source      = ["203.0.113.10/32"]
    description = "office"
  }
  rule {
    type   = "custom_tcp"
    port   = "8000-8100"
    source = ["198.51.100.0/24"]
  }
  # outbound: a group without outbound rules does not restrict outbound traffic
  rule {
    direction = "out"
    type      = "all"
  }
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.post("https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1/confirm", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/security-groups/1/confirm", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## GET /cloud/servers/{id}/security-groups

**Sunucuya bağlı güvenlik grupları** · operationId `listServerSecurityGroups` · scope `cloud_read` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/listServerSecurityGroups.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |

### Yanıtlar

- **200**: Attached groups
- **401**: Missing, invalid or revoked key
- **404**: Not found — also returned for objects owned by someone else
- **409**: firewall_not_enabled

### Örnekler

```bash
curl -s 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro security-group server list 12345
```
```hcl
# kaynak gyro_server_security_groups: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/server_security_groups
# Attach both groups to a server (order = evaluation order, max 5). Without gyro_firewall rules, inbound traffic
# that no group allows is denied.
resource "gyro_server_security_groups" "web1" {
  server_id          = 1234
  security_group_ids = [gyro_security_group.web.id, gyro_security_group.admin.id]
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.get("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups", {
  method: "GET",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## PUT /cloud/servers/{id}/security-groups

**Bağlı grupları tam liste olarak ayarla** · operationId `setServerSecurityGroups` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/setServerSecurityGroups.json

Tek değişiklikte bağlar / ayırır (sıra = değerlendirme sırası, en çok 5). Sunucunun önceki değişikliği uygulanırken 422 err_busy döner: birkaç saniye sonra tekrar deneyin.


### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |

### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `security_groups` (zorunlu) | array<string> |  |

### Yanıtlar

- **200**: Attached groups
- **401**: Missing, invalid or revoked key
- **404**: Not found — also returned for objects owned by someone else
- **409**: firewall_not_enabled
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X PUT 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"security_groups": ["string"]}'
```
```bash
gyro security-group server set 12345 --help    # tüm seçenekler
```
```hcl
# kaynak gyro_server_security_groups: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/server_security_groups
# Attach both groups to a server (order = evaluation order, max 5). Without gyro_firewall rules, inbound traffic
# that no group allows is denied.
resource "gyro_server_security_groups" "web1" {
  server_id          = 1234
  security_group_ids = [gyro_security_group.web.id, gyro_security_group.admin.id]
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.put("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups", headers=h, json={"security_groups": ["string"]}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups", {
  method: "PUT",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"security_groups": ["string"]}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## POST /cloud/servers/{id}/security-groups/{sg}

**Güvenlik grubunu sunucuya bağla** · operationId `attachSecurityGroup` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/attachSecurityGroup.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |
| `sg` (zorunlu) | path | string |  |

### Yanıtlar

- **200**: Attached groups
- **401**: Missing, invalid or revoked key
- **404**: Not found — also returned for objects owned by someone else
- **409**: firewall_not_enabled
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X POST 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups/1' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro security-group attach 12345
```
```hcl
# kaynak gyro_server_security_groups: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/server_security_groups
# Attach both groups to a server (order = evaluation order, max 5). Without gyro_firewall rules, inbound traffic
# that no group allows is denied.
resource "gyro_server_security_groups" "web1" {
  server_id          = 1234
  security_group_ids = [gyro_security_group.web.id, gyro_security_group.admin.id]
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.post("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups/1", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups/1", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## DELETE /cloud/servers/{id}/security-groups/{sg}

**Güvenlik grubunu sunucudan ayır** · operationId `detachSecurityGroup` · scope `cloud_write` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/detachSecurityGroup.json




### Parametreler

| Alan | in | Tür | Açıklama |
|---|---|---|---|
| `id` (zorunlu) | path | integer | Server id (= service id in the client area) |
| `sg` (zorunlu) | path | string |  |

### Yanıtlar

- **200**: Attached groups
- **401**: Missing, invalid or revoked key
- **404**: Not found — also returned for objects owned by someone else
- **409**: firewall_not_enabled
- **422**: Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)

### Örnekler

```bash
curl -s -X DELETE 'https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups/1' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro security-group detach 12345
```
```hcl
# kaynak gyro_server_security_groups: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/server_security_groups
# Attach both groups to a server (order = evaluation order, max 5). Without gyro_firewall rules, inbound traffic
# that no group allows is denied.
resource "gyro_server_security_groups" "web1" {
  server_id          = 1234
  security_group_ids = [gyro_security_group.web.id, gyro_security_group.admin.id]
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.delete("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups/1", headers=h, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/servers/12345/security-groups/1", {
  method: "DELETE",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
  },
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```
