---
title: "API anahtarları — API başvurusu"
description: "Hizmet, eylem ya da bayi uç-müşterisiyle daraltılmış alt hesap anahtarları. Yalnız GyroAPI `/cloud` uçlarında geçerlidir."
url: https://www.gyrohosting.com/developers/tr/api/api-keys.html
language: tr
openapi: https://www.gyrohosting.com/developers/openapi.json
api_version: 2.30.0
---

# API anahtarları

Hizmet, eylem ya da bayi uç-müşterisiyle daraltılmış alt hesap anahtarları. Yalnız GyroAPI `/cloud` uçlarında geçerlidir.

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


## GET /cloud/keys

**Alt hesap anahtarlarını listele (token göstermez)** · operationId `listApiKeys` · scope `keys` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/listApiKeys.json




### Yanıtlar

- **200**: Keys
- **403**: Key lacks the scope, IP not allowed, or feature disabled

### Örnekler

```bash
curl -s 'https://www.gyrohosting.com/api/v1/client/cloud/keys' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro key list
```
```hcl
# kaynak gyro_api_key: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/api_key
# A key for the reseller's end-customer: sees only Acme's services, cannot reach billing
resource "gyro_api_key" "acme_ci" {
  name        = "acme-ci"
  customer_id = tonumber(gyro_reseller_customer.acme.id)
  scopes      = ["cloud_read", "cloud_write", "services_read", "services_write"]
  actions     = ["reboot", "poweron", "snapshots:*"]
  rate_limit  = 60
}

output "acme_token" {
  value     = gyro_api_key.acme_ci.token
  sensitive = true
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.get("https://www.gyrohosting.com/api/v1/client/cloud/keys", 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/keys", {
  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/keys

**Alt hesap anahtarı oluştur (token bir kez döner)** · operationId `createApiKey` · scope `keys` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/createApiKey.json




### İstek gövdesi

| Alan | Tür | Açıklama |
|---|---|---|
| `name` (zorunlu) | string |  |
| `scopes` | array<string (cloud_read, cloud_write, cloud_order, cloud_delete, services_read, services_write, webhooks)> |  |
| `services` | array<integer> | Optional service allow list |
| `actions` | array<string> | Optional action allow list: server actions (reboot) or tool:action / tool:* / method:name |
| `ips` | array<string> |  |
| `rate_limit` | integer | Requests per minute (<= your own limit; 0 = default) |

### Yanıtlar

- **201**: Created
- **403**: Key lacks the scope, IP not allowed, or feature disabled
- **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/keys' \
  -H "Authorization: Bearer $GYRO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "ci-reboot-only", "scopes": ["cloud_read", "cloud_write"], "services": [47466], "actions": ["reboot", "poweron"], "ips": ["203.0.113.10"], "rate_limit": 30}'
```
```bash
gyro key create --help    # tüm seçenekler
```
```hcl
# kaynak gyro_api_key: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/api_key
# A key for the reseller's end-customer: sees only Acme's services, cannot reach billing
resource "gyro_api_key" "acme_ci" {
  name        = "acme-ci"
  customer_id = tonumber(gyro_reseller_customer.acme.id)
  scopes      = ["cloud_read", "cloud_write", "services_read", "services_write"]
  actions     = ["reboot", "poweron", "snapshots:*"]
  rate_limit  = 60
}

output "acme_token" {
  value     = gyro_api_key.acme_ci.token
  sensitive = true
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.post("https://www.gyrohosting.com/api/v1/client/cloud/keys", headers=h, json={"name": "ci-reboot-only", "scopes": ["cloud_read", "cloud_write"], "services": [47466], "actions": ["reboot", "poweron"], "ips": ["203.0.113.10"], "rate_limit": 30}, timeout=60)
r.raise_for_status()
print(r.json()["data"])
```
```js
const res = await fetch("https://www.gyrohosting.com/api/v1/client/cloud/keys", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GYRO_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"name": "ci-reboot-only", "scopes": ["cloud_read", "cloud_write"], "services": [47466], "actions": ["reboot", "poweron"], "ips": ["203.0.113.10"], "rate_limit": 30}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error.code}: ${error.message}`);
```


## DELETE /cloud/keys/{id}

**Alt hesap anahtarını sil** · operationId `deleteApiKey` · scope `keys` · OpenAPI fragment: https://www.gyrohosting.com/developers/spec/ops/deleteApiKey.json




### Parametreler

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

### Yanıtlar

- **200**: Deleted
- **404**: Not found — also returned for objects owned by someone else

### Örnekler

```bash
curl -s -X DELETE 'https://www.gyrohosting.com/api/v1/client/cloud/keys/12345' \
  -H "Authorization: Bearer $GYRO_TOKEN"
```
```bash
gyro key delete 12345
```
```hcl
# kaynak gyro_api_key: https://registry.terraform.io/providers/gyro-hosting/gyro/latest/docs/resources/api_key
# A key for the reseller's end-customer: sees only Acme's services, cannot reach billing
resource "gyro_api_key" "acme_ci" {
  name        = "acme-ci"
  customer_id = tonumber(gyro_reseller_customer.acme.id)
  scopes      = ["cloud_read", "cloud_write", "services_read", "services_write"]
  actions     = ["reboot", "poweron", "snapshots:*"]
  rate_limit  = 60
}

output "acme_token" {
  value     = gyro_api_key.acme_ci.token
  sensitive = true
}
```
```python
import os, uuid, requests

h = {"Authorization": "Bearer " + os.environ["GYRO_TOKEN"]}
r = requests.delete("https://www.gyrohosting.com/api/v1/client/cloud/keys/12345", 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/keys/12345", {
  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}`);
```
