---
title: "Upsert a API-key"
method: PUT
path: "/key-auths/{KeyAuthId}"
tags: ["API-keys"]
---

# Upsert a API-key

`PUT /key-auths/{KeyAuthId}`

Create or Update API-key using ID.

## Request body

- KeyAuth
  - `consumer` object, nullable
    - `id` string
  - `created_at` integer — Unix epoch when the resource was created.
  - `id` string, nullable
  - `key` string, required
  - `tags` string[]

## Response `200`

Successfully upserted API-key

- KeyAuth
  - `consumer` object, nullable
    - `id` string
  - `created_at` integer — Unix epoch when the resource was created.
  - `id` string, nullable
  - `key` string, required
  - `tags` string[]

## Other responses

- `401` — Unauthorized

## Changes

> 4 revisions in range; 1 not diffed.

- **2024-11-26** `99e71588eb61` — 3 breaking, 1 warning, 9 info
  - added the new required request property `key`
  - the request's body type changed from no type to `object`
  - the response's body type changed from no type to `object` for status `200`
  - removed `#/components/schemas/KeyAuthWithoutParents, subschema #2` from the request body `allOf` list
  - …9 more
- **2024-09-11** `5bd52189d290` — 1 warning
  - deleted the `path` request parameter `KeyAuthId`

[Change history](https://skmtc.dev/kong/apis/kong-enterprise-admin-api/changes/key-auths/:KeyAuthId/put.md)

---

[API](https://skmtc.dev/kong/apis/kong-enterprise-admin-api.md) · [All operations](https://skmtc.dev/kong/apis/kong-enterprise-admin-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/kong/kong-enterprise-admin-api/revisions/99e71588eb61/schema)
