---
title: "Upsert a Key"
method: PUT
path: "/v2/control-planes/{controlPlaneId}/core-entities/keys/{KeyId}"
tags: ["Keys"]
---

# Upsert a Key

`PUT /v2/control-planes/{controlPlaneId}/core-entities/keys/{KeyId}`

Create or Update Key using ID or name.

## Request body

- Key — A Key object holds a representation of asymmetric keys in various formats. When Kong or a Kong plugin requires a specific public or private key to perform certain operations, it can use this entity.
  - `created_at` integer, nullable — Unix epoch when the resource was created.
  - `id` string, nullable — A string representing a UUID (universally unique identifier).
  - `jwk` string, nullable — A JSON Web Key represented as a string.
  - `kid` string, required — A unique identifier for a key.
  - `name` string, nullable — The name to associate with the given keys.
  - `pem` object, nullable — A keypair in PEM format.
    - `private_key` string
    - `public_key` string
  - `set` object, nullable — The id (an UUID) of the key-set with which to associate the key.
    - `id` string
  - `tags` string[], nullable — An optional set of strings associated with the Key for grouping and filtering.
  - `updated_at` integer, nullable — Unix epoch when the resource was last updated.
  - `x5t` string, nullable — X.509 certificate SHA-1 thumbprint.

## Response `200`

Successfully upserted Key

- Key — A Key object holds a representation of asymmetric keys in various formats. When Kong or a Kong plugin requires a specific public or private key to perform certain operations, it can use this entity.
  - `created_at` integer, nullable — Unix epoch when the resource was created.
  - `id` string, nullable — A string representing a UUID (universally unique identifier).
  - `jwk` string, nullable — A JSON Web Key represented as a string.
  - `kid` string, required — A unique identifier for a key.
  - `name` string, nullable — The name to associate with the given keys.
  - `pem` object, nullable — A keypair in PEM format.
    - `private_key` string
    - `public_key` string
  - `set` object, nullable — The id (an UUID) of the key-set with which to associate the key.
    - `id` string
  - `tags` string[], nullable — An optional set of strings associated with the Key for grouping and filtering.
  - `updated_at` integer, nullable — Unix epoch when the resource was last updated.
  - `x5t` string, nullable — X.509 certificate SHA-1 thumbprint.

## Other responses

- `401` — Unauthorized

---

[API](https://skmtc.net/kong/apis/konnect-api-go-sdk.md) · [All operations](https://skmtc.net/kong/apis/konnect-api-go-sdk/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kong/konnect-api-go-sdk/versions/f920f418f552/schema)
