Method: projects.locations.instances.users.create

Creates a User in an instance. The server assigns the User ID.

user.roles can be empty or contain only SIGNER, which is ACTIVE immediately. ADMIN and POLICY_AUTHOR need Admin approval, so this method cannot grant them. A request with either fails with INVALID_ARGUMENT. To grant them, a client creates the User and then calls users.enableRole.

The first Admins of an instance are the exception. While fewer than 2 active Admins have an authorizationKey, a caller can create Users with roles set to [ADMIN] and an empty authorizationKey. The caller does not need to be a User. Each created User starts with empty roles and ADMIN in PENDING_ACTIVE, and activates ADMIN by setting their own key with users.patch. When 2 Admins have a key, this setup ends: ADMIN cannot be granted here, and any remaining setup Users have ADMIN set to DISABLED (though they can still set their own key with users.patch). Until the setup ends, other calls that need ADMIN fail with FAILED_PRECONDITION.

Returns the following error codes:

  • INVALID_ARGUMENT: user is malformed. For example, principal is empty, team is set without SIGNER or missing with it, or authorizationKey does not parse. During the setup of the first Admins, a request for ADMIN also fails if authorizationKey is set.
  • ALREADY_EXISTS: A User with the same principal already exists, or requestId was already used for a different User.
  • FAILED_PRECONDITION: team does not exist in the instance, or the request needs ADMIN and fewer than 2 active Admins have an authorizationKey.

HTTP request

POST https://mpc.googleapis.com/v1beta/{parent=projects/*/locations/*/instances/*}/users

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
parent

string

Required. The instance to create the User in. Format: projects/{project}/locations/{location}/instances/{instance} It takes the form projects/{project}/locations/{location}/instances/{instance}.

Query parameters

Parameters
requestId

string

Optional. An idempotency key. The server generates User IDs, so a client must set this field to retry a users.create request safely. If an earlier request with the same requestId succeeded, the server returns the User that it created and does not create a second User. If the retry has a different principal, or sets an authorizationKey that differs from the User's key, it fails with ALREADY_EXISTS (REQUEST_ID_ALREADY_USED).

Must be a UUID4 and not the zero UUID.

Request body

The request body contains an instance of User.

Response body

If successful, the response body contains a newly created instance of User.

Authorization scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Authentication Overview.