diff --git a/README.md b/README.md index 0591753c4..5f2684e37 100644 --- a/README.md +++ b/README.md @@ -912,10 +912,14 @@ usersRes.data.forEach((user) => { // Search all users, optionally according to tenant and/or role filter // Results can be paginated using the limit and page parameters // Additional filters: verifiedEmail, verifiedPhone, statuses, roles, tenantIds, etc. +// Results can also be filtered by time using fromCreatedTime, toCreatedTime, +// fromModifiedTime, and toModifiedTime (epoch in milliseconds) const usersRes = await descopeClient.management.user.search({ tenantIds: ['tenant-ID'], verifiedEmail: true, // optional: filter by verified email status verifiedPhone: false, // optional: filter by verified phone status + fromCreatedTime: 1700000000000, // optional: only users created after this time + toModifiedTime: 1800000000000, // optional: only users modified on or before this time }); console.log('Total users:', usersRes.data.total); usersRes.data.users.forEach((user) => { diff --git a/lib/management/user.ts b/lib/management/user.ts index 4d9b7c262..ea3c8ad9c 100644 --- a/lib/management/user.ts +++ b/lib/management/user.ts @@ -58,9 +58,9 @@ type SearchRequest = { loginIds?: string[]; userIds?: string[]; fromCreatedTime?: number; // Search users created after this time (epoch in milliseconds) - toCreatedTime?: number; // Search users created before this time (epoch in milliseconds) + toCreatedTime?: number; // Search users created on or before this time (epoch in milliseconds) fromModifiedTime?: number; // Search users modified after this time (epoch in milliseconds) - toModifiedTime?: number; // Search users modified before this time (epoch in milliseconds) + toModifiedTime?: number; // Search users modified on or before this time (epoch in milliseconds) tenantRoleIds?: Record; // Search users based on tenants and role IDs tenantRoleNames?: Record; // Search users based on tenants and role names verifiedEmail?: boolean; // Filter by verified email status @@ -674,6 +674,16 @@ const withUser = (httpClient: HttpClient) => { }), (data) => ({ users: data.users, total: data.total }), ), + /** + * Search all users. Results can be filtered according to tenants, roles, + * and other attributes on the given SearchRequest, and paginated using + * the limit and page fields. + * @param searchReq.fromCreatedTime only include users created after this time (epoch in milliseconds) + * @param searchReq.toCreatedTime only include users created on or before this time (epoch in milliseconds) + * @param searchReq.fromModifiedTime only include users modified after this time (epoch in milliseconds) + * @param searchReq.toModifiedTime only include users modified on or before this time (epoch in milliseconds) + * @returns The users found by the query, along with the total number of matches + */ search: (searchReq: SearchRequest): Promise> => transformResponse( httpClient.post(apiPaths.user.search, {