> ## 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.

# Retrieve API key

> Retrieve an API key.



## OpenAPI

````yaml get /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}:
    get:
      summary: Retrieve an API key
      description: Retrieve an API key.
      operationId: getApiKey
      parameters:
        - $ref: '#/components/parameters/workspaceId'
        - $ref: '#/components/parameters/apiKeyId'
      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.retrieve(
                "3f2b9c1e-8a4d-4e6f-9b7a-1c2d3e4f5a6b",
                workspace_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
            )
            print(api_key.status)
        - lang: typescript
          source: >
            import Openlayer from 'openlayer';


            const client = new Openlayer();


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


            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.Get(\n\tcontext.TODO(),\n\t\"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e\",\n\t\"3f2b9c1e-8a4d-4e6f-9b7a-1c2d3e4f5a6b\",\n)\nif err != nil {\n\tpanic(err.Error())\n}\nfmt.Printf(\"%+v\\n\", apiKey.Status)\n"
        - lang: java
          source: >
            import com.openlayer.api.client.OpenlayerClient;

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

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

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


            OpenlayerClient client = OpenlayerOkHttpClient.fromEnv();


            ApiKeyRetrieveParams params = ApiKeyRetrieveParams.builder()
                .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
                .apiKeyId("3f2b9c1e-8a4d-4e6f-9b7a-1c2d3e4f5a6b")
                .build();
            ApiKeyRetrieveResponse apiKey =
            client.workspaces().apiKeys().retrieve(params);
        - lang: ruby
          source: |
            require "openlayer"

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

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

            puts(api_key)
        - lang: curl
          source: |
            curl --request GET \
              --url https://api.openlayer.com/v1/workspaces/182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e/api-keys/3f2b9c1e-8a4d-4e6f-9b7a-1c2d3e4f5a6b \
              --header 'Authorization: Bearer <token>'
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.

````