---
title: "Create API Key"
method: POST
path: "/_api/key"
tags: ["API Keys"]
---

# Create API Key

`POST /_api/key`

## Request

- The document declares no server URL.
- Auth: one of:
  - API key in header `Authorization`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/macrometa/apis/macrometa-api-reference/docs/_api/key/post.ts> (a function with typed inputs; its response is checked against the schema)

Create API keys for yourself.

## Request body

- ApikeyCreate
  - `keyid` string, required: The id of the API key.
  - `user` string: The user that owns the API key. The 'user' option should be used only when creating an API key that belongs to another user, and can be used only by service or _mm.root.
  - `isSystem` boolean: Indicates whether the key is a system API key.

## Response `201`

Successfully added API key.

- ApiKeyHttpExamplesRc201
  - `code` integer: HTTP response code.
  - `error` boolean, required: Flag if there is an error in response. *False* for this response.
  - `key` string: The generated key.
  - `keyid` string: keyid of the key.
  - `tenant` string: Name of the tenant.
  - `user` string: Name of the user.

## Other responses

- `400`: Failed due to missing or malformed data. Verify that all parameters are complete.
- `401`: Failed because you do not have administrator permissions.
- `403`: Failed to validate because you do not have access to the server.
- `409`: Failed because API key already exists.

---

[API](https://skmtc.dev/macrometa/apis/macrometa-api-reference.md) - [All operations](https://skmtc.dev/macrometa/apis/macrometa-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/macrometa/apis/macrometa-api-reference/revisions/2006b6d7f31d?raw)
