Skip to content
Primary navigation

List project service accounts

admin.organization.projects.service_accounts.list(strproject_id, ServiceAccountListParams**kwargs) -> SyncConversationCursorPage[ProjectServiceAccount]
GET/organization/projects/{project_id}/service_accounts

Returns a list of service accounts in the project.

ParametersExpand Collapse
project_id: str
after: Optional[str]

A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

limit: Optional[int]

A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

ReturnsExpand Collapse
class ProjectServiceAccount: …

Represents an individual service account in a project.

id: str

The identifier, which can be referenced in API endpoints

created_at: int

The Unix timestamp (in seconds) of when the service account was created

formatunixtime
name: str

The name of the service account

object: Literal["organization.project.service_account"]

The object type, which is always organization.project.service_account

role: Literal["owner", "member"]

owner or member

One of the following:
"owner"
"member"

List project service accounts

import os
from openai import OpenAI

client = OpenAI(
    admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"),  # This is the default and can be omitted
)
page = client.admin.organization.projects.service_accounts.list(
    project_id="project_id",
)
page = page.data[0]
print(page.id)
{
    "object": "list",
    "data": [
        {
            "object": "organization.project.service_account",
            "id": "svc_acct_abc",
            "name": "Service Account",
            "role": "owner",
            "created_at": 1711471533
        }
    ],
    "first_id": "svc_acct_abc",
    "last_id": "svc_acct_xyz",
    "has_more": false
}
Returns Examples
{
    "object": "list",
    "data": [
        {
            "object": "organization.project.service_account",
            "id": "svc_acct_abc",
            "name": "Service Account",
            "role": "owner",
            "created_at": 1711471533
        }
    ],
    "first_id": "svc_acct_abc",
    "last_id": "svc_acct_xyz",
    "has_more": false
}