Docs

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.

  • Name
    emailAddress?
    Type
    string[]
    Description

    Counts users with emails that match the given query, via case-insensitive partial match. For example, hello will match a user with the email hello@example.com.

  • Name
    phoneNumber?
    Type
    string[]
    Description

    Counts users with phone numbers that match the given query, via case-insensitive partial match. For example, 555 will match a user with the phone number +1555xxxxxxx.

  • Name
    externalId?
    Type
    string[]
    Description

    Counts users with the specified external IDs.

  • Name
    username?
    Type
    string[]
    Description

    Counts users with the specified usernames.

  • Name
    web3wallet?
    Type
    string[]
    Description

    Counts users with the specified Web3 wallet addresses.

  • Name
    userId?
    Type
    string
    Description

    Counts users with the user IDs specified.

  • Name
    query?
    Type
    string
    Description

    Counts users that match the given query. For possible matches, Clerk checks the email addresses, phone numbers, usernames, Web3 wallet addresses, user IDs, first and last names. The query value doesn't need to match the exact value you are looking for, it is capable of partial matches as well.

const response = await clerkClient.users.getCount()

console.log(response)
/*
369
*/

Filter by query

The following 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 for more information.

Feedback

What did you think of this content?

Last updated on