Memos unofficial
POST/api/v1/users

Create a user

Creates a user with a username, role, and state, along with any optional profile details. Set validateOnly to validate the request without creating the user, or pass requestId to make repeated creation requests idempotent.

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

3 parameters · 11 body fields
userIdstringoptional
Optional resource ID; if supplied, it must equal the body `username` and match `^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$`.
validateOnlybooleanoptional
Whether to validate the request without creating the user.
requestIdstringoptional
An idempotency token to ensure repeated creation requests have the same result.

The user details to create. Supply role, username, and state; creation timestamps are output-only.

namestringoptional
The resource name of the user. Format: users/{user}
rolestringrequired
The role of the user.
Allowed:ROLE_UNSPECIFIEDADMINUSER
usernamestringrequired
Required. The unique username for login.
emailstringoptional
Optional. The email address of the user. Stored trimmed and lowercased; empty means no address. An address belongs to at most one user on the instance, so writes that would reuse one fail with ALREADY_EXISTS.
displayNamestringoptional
Optional. The display name of the user.
avatarUrlstringoptional
Optional. The avatar URL of the user.
descriptionstringoptional
Optional. The description of the user.
passwordstringoptional
Input only. The password for the user.
statestringrequired
The state of the user.
Allowed:STATE_UNSPECIFIEDNORMALARCHIVED
createTimestringoptional
Output only. The creation timestamp.
updateTimestringoptional
Output only. The last update timestamp.

2 status codes
200Returns the user resource, including its role, username, profile details, state, and timestamps.
namestringoptional
The resource name of the user. Format: users/{user}
rolestringrequired
The role of the user.
Allowed:ROLE_UNSPECIFIEDADMINUSER
usernamestringrequired
Required. The unique username for login.
emailstringoptional
Optional. The email address of the user. Stored trimmed and lowercased; empty means no address. An address belongs to at most one user on the instance, so writes that would reuse one fail with ALREADY_EXISTS.
displayNamestringoptional
Optional. The display name of the user.
avatarUrlstringoptional
Optional. The avatar URL of the user.
descriptionstringoptional
Optional. The description of the user.
passwordstringoptional
Input only. The password for the user.
statestringrequired
The state of the user.
Allowed:STATE_UNSPECIFIEDNORMALARCHIVED
createTimestringoptional
Output only. The creation timestamp.
updateTimestringoptional
Output only. The last update timestamp.
defaultDefault error response
codeintegeroptional
The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].
messagestringoptional
A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.
detailsarray<object>optional
A list of messages that carry the error details. There is a common set of message types for APIs to use.

Error handling

If supplied, the userId query parameter must equal the body's username and match the specified username pattern. The validateOnly query parameter controls whether the request creates a user, and requestId can identify repeated requests. The body requires role, username, and state; role must be ROLE_UNSPECIFIED, ADMIN, or USER, and state must be STATE_UNSPECIFIED, NORMAL, or ARCHIVED.