---
title: "Generates an API key for the current user. Deprecated in favor of POST /api/auth/api-keys."
method: GET
path: "/api/auth/api-key/generate"
tags: ["Authentication"]
deprecated: true
---

# Generates an API key for the current user. Deprecated in favor of POST /api/auth/api-keys.

`GET /api/auth/api-key/generate`

## Request

- Base URL: `https://passivelogic.com` (the document declares no server; this is the origin it was published from)
- URL: `https://passivelogic.com/api/auth/api-key/generate`
- Auth: one of:
  - API key in header `X-PL-AUTH`
  - API key in header `Authorization: PL-API-KEY`
  - API key in header `PL-API-KEY`
  - HTTP basic
- TypeScript: <https://skmtc.dev/passivelogic/apis/passivelogic-http-api/docs/api/auth/api-key/generate/get.ts> (a function with typed inputs; its response is checked against the schema)

> **Deprecated.**

Generates, stores, and returns a new API key with the default expiration period for the user currently logged in.

Once created, you can then provide this API key in an
`Authorization: PL-API-KEY <Key>` header in replacement of an `X-PL-AUTH` header.

## Query parameters

- `expireSeconds` integer, nullable
- `role` string, nullable

## Response `200`

OK

- GenerateApiKeyResponse: New API key generated for a user.
  - `expiration` integer, required: Expiration of the new key.
  - `key` string, required: New API key.

---

[API](https://skmtc.dev/passivelogic/apis/passivelogic-http-api.md) - [All operations](https://skmtc.dev/passivelogic/apis/passivelogic-http-api/llms.txt) - [OpenAPI document](https://skmtc.dev/passivelogic/apis/passivelogic-http-api/revisions/28fce63bcdbb?raw)
