Primary navigation

Legacy APIs

Admin APIs

Programmatically manage organization resources and administrative workflows.

Admin APIs let you automate organization management workflows such as user invitations, audit log review, project administration, API key management, and rate limit operations. Use them for back-office automation, security workflows, and operational tooling that should run outside the dashboard.

For endpoint details, see the Administration API reference, including Admin API keys, Invites, Users, Projects, and Audit logs.

Use an Admin API key with the SDK

To access these endpoints, create an Admin API key. Admin API keys cannot be used for non-administration endpoints.

Support for Admin APIs was added in these SDK versions, which may require updating your SDK version:

  • Node: 6.36.0
  • Python: 2.34.0
  • Go: 3.34.0
  • Ruby: 0.61.0
  • Java: 4.34.0

Set OPENAI_ADMIN_KEY, then initialize the SDK for your language.

Set up the SDK with an Admin API key
1
2
3
4
5
import OpenAI from "openai";

const client = new OpenAI({
  adminAPIKey: process.env.OPENAI_ADMIN_KEY,
});

Invite a user by email

Use the Invites endpoint to send an organization invitation to an email address.

Invite a user by email
1
2
3
4
5
6
const invite = await client.admin.organization.invites.create({
  email: "user@example.com",
  role: "reader",
});

console.log(invite.id);

Retrieve audit logs

Use the Audit Logs endpoint to list recent user actions and configuration changes for the organization.

Retrieve audit logs
1
2
3
4
5
const auditLogs = await client.admin.organization.auditLogs.list({
  limit: 10,
});

console.log(auditLogs.data);