---
title: "POST /workspaces/{workspaceId}/apikeys"
method: POST
path: "/workspaces/{workspaceId}/apikeys"
---

# POST /workspaces/{workspaceId}/apikeys

`POST /workspaces/{workspaceId}/apikeys`

Creates a Grafana API key for the workspace. This key can be used to authenticate requests sent to the workspace's HTTP API. See [https://docs.aws.amazon.com/grafana/latest/userguide/Using-Grafana-APIs.html](https://docs.aws.amazon.com/grafana/latest/userguide/Using-Grafana-APIs.html) for available APIs and example requests.

In workspaces compatible with Grafana version 9 or above, use workspace service accounts instead of API keys. API keys will be removed in a future release.

## Path parameters

- `workspaceId` string, required

## Request body

- object
  - `keyName` string, required — Specifies the name of the key. Keynames must be unique to the workspace.
  - `keyRole` string, required — <p>Specifies the permission level of the key.</p> <p> Valid values: <code>ADMIN</code>|<code>EDITOR</code>|<code>VIEWER</code> </p>
  - `secondsToLive` integer, required — Specifies the time in seconds until the key expires. Keys can be valid for up to 30 days.

## Response `200`

Success

- CreateWorkspaceApiKeyResponse
  - `keyName` string, required — The name of the key that was created.
  - `key` string, password, required — The key token. Use this value as a bearer token to authenticate HTTP requests to the workspace.
  - `workspaceId` string, required — The ID of the workspace that the key is valid for.

## Other responses

- `480` — ResourceNotFoundException
- `481` — ThrottlingException
- `482` — ConflictException
- `483` — ValidationException
- `484` — AccessDeniedException
- `485` — InternalServerException
- `486` — ServiceQuotaExceededException

---

[API](https://skmtc.net/aws/apis/grafana.md) · [All operations](https://skmtc.net/aws/apis/grafana/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/aws/grafana/versions/76cc5bd3d508/schema)
