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

    The email addresses to filter by.

  • Name
    phoneNumber?
    Type
    string[]
    Description

    The phone numbers to filter by.

  • Name
    externalId?
    Type
    string[]
    Description

    The external ID's to filter by.

  • Name
    username?
    Type
    string[]
    Description

    The usernames to filter by.

  • Name
    web3wallet?
    Type
    string[]
    Description

    The Web3 wallet address to filter by.

  • Name
    userId?
    Type
    string
    Description

    The user ID's to filter by.

  • Name
    query?
    Type
    string
    Description

    Counts users that match the given query. For possible matches, we check 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

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

Feedback

What did you think of this content?

Last updated on