---
title: "Upsert a Key associated with a KeySet"
url: "https://nov18-dev.movespot.fyi/apis/konnect-control-planes-configuration-3/versions/4a9ee72f-47ac-4061-9b08-3290c8d0ce93/operations/upsert-key-with-key-set"
---

> Full API specification: https://nov18-dev.movespot.fyi/apis/konnect-control-planes-configuration-3/versions/4a9ee72f-47ac-4061-9b08-3290c8d0ce93.md

# Upsert a Key associated with a KeySet

`PUT` `/control-planes/{controlPlaneId}/core-entities/key-sets/{KeySetId}/keys/{KeyId}`

Operation ID: `upsert-key-with-key-set`

Create or Update a Key associated with a KeySet using ID or name.

## Path parameters

- `controlPlaneId` (string, uuid, required) - The UUID of your control plane. This variable is available in the Konnect manager.
- `KeySetId` (string, required) - ID of the KeySet to lookup
- `KeyId` (string, required) - ID of the Key to lookup

## Request body (required)

Content types: `application/json`

## Responses

- `200` - Successfully upserted Key

## OpenAPI definition

```yaml
openapi: 3.1.0
info:
  title: Konnect Control Planes Configuration
  version: 3.14.0
servers:
  - url: https://us.api.konghq.com/v2
    description: United-States Production region
  - url: https://eu.api.konghq.com/v2
    description: Europe Production region
  - url: https://au.api.konghq.com/v2
    description: Australia Production region
  - url: https://me.api.konghq.com/v2
    description: Middle-East Production region
  - url: https://in.api.konghq.com/v2
    description: India Production region
  - url: https://sg.api.konghq.com/v2
    description: Singapore Production region
paths:
  /control-planes/{controlPlaneId}/core-entities/key-sets/{KeySetId}/keys/{KeyId}:
    parameters:
      - $ref: "#/components/parameters/controlPlaneId"
    put:
      operationId: upsert-key-with-key-set
      summary: Upsert a Key associated with a KeySet
      description: Create or Update a Key associated with a KeySet using ID or name.
      parameters:
        - $ref: "#/components/parameters/KeySetId"
        - $ref: "#/components/parameters/KeyId"
      requestBody:
        description: Description of the Key
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/KeyWithoutParents"
      responses:
        "200":
          description: Successfully upserted Key
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Key"
      tags:
        - Keys
security:
  - konnectAccessToken: []
  - personalAccessToken: []
components:
  parameters:
    controlPlaneId:
      name: controlPlaneId
      in: path
      required: true
      schema:
        type: string
        format: uuid
        example: 9524ec7d-36d9-465d-a8c5-83a3c9390458
      description: The UUID of your control plane. This variable is available in the
        Konnect manager.
    KeySetId:
      description: ID of the KeySet to lookup
      example: 6cc34248-50b4-4a81-9201-3bdf7a83f712
      in: path
      name: KeySetId
      required: true
      schema:
        type: string
    KeyId:
      description: ID of the Key to lookup
      example: bba22c06-a632-42be-a018-1b9ff357b5b9
      in: path
      name: KeyId
      required: true
      schema:
        type: string
  schemas:
    KeyWithoutParents:
      description: 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.
      type: object
      properties:
        created_at:
          description: Unix epoch when the resource was created.
          type: integer
          nullable: true
        id:
          description: A string representing a UUID (universally unique identifier).
          type: string
          nullable: true
        jwk:
          description: A JSON Web Key represented as a string.
          type: string
          nullable: true
          x-encrypted: true
          x-referenceable: true
        kid:
          description: A unique identifier for a key.
          type: string
        name:
          description: The name to associate with the given keys.
          type: string
          nullable: true
        pem:
          description: A keypair in PEM format.
          type: object
          nullable: true
          properties:
            private_key:
              type: string
              x-encrypted: true
              x-referenceable: true
            public_key:
              type: string
              x-referenceable: true
        set:
          description: The id (an UUID) of the key-set with which to associate the key.
          type: object
          nullable: true
          properties:
            id:
              type: string
          x-foreign: true
        tags:
          description: An optional set of strings associated with the Key for grouping and
            filtering.
          type: array
          items:
            description: A string representing a tag.
            type: string
          nullable: true
        updated_at:
          description: Unix epoch when the resource was last updated.
          type: integer
          nullable: true
        x5t:
          description: X.509 certificate SHA-1 thumbprint.
          type: string
          nullable: true
      example:
        id: d958f66b-8e99-44d2-b0b4-edd5bbf24658
        jwk: '{"alg":"RSA",  "kid": "42",  ...}'
        kid: "42"
        name: a-key
        pem:
          private_key: -----BEGIN
          public_key: -----BEGIN
        set:
          id: b86b331c-dcd0-4b3e-97ce-47c5a9543031
      additionalProperties: false
      required:
        - kid
    Key:
      description: 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.
      type: object
      properties:
        created_at:
          description: Unix epoch when the resource was created.
          type: integer
          nullable: true
        id:
          description: A string representing a UUID (universally unique identifier).
          type: string
          nullable: true
        jwk:
          description: A JSON Web Key represented as a string.
          type: string
          nullable: true
          x-encrypted: true
          x-referenceable: true
        kid:
          description: A unique identifier for a key.
          type: string
        name:
          description: The name to associate with the given keys.
          type: string
          nullable: true
        pem:
          description: A keypair in PEM format.
          type: object
          nullable: true
          properties:
            private_key:
              type: string
              x-encrypted: true
              x-referenceable: true
            public_key:
              type: string
              x-referenceable: true
        set:
          description: The id (an UUID) of the key-set with which to associate the key.
          type: object
          nullable: true
          properties:
            id:
              type: string
          x-foreign: true
        tags:
          description: An optional set of strings associated with the Key for grouping and
            filtering.
          type: array
          items:
            description: A string representing a tag.
            type: string
          nullable: true
        updated_at:
          description: Unix epoch when the resource was last updated.
          type: integer
          nullable: true
        x5t:
          description: X.509 certificate SHA-1 thumbprint.
          type: string
          nullable: true
      example:
        id: d958f66b-8e99-44d2-b0b4-edd5bbf24658
        jwk: '{"alg":"RSA",  "kid": "42",  ...}'
        kid: "42"
        name: a-key
        pem:
          private_key: -----BEGIN
          public_key: -----BEGIN
        set:
          id: b86b331c-dcd0-4b3e-97ce-47c5a9543031
      additionalProperties: false
      required:
        - kid
  securitySchemes:
    konnectAccessToken:
      type: http
      scheme: bearer
      description: The Konnect access token is meant to be used by the Konnect
        dashboard and the decK CLI to authenticate with.
    personalAccessToken:
      type: http
      scheme: bearer
      description: The personal access token is meant to be used as an alternative to
        basic-auth when accessing Konnect via APIs. You can generate a Personal
        Access Token (PAT) from the personal access token page in the Konnect
        dashboard.
```
