# API Key


<style>
  span[class^="pill-"] {
    color: white;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 0.6em;
    vertical-align: middle;
    margin-right: 12px;
    font-family: sans-serif;
    font-weight: bold;
    display: inline-block;
    line-height: 1;
  }
  span.pill-GET { background-color: #61affe; }
  span.pill-POST { background-color: #49cc90; }
  span.pill-PUT { background-color: #fca130; }
  span.pill-DELETE { background-color: #f93e3e; }
  span.pill-PATCH { background-color: #50e3c2; }
  span[class^="pill-"]:after {
    content: attr(data-label);
    font-size: 0.9rem;
  }
</style>

API keys are credentials for programmatic access to Exoscale APIs and services.

[Read more](https://community.exoscale.com/product/iam/how-to/key-mgmt/)

## <span data-label="POST" class="pill-POST"></span>create-api-key

Create a new API key

```
POST /api-key
```

null

### Request body

Content-Type: `application/json`

| Property | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | **yes** | IAM API Key Name<br/><br/>Min length: `1`. Max length: `255`. |
| `role-id` | string | **yes** | IAM API Key Role ID<br/><br/>Must be a valid UUID. |

<details>
<summary>Example</summary>

```json
{
  "name": "string",
  "role-id": "string"
}
```
</details>


### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `key` | string | IAM API Key |
| `name` | string | IAM API Key name |
| `role-id` | string | IAM API Key Role ID<br/><br/>Must be a valid UUID. |
| `secret` | string | IAM API Key Secret |

<details>
<summary>Example output</summary>

```json
{
  "key": "string",
  "name": "string",
  "role-id": "string",
  "secret": "string"
}
```
</details>


SDK reference for `create-api-key`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.CreateAPIKey) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.create_api_key) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#createApiKey(com.exoscale.sdk.model.CreateApiKeyRequest))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api create-api-key`

## <span data-label="GET" class="pill-GET"></span>get-api-key

Get API key

```
GET /api-key/{id}
```

null

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `id` | `path` |  |

### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `key` | string | IAM API Key |
| `name` | string | IAM API Key name |
| `role-id` | string | IAM API Key Role ID<br/><br/>Must be a valid UUID. |

<details>
<summary>Example output</summary>

```json
{
  "key": "string",
  "name": "string",
  "role-id": "string"
}
```
</details>


SDK reference for `get-api-key`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.GetAPIKey) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.get_api_key) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#getApiKey(java.lang.String))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api get-api-key`

## <span data-label="DELETE" class="pill-DELETE"></span>delete-api-key

Delete an API key

```
DELETE /api-key/{id}
```

null

### Path parameters

| Name | In | Description |
| --- | --- | --- |
| `id` | `path` |  |

### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `id` | string | Operation ID<br/><br/>Must be a valid UUID. |
| `message` | string | Operation message |
| `reason` | string | Operation failure reason<br/><br/>Allowed values: `incorrect`, `unknown`, `unavailable`, `forbidden`, `busy`, `fault`, `partial`, `not-found`, `interrupted`, `unsupported`, `conflict`. |
| `reference` | [Reference](/reference/api/_schemas/operation/#reference) | Related resource reference |
| `state` | string | Operation status<br/><br/>Allowed values: `failure`, `pending`, `success`, `timeout`. |

<details>
<summary>Example output</summary>

```json
{
  "id": "string",
  "message": "string",
  "reason": "incorrect",
  "reference": {
    "command": "string",
    "id": "string",
    "link": "string"
  },
  "state": "failure"
}
```
</details>


SDK reference for `delete-api-key`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.DeleteAPIKey) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.delete_api_key) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#deleteApiKey(java.lang.String))

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api delete-api-key`


---

## Other Operations

## <span data-label="GET" class="pill-GET"></span>list-api-keys

List API keys

```
GET /api-key
```

null

### Responses

Status: `200` - 200

Content-Type: `application/json`

| Property | Type | Description |
| --- | --- | --- |
| `api-keys` | array of [IAM API Key](/reference/api/_schemas/iam-api-key/) |  |

<details>
<summary>Example output</summary>

```json
{
  "api-keys": [
    {
      "key": "string",
      "name": "string",
      "role-id": "string"
    }
  ]
}
```
</details>


SDK reference for `list-api-keys`: [golang](https://pkg.go.dev/github.com/exoscale/egoscale/v3#Client.ListAPIKeys) | [Python](https://exoscale.github.io/python-exoscale/v2.html#exoscale.api.v2.Client.list_api_keys) | [Java](https://exoscale.github.io/exoscale-sdk-java/com/exoscale/sdk/api/ExoscaleApi.html#listApiKeys())

[CLI](https://community.exoscale.com/tools/command-line-interface/): `exo api list-api-keys`


