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

Retrieve admin API key

client.admin.organization.adminAPIKeys.retrieve(keyID, options?): AdminAPIKey { id, created_at, expires_at, 5 more }
GET
/organization/admin_api_keys/{key_id}

Retrieve a single organization API key

Parameters
keyID: string

The ID of the API key.

Returns
AdminAPIKey { id, created_at, expires_at, 5 more }

Represents an individual Admin API key in an org.

id: string

The identifier, which can be referenced in API endpoints

created_at: number

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

formatunixtime
expires_at: number | null

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

formatunixtime
object: "organization.admin_api_key"

The object type, which is always organization.admin_api_key

owner: Owner { id, created_at, name, 3 more }
redacted_value: string

The redacted value of the API key

last_used_at?: number | null

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

formatunixtime
name?: string | null

The name of the API key

Retrieve admin API key

import OpenAI from 'openai';

const client = new OpenAI({
  adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted
});

const adminAPIKey = await client.admin.organization.adminAPIKeys.retrieve('key_id');

console.log(adminAPIKey.id);
{
  "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"
  }
}
Returns Examples
{
  "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"
  }
}