Users
User lookup.
Methods on this page are called through client.users.
client.users.create
client.users.create(request: CreateUserRequest, requestOptions?: RequestOptions): Promise<UserResponseShape>Creates one dormant human user after requiring instance-wide CREATE_USER authority. Creation does not issue a credential or create a role, grant, or authentication mapping.
HTTP: POST /v1/users
Parameters
| Parameter | Type | Description |
|---|---|---|
request | CreateUserRequest | Request body. |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<UserResponseShape>
Example
const createdUser = await client.users.create({
email: "[email protected]",
username: "alex",
displayName: "Alex Example",
labels: { team: "search" },
});client.users.createEnrollment
client.users.createEnrollment(userId: string, request: CreateUserEnrollmentRequest, requestOptions?: RequestOptions): Promise<CreateUserEnrollmentResponseShape>Creates a short-lived, one-time enrollment credential for an existing dormant human. Requires MANAGE_USER_ENROLLMENT with ANY or EXACT authority on the target user. The raw credential is returned only once. rotateExisting atomically revokes and replaces a live enrollment; an expired enrollment is replaced automatically.
HTTP: POST /v1/users/{userId}/enrollments
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | Human-user UUID |
request | CreateUserEnrollmentRequest | Request body. |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<CreateUserEnrollmentResponseShape>
Example
const createdEnrollment = await client.users.createEnrollment(createdUser.userId, {
rotateExisting: true,
});
// Save createdEnrollment.enrollmentToken now; it is returned only once.client.users.delete
client.users.delete(id: string, requestOptions?: RequestOptions): Promise<void>Permanently soft-deletes the user and invalidates credentials acting for that subject. The GoodMem instance owner cannot be deleted; transfer ownership first. Repeating an authorized delete succeeds without rewriting audit data.
HTTP: DELETE /v1/users/{id}
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | User UUID |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<void>
Example
await client.users.delete(updatedUser.userId);client.users.get
client.users.get(options?: UsersGetOptions, requestOptions?: RequestOptions): Promise<UserResponseShape>Returns a user selected by UUID after applying READ_USER authority. includeDeleted permits an authorized caller to inspect a permanent tombstone; it does not grant additional authority.
HTTP: GET /v1/users/{id}
Parameters
| Parameter | Type | Description |
|---|---|---|
options | UsersGetOptions optional | Exactly one of id or email. |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<UserResponseShape>
Example
Example 1:
const userById = await client.users.get({ id: "your-user-id" });
console.log(userById.email);Example 2:
const userByEmail = await client.users.get({ email: "[email protected]" });
console.log(userByEmail.userId);client.users.getByUsername
client.users.getByUsername(username: string, options?: UsersGetByUsernameOptions, requestOptions?: RequestOptions): Promise<UserResponseShape>Returns a user selected by exact username after applying READ_USER authority. includeDeleted permits an authorized caller to inspect a permanent tombstone; it does not grant additional authority. Missing and unauthorized matches both return 404 so this guessable identifier cannot reveal whether a user exists.
HTTP: GET /v1/users/username/{username}
Parameters
| Parameter | Type | Description |
|---|---|---|
username | string | Exact username |
options | UsersGetByUsernameOptions optional | Optional query parameters. |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<UserResponseShape>
Example
const userByUsername = await client.users.getByUsername("alex");
console.log(userByUsername.email);client.users.getEnrollment
client.users.getEnrollment(userId: string, enrollmentId: string, requestOptions?: RequestOptions): Promise<UserEnrollmentResponseShape>Returns non-secret metadata for one current or historical enrollment. The target user is resolved before the enrollment, and MANAGE_USER_ENROLLMENT with ANY or EXACT authority on that user is required. Raw enrollment tokens are never returned.
HTTP: GET /v1/users/{userId}/enrollments/{enrollmentId}
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | Human-user UUID |
enrollmentId | string | Enrollment UUID |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<UserEnrollmentResponseShape>
Example
const enrollment = await client.users.getEnrollment(
createdUser.userId,
createdEnrollment.enrollment.enrollmentId,
);client.users.list
client.users.list(options?: UsersListOptions, requestOptions?: RequestOptions): Promise<Page<UserResponseShape>>Requires LIST_USER on the GoodMem instance and READ_USER on each returned row. Authorization, label filtering, lifecycle filtering, and keyset pagination run in PostgreSQL. includeDeleted expands the lifecycle view but grants no access. includeEnrollmentSummary requests non-secret bootstrap posture only on active rows where MANAGE_USER_ENROLLMENT is independently authorized.
LABEL FILTERS: Label filters accept either label.<key>=<value> or label[key]=value (for example, label.environment=production or label[environment]=production).
HTTP: GET /v1/users
Parameters
| Parameter | Type | Description |
|---|---|---|
options | UsersListOptions optional | Optional query parameters. |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<Page<UserResponseShape>>
Example
for await (const user of await client.users.list({ maxResults: 25 })) {
console.log(user.userId, user.email);
}client.users.listEnrollments
client.users.listEnrollments(userId: string, options?: UsersListEnrollmentsOptions, requestOptions?: RequestOptions): Promise<Page<UserEnrollmentResponseShape>>Returns one newest-first page containing pending, expired, consumed, and revoked enrollment metadata. MANAGE_USER_ENROLLMENT with ANY or EXACT authority on the target user is required. The page never contains raw credentials.
HTTP: GET /v1/users/{userId}/enrollments
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | Human-user UUID |
options | UsersListEnrollmentsOptions optional | Optional query parameters. |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<Page<UserEnrollmentResponseShape>>
Example
for await (const enrollment of await client.users.listEnrollments(createdUser.userId)) {
console.log(enrollment.enrollmentId, enrollment.status);
}client.users.me
client.users.me(requestOptions?: RequestOptions): Promise<UserResponseShape>Returns the human-user profile associated with the authenticated principal. Service principals do not have a human-user profile.
HTTP: GET /v1/users/me
Parameters
| Parameter | Type | Description |
|---|---|---|
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<UserResponseShape>
Example
const me = await client.users.me();
console.log(me.email, me.userId);client.users.revokeEnrollment
client.users.revokeEnrollment(userId: string, enrollmentId: string, requestOptions?: RequestOptions): Promise<void>Permanently revokes one outstanding enrollment after requiring MANAGE_USER_ENROLLMENT on its target user. Repeating an authorized revocation succeeds without replacing its original audit provenance. Consumed enrollments cannot be revoked.
HTTP: DELETE /v1/users/{userId}/enrollments/{enrollmentId}
Parameters
| Parameter | Type | Description |
|---|---|---|
userId | string | Human-user UUID |
enrollmentId | string | Enrollment UUID |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<void>
Example
await client.users.revokeEnrollment(createdUser.userId, enrollment.enrollmentId);client.users.update
client.users.update(id: string, request: UpdateUserRequest, requestOptions?: RequestOptions): Promise<UserResponseShape>Updates only fields present in the request. Empty username or displayName values clear those optional fields. Updating a deleted user fails with 412.
HTTP: PUT /v1/users/{id}
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | User UUID |
request | UpdateUserRequest | Request body. |
requestOptions | RequestOptions optional | Per-call signal, timeout, or headers. |
Returns: Promise<UserResponseShape>
Example
const updatedUser = await client.users.update(createdUser.userId, {
displayName: "Alexandra Example",
});Data Models
Interfaces
CreateUserEnrollmentRequest
Options for issuing a one-time enrollment credential to the user named by the request path.
| Field | Type | Required | Description |
|---|---|---|---|
enrollmentId | string | null | no | Optional client-provided enrollment UUID; generated when omitted. |
rotateExisting | boolean | null | no | Whether an existing live enrollment may be revoked and atomically replaced. |
CreateUserEnrollmentResponse
New enrollment metadata and its one-time raw enrollment credential.
| Field | Type | Required | Description |
|---|---|---|---|
enrollment | UserEnrollmentResponse | yes | OUTPUT_ONLY; non-secret metadata for the created enrollment. |
enrollmentToken | string | yes | OUTPUT_ONLY; one-time raw enrollment credential. Save and deliver it securely. |
CreateUserRequest
Creates a human user without creating a credential, role assignment, grant, or external authentication mapping.
| Field | Type | Required | Description |
|---|---|---|---|
userId | string | null | no | Optional client-provided user UUID; generated by the server when omitted. |
email | string | yes | Unique, nonempty email address. |
username | string | null | no | Optional unique username. |
displayName | string | null | no | Optional human-facing display name. |
labels | Record<string, string> | null | no | Optional labels for organization and filtering. At most 20 entries; keys and values contain at most 255 characters; keys use [a-z0-9._-]. |
ListUserEnrollmentsResponse
One stable page of a human user's enrollment history.
| Field | Type | Required | Description |
|---|---|---|---|
enrollments | Array<UserEnrollmentResponse> | yes | OUTPUT_ONLY; enrollments ordered newest first. |
nextToken | string | null | no | OUTPUT_ONLY; opaque continuation token, absent after the final page. |
ListUsersResponse
One authorization-filtered page of human users.
| Field | Type | Required | Description |
|---|---|---|---|
users | Array<UserResponse> | yes | OUTPUT_ONLY; users in stable keyset order. |
nextToken | string | null | no | OUTPUT_ONLY; opaque continuation token, omitted after the final page. |
UpdateUserRequest
Updates explicitly present profile fields. Empty username or displayName clears that optional field; an omitted field remains unchanged.
| Field | Type | Required | Description |
|---|---|---|---|
email | string | null | no | Replacement email. A present empty value is invalid. |
username | string | null | no | Replacement username. An empty string clears the username. |
displayName | string | null | no | Replacement display name. An empty string clears the display name. |
replaceLabels | Record<string, string> | null | no | Complete replacement label map; an empty map clears all labels and is mutually exclusive with mergeLabels. At most 20 entries; keys and values contain at most 255 characters; keys use [a-z0-9._-]. |
mergeLabels | Record<string, string> | null | no | Labels to upsert; must contain at least one entry and is mutually exclusive with replaceLabels. The final stored map may contain at most 20 entries; keys and values contain at most 255 characters; keys use [a-z0-9._-]. |
UserEnrollmentResponse
Non-secret lifecycle metadata for a human user's one-time enrollment credential.
| Field | Type | Required | Description |
|---|---|---|---|
enrollmentId | string | yes | OUTPUT_ONLY; immutable enrollment UUID. |
userId | string | yes | OUTPUT_ONLY; UUID of the human user invited to enroll. |
credentialPrefix | string | yes | OUTPUT_ONLY; non-secret prefix that identifies the enrollment credential safely. |
status | "PENDING" | "EXPIRED" | "CONSUMED" | "REVOKED" | yes | OUTPUT_ONLY; current derived enrollment lifecycle state. |
expiresAt | number | yes | OUTPUT_ONLY; exclusive completion deadline in milliseconds since epoch. |
consumedApiKeyId | string | null | no | OUTPUT_ONLY; initial API-key UUID, present after consumption. |
createdAt | number | yes | OUTPUT_ONLY; enrollment issuance time in milliseconds since epoch. |
consumedAt | number | null | no | OUTPUT_ONLY; first-completion time, absent before consumption. |
revokedAt | number | null | no | OUTPUT_ONLY; permanent revocation time, absent while unrevoked. |
createdById | string | yes | OUTPUT_ONLY; exact principal or API-key actor that issued the enrollment. |
revokedById | string | null | no | OUTPUT_ONLY; exact revoking actor UUID, absent while unrevoked. |
UserEnrollmentSummary
Non-secret enrollment posture for one active human user.
| Field | Type | Required | Description |
|---|---|---|---|
bootstrapEligible | boolean | yes | Whether no enrollment has been consumed and the user has no subject API key. |
openEnrollmentStatus | "PENDING" | "EXPIRED" | null | no | State of the open enrollment, when one exists; present exactly with openEnrollmentExpiresAt. |
openEnrollmentExpiresAt | number | null | no | Exclusive open-enrollment completion deadline in epoch milliseconds; present exactly with openEnrollmentStatus. |
UserResponse
A durable human user profile and its lifecycle metadata.
| Field | Type | Required | Description |
|---|---|---|---|
userId | string | yes | OUTPUT_ONLY; immutable user UUID. |
email | string | yes | OUTPUT_ONLY; unique email address. |
displayName | string | null | no | OUTPUT_ONLY; optional human-facing display name. |
username | string | null | no | OUTPUT_ONLY; optional unique username. |
labels | Record<string, string> | yes | OUTPUT_ONLY; mutable labels attached to the user principal. At most 20 entries; keys and values contain at most 255 characters; keys use [a-z0-9._-]. |
enrollmentSummary | UserEnrollmentSummary | null | no | OUTPUT_ONLY; enrollment posture when requested and independently authorized. |
deletedAt | number | null | no | OUTPUT_ONLY; permanent deletion time in milliseconds, absent while active. |
deletedById | string | null | no | OUTPUT_ONLY; exact deleting actor UUID, absent while active. |
createdAt | number | yes | OUTPUT_ONLY; creation time in milliseconds since the epoch. |
updatedAt | number | yes | OUTPUT_ONLY; most recent mutation time in milliseconds since the epoch. |
createdById | string | yes | OUTPUT_ONLY; exact creating actor UUID. |
updatedById | string | yes | OUTPUT_ONLY; exact actor UUID for the most recent mutation. |
Response Shapes
Response shape types model values returned by the SDK after forward-compatible unknown enum strings are coerced to null.
CreateUserEnrollmentResponseShape
| Field | Type | Required | Description |
|---|---|---|---|
enrollment | UserEnrollmentResponseShape | yes | OUTPUT_ONLY; non-secret metadata for the created enrollment. |
enrollmentToken | string | yes | OUTPUT_ONLY; one-time raw enrollment credential. Save and deliver it securely. |
ListUserEnrollmentsResponseShape
| Field | Type | Required | Description |
|---|---|---|---|
enrollments | Array<UserEnrollmentResponseShape> | yes | OUTPUT_ONLY; enrollments ordered newest first. |
nextToken | string | null | no | OUTPUT_ONLY; opaque continuation token, absent after the final page. |
ListUsersResponseShape
| Field | Type | Required | Description |
|---|---|---|---|
users | Array<UserResponseShape> | yes | OUTPUT_ONLY; users in stable keyset order. |
nextToken | string | null | no | OUTPUT_ONLY; opaque continuation token, omitted after the final page. |
UserEnrollmentResponseShape
| Field | Type | Required | Description |
|---|---|---|---|
enrollmentId | string | yes | OUTPUT_ONLY; immutable enrollment UUID. |
userId | string | yes | OUTPUT_ONLY; UUID of the human user invited to enroll. |
credentialPrefix | string | yes | OUTPUT_ONLY; non-secret prefix that identifies the enrollment credential safely. |
status | "PENDING" | "EXPIRED" | "CONSUMED" | "REVOKED" | null | yes | OUTPUT_ONLY; current derived enrollment lifecycle state. |
expiresAt | number | yes | OUTPUT_ONLY; exclusive completion deadline in milliseconds since epoch. |
consumedApiKeyId | string | null | no | OUTPUT_ONLY; initial API-key UUID, present after consumption. |
createdAt | number | yes | OUTPUT_ONLY; enrollment issuance time in milliseconds since epoch. |
consumedAt | number | null | no | OUTPUT_ONLY; first-completion time, absent before consumption. |
revokedAt | number | null | no | OUTPUT_ONLY; permanent revocation time, absent while unrevoked. |
createdById | string | yes | OUTPUT_ONLY; exact principal or API-key actor that issued the enrollment. |
revokedById | string | null | no | OUTPUT_ONLY; exact revoking actor UUID, absent while unrevoked. |
UserEnrollmentSummaryResponseShape
| Field | Type | Required | Description |
|---|---|---|---|
bootstrapEligible | boolean | yes | Whether no enrollment has been consumed and the user has no subject API key. |
openEnrollmentStatus | "PENDING" | "EXPIRED" | null | no | State of the open enrollment, when one exists; present exactly with openEnrollmentExpiresAt. |
openEnrollmentExpiresAt | number | null | no | Exclusive open-enrollment completion deadline in epoch milliseconds; present exactly with openEnrollmentStatus. |
UserResponseShape
| Field | Type | Required | Description |
|---|---|---|---|
userId | string | yes | OUTPUT_ONLY; immutable user UUID. |
email | string | yes | OUTPUT_ONLY; unique email address. |
displayName | string | null | no | OUTPUT_ONLY; optional human-facing display name. |
username | string | null | no | OUTPUT_ONLY; optional unique username. |
labels | Record<string, string> | yes | OUTPUT_ONLY; mutable labels attached to the user principal. At most 20 entries; keys and values contain at most 255 characters; keys use [a-z0-9._-]. |
enrollmentSummary | UserEnrollmentSummaryResponseShape | null | no | OUTPUT_ONLY; enrollment posture when requested and independently authorized. |
deletedAt | number | null | no | OUTPUT_ONLY; permanent deletion time in milliseconds, absent while active. |
deletedById | string | null | no | OUTPUT_ONLY; exact deleting actor UUID, absent while active. |
createdAt | number | yes | OUTPUT_ONLY; creation time in milliseconds since the epoch. |
updatedAt | number | yes | OUTPUT_ONLY; most recent mutation time in milliseconds since the epoch. |
createdById | string | yes | OUTPUT_ONLY; exact creating actor UUID. |
updatedById | string | yes | OUTPUT_ONLY; exact actor UUID for the most recent mutation. |