---
search:
  tags:
    - Account
    - POST
seo:
  description: >-
    Creates a key that acts as your account, with the roles you hold when the
    key is used. You… Reference for the POST /_luna/auth/keys endpoint in the
    Luna API.
sidebar:
  label: Create an account key
  badge: POST
title: Create an account key
type: openapi-operation
---
Creates a key that acts as your account, with the roles you hold when the key is used. You must be logged in: a session or the key `luna login` made. The key is shown once.

`POST /_luna/auth/keys`

**Request body** (`application/json`, required)

- `name` (string, required)
- `access` (string, required) — \`read\` or \`write\`. A \`read\` key cannot change anything.
- `expiresIn` (integer<int64> | null) — Seconds from now until the key expires. Leave it out for a key that does not expire.

Request body example:

```json
{
  "name": "string",
  "access": "string",
  "expiresIn": 0
}
```

**Responses**

- `200` — The new key.
- `default` — The request failed. The status says how and \`error.message\` says why.

Response example, 200:

```json
{
  "id": "string",
  "key": "string",
  "expiresMs": 0
}
```
