POST/organization/projects/{project_id}/service_accounts

Create a project service account

Creates a service account in a project and, by default, returns an unredacted API key for it. Supply a name; set create_service_account_only to create the account without default roles or an API key, and use expires_in_seconds to configure the initial key's lifetime.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

1 parameter · 3 body fields
project_idstringrequired
The ID of the project in which to create the service account.

Service account creation details. name is required; other fields control whether to create an API key and its expiration.

namestringrequired
The name of the service account being created.
create_service_account_onlybooleanoptional
Set to true to create the service account without default roles or an API key.
expires_in_secondsintegeroptional
Number of seconds until the initial API key expires. If omitted or null, the key does not expire unless the effective organization or project policy requires an expiration. When a policy sets a maximum lifetime, this value must be provided and must not exceed that limit. A non-null value cannot be used when `create_service_account_only` is true.

6 status codes
200Returns the created service account, including its ID, name, role, creation timestamp, and API key when one is created.
objectstringrequired
Allowed:organization.project.service_account
idstringrequired
namestringrequired
rolestringrequired
Service accounts created with default project membership have role `member`. Accounts created with `create_service_account_only` have role `none`.
Allowed:membernone
created_atintegerrequired
api_keyobjectrequired
201Returns the created service account, including its ID, name, role, creation timestamp, and API key when one is created.
objectstringrequired
Allowed:organization.project.service_account
idstringrequired
namestringrequired
rolestringrequired
Service accounts created with default project membership have role `member`. Accounts created with `create_service_account_only` have role `none`.
Allowed:membernone
created_atintegerrequired
api_keyobjectrequired
400Returned when the project is archived.
errorobjectrequired
403Returned when the caller does not have permission to create a project service account.
errorobjectrequired
Details about the permission error.
404Returned when a requested project, user, service account, or API key is not found.
errorobjectrequired
429Returned when management requests exceed the allowed rate; reduce the request rate and try again later.
errorobjectrequired

Error handling

A 400 is returned when the project is archived; a 403 when the authenticated user lacks permission; a 404 when a requested project, user, service account, or API key is not found; and a 429 when management requests are being sent too frequently. name is required, and expires_in_seconds, when non-null, must be between 1 and 31536000; if omitted or null, the key does not expire unless an effective organization or project policy requires an expiration. The project_id path parameter must identify an existing project.