SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
13 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
1.5 KB · 23 lines shellscript
Raw Blame History
1#!/usr/bin/env bash2# List organization users / invites / projects / admin keys / roles / groups (read-only Admin API).3# STATUS: ACCOUNT_RESTRICTED — verified 2026-09-18 with our project key: every call returned4#   403 {"error":"You have insufficient permissions for this operation. Missing scopes: api.management.read ..."}5#   (roles -> api.roles.read, groups -> api.groups.read, audit_logs -> HTTP 401 api.audit_logs.read).6# With an Admin API key (OPENAI_ADMIN_KEY, created at platform.openai.com/settings/organization/admin-keys) the same7# calls return {"object":"list","data":[...],"first_id","last_id","has_more"}.8# Usage: source scripts/lib.sh && bash examples/openai/admin/list_org_resources.sh9set -euo pipefail10source "$(dirname "$0")/../../../scripts/lib.sh"11KEY="${OPENAI_ADMIN_KEY:-$OPENAI_API_KEY}"   # falls back to the project key => expect 4031213call() { # call PATH14  local out; out="$(mktemp)"15  local st; st="$(curl -sS -o "$out" -w '%{http_code}' "https://api.openai.com$1" \16        -H "Authorization: Bearer $KEY" -H "Content-Type: application/json")"17  log_request openai GET "${1%%\?*}" "$st" 0 "admin example list_org_resources.sh"18  printf '%s %s\n' "$st" "$1"; mask < "$out" | head -c 600; echo; rm -f "$out"19}20for p in "/v1/organization/users?limit=5" "/v1/organization/invites?limit=5" "/v1/organization/projects?limit=5&include_archived=false" \21         "/v1/organization/admin_api_keys?limit=5" "/v1/organization/roles?limit=5" "/v1/organization/groups?limit=5" \22         "/v1/organization/audit_logs?limit=5"; do call "$p"; done23