Primary navigation
Production

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, spend limits and alerts, data retention, 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, Spend limits, 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
javascript
1
2
3
4
5
import OpenAI from "openai";

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

Restrict model access for projects

Use project model permissions to set an allowlist or denylist for a project. Set mode to allow_list to allow only the listed models, or set mode to deny_list to block the listed models while allowing other available models. Model IDs must be visible to the organization, including visible fine-tuned model snapshots.

Set a project model allowlist/denylist
javascript
1
2
3
4
5
6
7
const modelPermissions =
  await client.admin.organization.projects.modelPermissions.update("proj_abc", {
    mode: "allow_list",
    model_ids: ["gpt-4.1", "o3"],
  });

console.log(modelPermissions.mode);

Set an organization spend limit

Use the Spend Limits endpoint to create or replace your organization’s monthly hard spend limit. Set threshold_amount in cents. The following example sets a $100 monthly limit:

1
2
3
4
5
6
7
8
curl -X POST https://api.openai.com/v1/organization/spend_limit \
  -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "threshold_amount": 10000,
    "currency": "USD",
    "interval": "month"
  }'

When tracked spend reaches a hard limit, affected API requests return a 429 error. For details, see the spend limits guide.

Manage spend limit alerts

Use project spend alerts to notify your team when project spend reaches a threshold. Threshold amounts are specified in cents.

Create a project spend limit alert
javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const spendAlert = await client.admin.organization.projects.spendAlerts.create(
  "proj_abc",
  {
    currency: "USD",
    interval: "month",
    notification_channel: {
      recipients: ["billing@example.com"],
      type: "email",
      subject_prefix: "[OpenAI spend]",
    },
    threshold_amount: 50000,
  }
);

console.log(spendAlert.id);

Manage data retention

Use project data retention controls to override or inherit the organization’s retention policy for a project. Set retention_type to organization_default to inherit the organization setting.

Set project data retention
javascript
1
2
3
4
5
6
const dataRetention =
  await client.admin.organization.projects.dataRetention.update("proj_abc", {
    retention_type: "organization_default",
  });

console.log(dataRetention.type);

Invite a user by email

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

Invite a user by email
javascript
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
javascript
1
2
3
4
5
const auditLogs = await client.admin.organization.auditLogs.list({
  limit: 10,
});

console.log(auditLogs.data);

Docs agent

Loading docs agent...

Morty Proxy This is a proxified and sanitized view of the page, visit original site.