POST
/organization/projects/{project_id}/service_accounts/{service_account_id}/api_keysCreate an API key for a service account
Creates an API key for a service account in a project. Use name and scopes to set the key's label and scopes, and expires_in_seconds to configure its lifetime. The response includes the unredacted key value and its identifier.
- IdempotentThe SDK sends
Idempotency-Key, so a retried request is only applied once.
project_idstringrequired
The ID of the project in which the service account is managed.
service_account_idstringrequired
The ID of the service account for which to create an API key.
Optional service account API key configuration.
namestringoptional
API key name.
scopesarray<string>optional
API key scopes.
expires_in_secondsintegeroptional
The number of seconds until the API key expires. Must be between 1 and 31536000, or null.
200Returns the created service account API key, including its unredacted value, name, creation timestamp, and identifier.
objectstringrequired
The object type, which is always `organization.project.service_account.api_key`
valuestringrequired
The unredacted API key value.
namestringrequired
The name of the API key.
created_atintegerrequired
The Unix timestamp (in seconds) when the API key was created.
expires_atintegeroptional
The Unix timestamp (in seconds) when the API key expires, or null if it does not expire.
idstringrequired
The identifier of the API key.
400Returned when the API key request is invalid or the project is archived.
errorobjectrequired
403Returned when the caller does not have permission to perform this operation.
errorobjectrequired
Details about the permission error.
404Returned when the project or service account was not found.
errorobjectrequired
409Returned when the service account already has an API key and cannot create another.
errorobjectrequired
429Returned when management requests exceed the allowed rate; reduce the request rate and try again later.
errorobjectrequired
Error handling
expires_in_seconds must be between 1 and 31536000 seconds when provided, or may be null. A 400 is returned when the API key request is invalid or the project is archived; a 403 is returned when the authenticated user lacks permission; a 404 is returned when the project or service account is not found. A 409 is returned when the service account already has an API key, and a 429 is returned when management requests exceed the allowed rate; retry later.