Project service accounts

Manage service accounts within a project. A service account is a bot user that is not associated with a user. If a user leaves an organization, their keys and membership in projects will no longer work. Service accounts do not have this limitation. However, service accounts can also be deleted from a project.source

List project service accounts

get https://api.openai.com/v1/organization/projects/{project_id}/service_accounts

Returns a list of service accounts in the project.source

Path parameters

The ID of the project.source

Query parameters

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

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.source

Returns

A list of ProjectServiceAccount objects.source

Example request
1
2
3
curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts?after=custom_id&limit=20 \
  -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
  -H "Content-Type: application/json"
Response

Create project service account

post https://api.openai.com/v1/organization/projects/{project_id}/service_accounts

Creates a new service account in the project. This also returns an unredacted API key for the service account.source

Path parameters

The ID of the project.source

Request body

The name of the service account being created.source

Returns

The created ProjectServiceAccount object.source

Example request
1
2
3
4
5
6
curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/service_accounts \
  -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "name": "Production App"
  }'
Response

Retrieve project service account

get https://api.openai.com/v1/organization/projects/{project_id}/service_accounts/{service_account_id}

Retrieves a service account in the project.source

Path parameters

The ID of the project.source

The ID of the service account.source

Returns

The ProjectServiceAccount object matching the specified ID.source

Example request
1
2
3
curl https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \
  -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
  -H "Content-Type: application/json"
Response

Delete project service account

delete https://api.openai.com/v1/organization/projects/{project_id}/service_accounts/{service_account_id}

Deletes a service account from the project.source

Path parameters

The ID of the project.source

The ID of the service account.source

Returns

Confirmation of service account being deleted, or an error in case of an archived project, which has no service accountssource

Example request
1
2
3
curl -X DELETE https://api.openai.com/v1/organization/projects/proj_abc/service_accounts/svc_acct_abc \
  -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
  -H "Content-Type: application/json"
Response

The project service account object

Represents an individual service account in a project.source

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

The identifier, which can be referenced in API endpointssource

The name of the service accountsource

owner or membersource

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

OBJECT The project service account object
1
2
3
4
5
6
7
{
    "object": "organization.project.service_account",
    "id": "svc_acct_abc",
    "name": "Service Account",
    "role": "owner",
    "created_at": 1711471533
}