GoodMemGoodMem

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

ParameterTypeDescription
requestCreateUserRequestRequest body.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;UserResponseShape&gt;

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/&#123;userId&#125;/enrollments

Parameters

ParameterTypeDescription
userIdstringHuman-user UUID
requestCreateUserEnrollmentRequestRequest body.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;CreateUserEnrollmentResponseShape&gt;

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/&#123;id&#125;

Parameters

ParameterTypeDescription
idstringUser UUID
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;void&gt;

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/&#123;id&#125;

Parameters

ParameterTypeDescription
optionsUsersGetOptions optionalExactly one of id or email.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;UserResponseShape&gt;

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/&#123;username&#125;

Parameters

ParameterTypeDescription
usernamestringExact username
optionsUsersGetByUsernameOptions optionalOptional query parameters.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;UserResponseShape&gt;

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/&#123;userId&#125;/enrollments/&#123;enrollmentId&#125;

Parameters

ParameterTypeDescription
userIdstringHuman-user UUID
enrollmentIdstringEnrollment UUID
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;UserEnrollmentResponseShape&gt;

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

ParameterTypeDescription
optionsUsersListOptions optionalOptional query parameters.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;Page&lt;UserResponseShape&gt;&gt;

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/&#123;userId&#125;/enrollments

Parameters

ParameterTypeDescription
userIdstringHuman-user UUID
optionsUsersListEnrollmentsOptions optionalOptional query parameters.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;Page&lt;UserEnrollmentResponseShape&gt;&gt;

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

ParameterTypeDescription
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;UserResponseShape&gt;

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/&#123;userId&#125;/enrollments/&#123;enrollmentId&#125;

Parameters

ParameterTypeDescription
userIdstringHuman-user UUID
enrollmentIdstringEnrollment UUID
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;void&gt;

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/&#123;id&#125;

Parameters

ParameterTypeDescription
idstringUser UUID
requestUpdateUserRequestRequest body.
requestOptionsRequestOptions optionalPer-call signal, timeout, or headers.

Returns: Promise&lt;UserResponseShape&gt;

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.

FieldTypeRequiredDescription
enrollmentIdstring | nullnoOptional client-provided enrollment UUID; generated when omitted.
rotateExistingboolean | nullnoWhether an existing live enrollment may be revoked and atomically replaced.

CreateUserEnrollmentResponse

New enrollment metadata and its one-time raw enrollment credential.

FieldTypeRequiredDescription
enrollmentUserEnrollmentResponseyesOUTPUT_ONLY; non-secret metadata for the created enrollment.
enrollmentTokenstringyesOUTPUT_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.

FieldTypeRequiredDescription
userIdstring | nullnoOptional client-provided user UUID; generated by the server when omitted.
emailstringyesUnique, nonempty email address.
usernamestring | nullnoOptional unique username.
displayNamestring | nullnoOptional human-facing display name.
labelsRecord&lt;string, string&gt; | nullnoOptional 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.

FieldTypeRequiredDescription
enrollmentsArray&lt;UserEnrollmentResponse&gt;yesOUTPUT_ONLY; enrollments ordered newest first.
nextTokenstring | nullnoOUTPUT_ONLY; opaque continuation token, absent after the final page.

ListUsersResponse

One authorization-filtered page of human users.

FieldTypeRequiredDescription
usersArray&lt;UserResponse&gt;yesOUTPUT_ONLY; users in stable keyset order.
nextTokenstring | nullnoOUTPUT_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.

FieldTypeRequiredDescription
emailstring | nullnoReplacement email. A present empty value is invalid.
usernamestring | nullnoReplacement username. An empty string clears the username.
displayNamestring | nullnoReplacement display name. An empty string clears the display name.
replaceLabelsRecord&lt;string, string&gt; | nullnoComplete 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._-].
mergeLabelsRecord&lt;string, string&gt; | nullnoLabels 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.

FieldTypeRequiredDescription
enrollmentIdstringyesOUTPUT_ONLY; immutable enrollment UUID.
userIdstringyesOUTPUT_ONLY; UUID of the human user invited to enroll.
credentialPrefixstringyesOUTPUT_ONLY; non-secret prefix that identifies the enrollment credential safely.
status"PENDING" | "EXPIRED" | "CONSUMED" | "REVOKED"yesOUTPUT_ONLY; current derived enrollment lifecycle state.
expiresAtnumberyesOUTPUT_ONLY; exclusive completion deadline in milliseconds since epoch.
consumedApiKeyIdstring | nullnoOUTPUT_ONLY; initial API-key UUID, present after consumption.
createdAtnumberyesOUTPUT_ONLY; enrollment issuance time in milliseconds since epoch.
consumedAtnumber | nullnoOUTPUT_ONLY; first-completion time, absent before consumption.
revokedAtnumber | nullnoOUTPUT_ONLY; permanent revocation time, absent while unrevoked.
createdByIdstringyesOUTPUT_ONLY; exact principal or API-key actor that issued the enrollment.
revokedByIdstring | nullnoOUTPUT_ONLY; exact revoking actor UUID, absent while unrevoked.

UserEnrollmentSummary

Non-secret enrollment posture for one active human user.

FieldTypeRequiredDescription
bootstrapEligiblebooleanyesWhether no enrollment has been consumed and the user has no subject API key.
openEnrollmentStatus"PENDING" | "EXPIRED" | nullnoState of the open enrollment, when one exists; present exactly with openEnrollmentExpiresAt.
openEnrollmentExpiresAtnumber | nullnoExclusive open-enrollment completion deadline in epoch milliseconds; present exactly with openEnrollmentStatus.

UserResponse

A durable human user profile and its lifecycle metadata.

FieldTypeRequiredDescription
userIdstringyesOUTPUT_ONLY; immutable user UUID.
emailstringyesOUTPUT_ONLY; unique email address.
displayNamestring | nullnoOUTPUT_ONLY; optional human-facing display name.
usernamestring | nullnoOUTPUT_ONLY; optional unique username.
labelsRecord&lt;string, string&gt;yesOUTPUT_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._-].
enrollmentSummaryUserEnrollmentSummary | nullnoOUTPUT_ONLY; enrollment posture when requested and independently authorized.
deletedAtnumber | nullnoOUTPUT_ONLY; permanent deletion time in milliseconds, absent while active.
deletedByIdstring | nullnoOUTPUT_ONLY; exact deleting actor UUID, absent while active.
createdAtnumberyesOUTPUT_ONLY; creation time in milliseconds since the epoch.
updatedAtnumberyesOUTPUT_ONLY; most recent mutation time in milliseconds since the epoch.
createdByIdstringyesOUTPUT_ONLY; exact creating actor UUID.
updatedByIdstringyesOUTPUT_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

FieldTypeRequiredDescription
enrollmentUserEnrollmentResponseShapeyesOUTPUT_ONLY; non-secret metadata for the created enrollment.
enrollmentTokenstringyesOUTPUT_ONLY; one-time raw enrollment credential. Save and deliver it securely.

ListUserEnrollmentsResponseShape

FieldTypeRequiredDescription
enrollmentsArray&lt;UserEnrollmentResponseShape&gt;yesOUTPUT_ONLY; enrollments ordered newest first.
nextTokenstring | nullnoOUTPUT_ONLY; opaque continuation token, absent after the final page.

ListUsersResponseShape

FieldTypeRequiredDescription
usersArray&lt;UserResponseShape&gt;yesOUTPUT_ONLY; users in stable keyset order.
nextTokenstring | nullnoOUTPUT_ONLY; opaque continuation token, omitted after the final page.

UserEnrollmentResponseShape

FieldTypeRequiredDescription
enrollmentIdstringyesOUTPUT_ONLY; immutable enrollment UUID.
userIdstringyesOUTPUT_ONLY; UUID of the human user invited to enroll.
credentialPrefixstringyesOUTPUT_ONLY; non-secret prefix that identifies the enrollment credential safely.
status"PENDING" | "EXPIRED" | "CONSUMED" | "REVOKED" | nullyesOUTPUT_ONLY; current derived enrollment lifecycle state.
expiresAtnumberyesOUTPUT_ONLY; exclusive completion deadline in milliseconds since epoch.
consumedApiKeyIdstring | nullnoOUTPUT_ONLY; initial API-key UUID, present after consumption.
createdAtnumberyesOUTPUT_ONLY; enrollment issuance time in milliseconds since epoch.
consumedAtnumber | nullnoOUTPUT_ONLY; first-completion time, absent before consumption.
revokedAtnumber | nullnoOUTPUT_ONLY; permanent revocation time, absent while unrevoked.
createdByIdstringyesOUTPUT_ONLY; exact principal or API-key actor that issued the enrollment.
revokedByIdstring | nullnoOUTPUT_ONLY; exact revoking actor UUID, absent while unrevoked.

UserEnrollmentSummaryResponseShape

FieldTypeRequiredDescription
bootstrapEligiblebooleanyesWhether no enrollment has been consumed and the user has no subject API key.
openEnrollmentStatus"PENDING" | "EXPIRED" | nullnoState of the open enrollment, when one exists; present exactly with openEnrollmentExpiresAt.
openEnrollmentExpiresAtnumber | nullnoExclusive open-enrollment completion deadline in epoch milliseconds; present exactly with openEnrollmentStatus.

UserResponseShape

FieldTypeRequiredDescription
userIdstringyesOUTPUT_ONLY; immutable user UUID.
emailstringyesOUTPUT_ONLY; unique email address.
displayNamestring | nullnoOUTPUT_ONLY; optional human-facing display name.
usernamestring | nullnoOUTPUT_ONLY; optional unique username.
labelsRecord&lt;string, string&gt;yesOUTPUT_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._-].
enrollmentSummaryUserEnrollmentSummaryResponseShape | nullnoOUTPUT_ONLY; enrollment posture when requested and independently authorized.
deletedAtnumber | nullnoOUTPUT_ONLY; permanent deletion time in milliseconds, absent while active.
deletedByIdstring | nullnoOUTPUT_ONLY; exact deleting actor UUID, absent while active.
createdAtnumberyesOUTPUT_ONLY; creation time in milliseconds since the epoch.
updatedAtnumberyesOUTPUT_ONLY; most recent mutation time in milliseconds since the epoch.
createdByIdstringyesOUTPUT_ONLY; exact creating actor UUID.
updatedByIdstringyesOUTPUT_ONLY; exact actor UUID for the most recent mutation.