# Create service account key in organization

`POST /v1/organizations/{organization}/serviceAccounts/{serviceAccount}/keys`, operation `serviceAccounts.CreateServiceAccountKeyInOrganization`

Creates a key. Its secret is in the response and cannot be read again.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `organization` | path | Yes | `string` | The organization's ID. |
| `serviceAccount` | path | Yes | `string` | The service account's ID. |

## Request body

Content-Type: `application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `expireTime` | `string (date-time)` | No | When the key stops working. Not with ttlSeconds. |
| `ttlSeconds` | `integer (int64)` | No | How many seconds after it is created the key stops working. Not with expireTime. |

## Responses

### 201

Created

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `createTime` | `string (date-time)` | Yes | When the key was created. |
| `expireTime` | `string (date-time)` | Yes | When the key stops working. |
| `lastUseTime` | `string (date-time)` | No | When the key was last used, if it was. |
| `name` | `string` | Yes | Resource name, the service account's name followed by /keys/{key_id}. |
| `secret` | `string` | No | The secret, which is the API key, sent as a bearer token. Only in the response that creates the key: it cannot be read again. Audit log entries never keep it. |

### default

Error

Base URL: `https://api.kosem.ai`. See [API conventions](https://docs.kosem.ai/reference/api-conventions.md) for authentication, pagination and errors, and [https://docs.kosem.ai/openapi.yaml](https://docs.kosem.ai/openapi.yaml) for the full OpenAPI document.