Skip to Content
You are viewing a beta version of Clerk Docs
Visit the latest docs
Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.com

getCount()

Retrieves the total number of users.

function getCount: (params: UserCountParams) => Promise<number>;

UserCountParams

The total count of users can be filtered down by adding one or more of these parameters.

NameTypeDescription
emailAddress?string[]The email addresses to filter by.
phoneNumber?string[]The phone numbers to filter by.
username?string[]The usernames to filter by.
web3wallet?string[]The web3wallet to filter by.
query?stringA search query to filter users by.
userId?stringThe user ID's to filter by.
externalId?string[]The external ID's to filter by.

getCount() examples

getCount() with no parameters

const response = await clerkClient.users.getCount(); console.log(response); /* 369 */

getCount({ query })

To do a broader match through a list of fields, you can use the query parameter which partially matches the fields: userId, emailAddress, phoneNumber, username, web3Wallet, and externalId.

This example retrieves the total number of users matching the query test.

const response = await clerkClient.users.getCount({ query: 'test' })

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint GET/users/count. See the BAPI reference(opens in a new tab) for more details.

Last updated on November 9, 2023

What did you think of this content?

Clerk © 2024