Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation
Theme

Retrieve admin API key

AdminApiKey admin().organization().adminApiKeys().retrieve(params = AdminApiKeyRetrieveParams.none(), requestOptions = RequestOptions.none())
GET
/organization/admin_api_keys/{key_id}

Retrieve a single organization API key

Retrieve admin API key

package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.adminapikeys.AdminApiKey;
import com.openai.models.admin.organization.adminapikeys.AdminApiKeyRetrieveParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        AdminApiKey adminApiKey = client.admin().organization().adminApiKeys().retrieve("key_id");
    }
}
Response example
{
  "object": "organization.admin_api_key",
  "id": "key_abc",
  "name": "Main Admin Key",
  "redacted_value": "sk-admin...xyz",
  "created_at": 1711471533,
  "expires_at": null,
  "last_used_at": 1711471534,
  "owner": {
    "type": "user",
    "object": "organization.user",
    "id": "user_123",
    "name": "John Doe",
    "created_at": 1711471533,
    "role": "owner"
  }
}
Parameters
AdminApiKeyRetrieveParams params
Optional<String> keyId

The ID of the API key.

Returns
class AdminApiKey:

Represents an individual Admin API key in an org.

String id

The identifier, which can be referenced in API endpoints

long createdAt

The Unix timestamp (in seconds) of when the API key was created

formatunixtime
Optional<Long> expiresAt

The Unix timestamp (in seconds) of when the API key expires

formatunixtime
JsonValue; object_
constant
constant

The object type, which is always organization.admin_api_key

String redactedValue

The redacted value of the API key

Optional<Long> lastUsedAt

The Unix timestamp (in seconds) of when the API key was last used

formatunixtime
Optional<String> name

The name of the API key

Returns Examples
Response example
{
  "object": "organization.admin_api_key",
  "id": "key_abc",
  "name": "Main Admin Key",
  "redacted_value": "sk-admin...xyz",
  "created_at": 1711471533,
  "expires_at": null,
  "last_used_at": 1711471534,
  "owner": {
    "type": "user",
    "object": "organization.user",
    "id": "user_123",
    "name": "John Doe",
    "created_at": 1711471533,
    "role": "owner"
  }
}