> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openlayer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update API key

> Rename an API key.



## OpenAPI

````yaml put /workspaces/{workspaceId}/api-keys/{apiKeyId}
openapi: 3.0.3
info:
  contact:
    email: support@openlayer.com
    name: Openlayer
    url: https://openlayer.com/
  description: API for interacting with the Openlayer server.
  title: Openlayer API
  version: '1.0'
  x-logo:
    url: https://logo.clearbit.com/openlayer.com
servers:
  - url: https://api.openlayer.com/v1
    description: Our prod backend
security:
  - bearerAuth: []
paths:
  /workspaces/{workspaceId}/api-keys/{apiKeyId}:
    put:
      summary: Update an API key
      description: Rename an API key.
      operationId: updateApiKey
      parameters:
        - $ref: '#/components/parameters/workspaceId'
        - $ref: '#/components/parameters/apiKeyId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name: 5decd237-1da1-42a8-9a87-c8cb3282c924
      responses:
        '200':
          description: Status OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKey'
      x-codeSamples:
        - lang: python
          source: |
            from openlayer import Openlayer

            client = Openlayer()

            api_key = client.workspaces.api_keys.update(
                "3f2b9c1e-8a4d-4e6f-9b7a-1c2d3e4f5a6b",
                workspace_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
                name="CI pipeline (prod)",
            )
            print(api_key.name)
        - lang: typescript
          source: >
            import Openlayer from 'openlayer';


            const client = new Openlayer();


            const apiKey = await
            client.workspaces.apiKeys.update('3f2b9c1e-8a4d-4e6f-9b7a-1c2d3e4f5a6b',
            {
              workspaceId: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
              name: 'CI pipeline (prod)',
            });


            console.log(apiKey.name);
        - lang: go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/openlayer-ai/openlayer-go\"\n)\n\nclient := openlayer.NewClient()\napiKey, err := client.Workspaces.APIKeys.Update(\n\tcontext.TODO(),\n\t\"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e\",\n\t\"3f2b9c1e-8a4d-4e6f-9b7a-1c2d3e4f5a6b\",\n\topenlayer.WorkspaceAPIKeyUpdateParams{\n\t\tName: openlayer.F(\"CI pipeline (prod)\"),\n\t},\n)\nif err != nil {\n\tpanic(err.Error())\n}\nfmt.Printf(\"%+v\\n\", apiKey.Name)\n"
        - lang: java
          source: >
            import com.openlayer.api.client.OpenlayerClient;

            import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient;

            import
            com.openlayer.api.models.workspaces.apikeys.ApiKeyUpdateParams;

            import
            com.openlayer.api.models.workspaces.apikeys.ApiKeyUpdateResponse;


            OpenlayerClient client = OpenlayerOkHttpClient.fromEnv();


            ApiKeyUpdateParams params = ApiKeyUpdateParams.builder()
                .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
                .apiKeyId("3f2b9c1e-8a4d-4e6f-9b7a-1c2d3e4f5a6b")
                .name("CI pipeline key (prod)")
                .build();
            ApiKeyUpdateResponse apiKey =
            client.workspaces().apiKeys().update(params);
        - lang: ruby
          source: |
            require "openlayer"

            openlayer = Openlayer::Client.new(api_key: ENV["OPENLAYER_API_KEY"])

            api_key = openlayer.workspaces.api_keys.update(
              "3f2b9c1e-8a4d-4e6f-9b7a-1c2d3e4f5a6b",
              workspace_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
              name: "Production key"
            )

            puts(api_key)
        - lang: curl
          source: |
            curl --request PUT \
              --url https://api.openlayer.com/v1/workspaces/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/api-keys/3f2b9c1e-8a4d-4e6f-9b7a-1c2d3e4f5a6b \
              --header 'Authorization: Bearer <token>' \
              --data '{"name": "Production ingest"}'
components:
  parameters:
    workspaceId:
      name: workspaceId
      in: path
      description: The workspace id.
      required: true
      schema:
        type: string
        format: uuid
    apiKeyId:
      name: apiKeyId
      in: path
      description: The API key id.
      required: true
      schema:
        type: string
        format: uuid
  schemas:
    ApiKey:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The API key id.
          readOnly: true
        name:
          type: string
          nullable: true
          maxLength: 120
          example: Secret Key
          description: The API key name.
        dateCreated:
          type: string
          format: date-time
          readOnly: true
          description: The API key creation date.
        dateUpdated:
          type: string
          format: date-time
          readOnly: true
          description: The API key last update date.
        dateLastUsed:
          type: string
          format: date-time
          readOnly: true
          nullable: true
          description: The API key last use date.
        secureKey:
          type: string
          example: sk-o...5PW0
          maxLength: 120
          readOnly: true
          description: >-
            An obfuscated hint of the API key value. When a key is created or
            rotated this also holds the full secret, for backward compatibility;
            prefer `secret`.
        secret:
          type: string
          readOnly: true
          example: sk-ol-Xq3v9Rk2mPz8TnW4yL7bC1dF5hJ6
          description: >-
            The full API key. Only present in the response that creates or
            rotates the key, and never shown again.
        status:
          type: string
          enum:
            - active
            - rotating
            - expired
          readOnly: true
          example: active
          description: >-
            The key's lifecycle state. `active`: the current secret
            authenticates. `rotating`: the key was rotated and the previous
            secret still authenticates until `previousKeyExpiresAt`. `expired`:
            `expiresAt` has passed, no secret authenticates, and the key can't
            be rotated.
        expiresAt:
          type: string
          format: date-time
          nullable: true
          example: '2027-01-01T00:00:00Z'
          description: >-
            When the key stops authenticating. `null` means the key never
            expires. Set when the key is created or rotated, and must be in the
            future. When the request is authenticated with an API key that
            expires, the result can't be later than that key's expiry. On
            create, omit it to inherit that expiry. On rotate, omit it to keep
            the current one. It can't be changed with an update; rotate the key
            instead.
        lastRotatedAt:
          type: string
          format: date-time
          nullable: true
          readOnly: true
          description: When the key was last rotated.
        previousKeyExpiresAt:
          type: string
          format: date-time
          nullable: true
          readOnly: true
          description: >-
            While `status` is `rotating`, when the previous secret stops
            authenticating.
      required:
        - id
        - dateCreated
        - dateUpdated
        - dateLastUsed
        - secureKey
        - status
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your workspace API key. See [Find your API
        key](https://www.openlayer.com/docs/workspace-and-projects/find-your-api-key)
        for more information.

````