---
title: "Upsert a Key"
url: "https://nov18-dev.movespot.fyi/apis/konnect-runtime-groups-configuration-0/versions/af18902c-58f1-49d7-8ec2-9987b4e0d1bd/operations/upsert-key"
---

> Full API specification: https://nov18-dev.movespot.fyi/apis/konnect-runtime-groups-configuration-0/versions/af18902c-58f1-49d7-8ec2-9987b4e0d1bd.md

# Upsert a Key

`PUT` `/runtime-groups/{runtimeGroupId}/core-entities/keys/{key_id_or_name}`

Operation ID: `upsert-key`

Create or Update Key using ID or name.

## Path parameters

- `key_id_or_name` (string, required) - The unique identifier or the name of the Key to retrieve.
- `runtimeGroupId` (string, required) - The ID of your runtime group. This variable is available in the Konnect manager

## Request body

Content types: `application/json`

## Responses

- `200` - Successfully upserted Key
- `400` - Invalid Key

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: Konnect Runtime Groups Configuration
  version: 0.0.1
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:
  /runtime-groups/{runtimeGroupId}/core-entities/keys/{key_id_or_name}:
    parameters:
      - $ref: "#/components/parameters/key_id_or_name"
      - $ref: "#/components/parameters/runtimeGroupId"
    put:
      operationId: upsert-key
      summary: Upsert a Key
      description: Create or Update Key using ID or name.
      requestBody:
        $ref: "#/components/requestBodies/keys-request"
      responses:
        "200":
          description: Successfully upserted Key
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Key"
              examples:
                Example:
                  value:
                    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
        "400":
          description: Invalid Key
          content:
            application/json:
              schema:
                type: object
      tags:
        - Keys
security:
  - konnectAccessToken: []
  - personalAccessToken: []
components:
  parameters:
    key_id_or_name:
      name: key_id_or_name
      in: path
      required: true
      schema:
        type: string
        example: 24D0DBDA-671C-11ED-BA0B-EF1DCCD3725
      description: The unique identifier or the name of the Key to retrieve.
    runtimeGroupId:
      name: runtimeGroupId
      in: path
      required: true
      schema:
        type: string
        example: 9524ec7d-36d9-465d-a8c5-83a3c9390458
      description: The ID of your runtime group. This variable is available in the
        Konnect manager
  requestBodies:
    keys-request:
      content:
        application/json:
          schema:
            type: object
            properties:
              set:
                description: The id (an UUID) of the key-set with which to associate the key
                  .With form-encoded, the notation is `set.id=<set id>` or
                  `set.name=<set name>`. With JSON, use `“set:{id:<set id>}` or
                  `set:{name:<set name>}.`
                type: object
                properties:
                  id:
                    description: 46CA83EE-671C-11ED-BFAB-2FE47512C77A
                    type: string
              name:
                description: |
                  The name to associate with the given keys.
                type: string
                example: my-key
              kid:
                description: |
                  A unique identifier for a key.
                type: string
                example: "42"
              jwk:
                description: A JSON Web Key represented as a string.
                type: string
                example: "{\\alg\\:\\RSA\\,  \\kid\\: \\42\\,  ...}"
              pem:
                description: |
                  A keypair in PEM format.
                type: object
                properties:
                  private_key:
                    type: string
                    example: "private_key: -----BEGIN"
                  public_key:
                    type: string
                    example: "public_key: -----BEGIN"
              tags:
                description: >
                  An optional set of strings associated with the Key for
                  grouping and filtering.
                type: array
                items:
                  type: string
            required:
              - kid
            x-examples:
              Example 1:
                set:
                  id: 46CA83EE-671C-11ED-BFAB-2FE47512C77A
                name: my-key
                kid: "42"
                jwk: "{alg:RSA,  kid: 42,  ...}"
                pem:
                  private_key: -----BEGIN
                  public_key: -----BEGIN
                tags:
                  - application-a
                  - public-key-xyz
  schemas:
    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
          example: 1422386534
        id:
          description: The unique identifier or the prefix of the Vault to delete.
          type: string
          example: 24D0DBDA-671C-11ED-BA0B-EF1DCCD3725F
        jwk:
          description: A JSON Web Key represented as a string.
          type: string
          example: "{\\alg\\:\\RSA\\,  \\kid\\: \\42\\,  ...}"
        kid:
          description: A unique identifier for a key.
          type: string
          example: "42"
        updated_at:
          description: Unix epoch when the resouce was updated.
          type: integer
          example: 1422386534
        pem:
          description: A keypair in PEM format.
          type: object
          properties:
            private_key:
              type: string
              example: -----BEGIN
            public_key:
              type: string
              example: -----BEGIN
        set:
          description: The id (an UUID) of the key-set with which to associate the key.
          type: object
          additionalProperties: false
          properties:
            id:
              type: string
              example: 46CA83EE-671C-11ED-BFAB-2FE47512C77A
        tags:
          description: An optional set of strings associated with the Key for grouping and
            filtering.
          type: array
          items:
            type: string
      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
      title: Key
  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.
```
