---
title: "Creates a key"
method: POST
path: "/apps/{app_id}/keys"
tags: ["keys"]
---

# Creates a key

`POST /apps/{app_id}/keys`

Creates an API key for the application specified.

## Path parameters

- `app_id` string, required

## Request body

- KeyPost
  - `capabilities` string[], required — The capabilities that this key has. More information on capabilities can be found in the <a href="https://ably.com/documentation/core-features/authentication#capabilities-explained">Ably documentation</a>.
  - `channels` string, required — Specify the channels and queues that this key can be used with.
  - `name` string, required — The name for your API key. This is a friendly name for your reference.

## Response `201`

Key created

- KeyResponse
  - `appId` string — The Ably application ID which this key is associated with.
  - `capability` object — The capabilities that this key has. More information on capabilities can be found in the <a href="https://ably.com/documentation/core-features/authentication#capabilities-explained">Ably documentation</a>.
  - `created` integer — Unix timestamp representing the date and time of creation of the key.
  - `id` string — The key ID.
  - `key` string — The complete API key including API secret.
  - `modified` integer — Unix timestamp representing the date and time of the last modification of the key.
  - `name` string — The name of the application this key is associated with.

## Other responses

- `400` — Bad request
- `401` — Authentication failed
- `404` — App not found
- `422` — Invalid request
- `500` — Internal server error

---

[API](https://skmtc.net/ably/apis/control.md) · [All operations](https://skmtc.net/ably/apis/control/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/ably/control/revisions/85e2f4b0deb6/schema)
