Skip to main content

Gets the total number of users in your instance.

function getCount(params: UserCountParams): Promise<number>
  • Name
    emailAddress?
    Type
    string[]
    Description

    Counts users with emails that match the given query, via case-insensitive partial match. For example, emailAddress=hello will match a user with the email HELLO@example.com. Accepts up to 100 email addresses.

  • Name
    externalId?
    Type
    string[]
    Description

    Counts users with the specified external IDs. Accepts up to 100 external IDs.

  • Name
    phoneNumber?
    Type
    string[]
    Description

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

  • Name
    query?
    Type
    string
    Description

    Counts users matching the given query across email addresses, phone numbers, usernames, Web3 wallet addresses, user IDs, first names, and last names. Partial matches supported. For example, query=hello will match a user with the email HELLO@example.com.

  • Name
    userId?
    Type
    string[]
    Description

    Counts users with the specified user IDs. Accepts up to 100 user IDs.

  • Name
    username?
    Type
    string[]
    Description

    Counts users with usernames that match the given query, via case-insensitive partial match. For example, username=CoolUser will match a user with the username SomeCoolUser. Accepts up to 100 usernames.

  • Name
    web3Wallet?
    Type
    string[]
    Description

    Counts users with Web3 wallet addresses that match the given query, via case-insensitive partial match. For example, web3Wallet=0x1234567890 will match a user with the Web3 wallet address 0x1234567890. Accepts up to 100 Web3 wallet addresses.

Note

Using clerkClient varies based on the SDK you're using. Refer to the overview for usage details, including guidance on how to access the userId and other properties.

const response = await clerkClient.users.getCount()

Filter by query

The following example gets the total number of users matching the query test.

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

Filter by last sign-in date

Gets the total number of users who signed in within a specific time range.

const response = await clerkClient.users.getCount({
  lastSignInAtAfter: 1700690400000,
  lastSignInAtBefore: 1700690400010,
})

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