/
Contact usSee pricingStart building
    Introduction
    Overview
    Postman
    Users
      Create user
      Search users
      Get user
      Update user
      Exchange primary factor
    • Delete

      • Delete user
        Delete user email
        Delete user phone number
        Delete user WebAuthn registration
        Delete user biometric registration
        Delete user TOTP
        Delete user crypto wallet
        Delete user password
        Delete user OAuth registration
    Magic links
    • Via email

      • Send magic link
        Log in or create user
        Invite
        Revoke pending invite
    • Embeddable

      • Create
      Authenticate
    OAuth
      Attach
      Authenticate
    • Start

      • Google
        Amazon
        Apple
        Bitbucket
        Coinbase
        Discord
        Facebook
        Figma
        GitHub
        GitLab
        Linkedin
        Microsoft
        Salesforce
        Slack
        Snapchat
        TikTok
        Twitch
        Twitter
        Yahoo
    Passwords
      Create
      Authenticate
      Strength check
      Migrate
    • Reset options

      • Password reset by email start
        Password reset by email
        Password reset by existing password
        Password reset by session
    One-time passcodes (OTP)
    • Via SMS

      • Send
        Login or create user
    • Via Whatsapp

      • Send
        Login or create user
    • Via email

      • Send
        Login or create user
      Authenticate
    Session management
      Session object
      Get JWKS
      Get sessions
      Authenticate Session
      Revoke session
      Migrate session
      Attest Session
      Exchange Access Token
    Passkeys & WebAuthn
    • Register

      • Start
        Register
    • Authenticate

      • Start
        Authenticate
      Update
      List WebAuthn Credentials
    Time-based one-time passcodes (TOTP)
      Create
      Authenticate
      Get recovery codes
      Recover
    Crypto wallets
      Authenticate start
      Authenticate
    M2M Authentication
      M2M Client Object
    • Token

      • Get Access Token
        Authenticate Access Token
    • M2M Client

      • Create M2M client
        Get M2M client
        Search M2M clients
        Update M2M client
        Delete M2M client
    • Rotate secret

      • Start secret rotation
        Rotate secret
        Cancel secret rotation
    Connected Apps
      Exchange Authorization Code
      Exchange Refresh Token
    • Tokens

      • Connected App ID Token Object
        Connected App Access Token Object
    • Configuration

      • Get JWKS
        Get OpenID Configuration
    • Methods

      • Introspect Token
        Authenticate Access Token (Local)
        Revoke Token
        Get UserInfo
    • Consent Management

      • Start OAuth Authorization
        Submit OAuth Authorization
        Get Authorized Connected Apps for a User
        Revoke Connected App Access to a User
    • Application Management

      • Dynamic Client Registration
        Create Connected App
        Get Connected App
        Search Connected Apps
        Update Connected App
        Delete Connected App
    • Rotate secret

      • Start secret rotation
        Rotate secret
        Cancel secret rotation
    RBAC
      Resource object
      Role object
      Scope object
      Get RBAC Policy
    User Impersonation
      Authenticate Token
    Resources
      Email templates
      URL validation
      Metadata
      User states
    Errors
      Overview
      Error object
      400
      401
      403
      404
      405
      429
      499
      500
      503
Get support on SlackVisit our developer forum

Contact us

Consumer Authentication

/

API reference

/

Users

/

Search users

Search Users

POST
https://test.stytch.com/v1/users/search

Warning: This endpoint is not recommended for use in login flows. Scaling issues may occur, as search performance may vary from ~150 milliseconds to 9 seconds depending on query complexity and rate limits are set to 150 requests/second.

Search for Users within your Stytch Project.

Use the query object to filter by different fields. See the query.operands.filter_value documentation below for a list of available filters.

Export all User data

Submit an empty query in your Search Users request to return all of your Stytch Project's Users.

This Github repository contains a utility that leverages the Search Users endpoint to export all of your User data to a CSV or JSON file.


Body parameters


limit int

The number of search results to return per page. The default limit is 100. A maximum of 1000 results can be returned by a single search request. If the total size of your result set is greater than one page size, you must paginate the response. See the cursor field.


cursor string

The cursor field allows you to paginate through your results. Each result array is limited to 1000 results. If your query returns more than 1000 results, you will need to paginate the responses using the cursor. If you receive a response that includes a non-null next_cursor in the results_metadata object, repeat the search call with the next_cursor value set to the cursor field to retrieve the next page of results. Continue to make search calls until the next_cursor in the response is null.


query object

The optional query object contains the operator, i.e. AND or OR, and the operands that will filter your results. Only an operator is required. If you include no operands, no filtering will be applied. If you include no query object, it will return all results with no filtering applied.

operator string

The action to perform on the operands. The accepted values are:

AND – all the operand values provided must match.

OR – [DEPRECATED] the operator will return any matches to at least one of the operand values you supply. This parameter is retained for legacy use cases only and is no longer supported. We strongly recommend breaking down complex queries into multiple search queries instead.

operands array[objects]

An array of operand objects that contains all of the filters and values to apply to your search search query.

filter_name string

The type of search filter to apply.

filter_value string, array, or object

The values to search for based on which search filter is specified in filter_name.

created_at_between object

The created_at_between filter allows you to search across your Users and return only those that were created between your supplied greater_than and less_than timestamps. The filter_value accepts an object of your greater_than and less_than timestamps. All timestamps in our API conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.

greater_than string

The greater_than timestamp specifies the beginning time for this filter, only users created after this timestamp will be returned.

less_than string

The less_than timestamp specifies the end of this filter, only users created before this timestamp will be returned.

created_at_greater_than string

Only Users created after the supplied created_at_greater_than timestamp will be returned. All timestamps in our API conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.

created_at_less_than string

Only Users created before the supplied created_at_less_than timestamp will be returned. All timestamps in our API conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.

user_id array[strings]

The user_id filter allows you to search for one or more exact user_ids. The filter_value accepts an array of user_ids, e.g. ["user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6"].

full_name_fuzzy string

The full_name_fuzzy filter allows you to search for a full or prefixed name match.

You can search for a prefix of a first or last name, so a search like "Ada" would match "Ada Lovelace" or "Abigail Adams".

status string

The status filter allows you to filter your Users based on their status: active or pending. See create_user_as_pending for more context. The filter_value accepts active or pending.

phone_number array[strings]

The phone_number filter allows you to search for one or more exact phone numbers. The filter_value accepts an array of phone number strings, e.g. ["+12025550162"]. Note: Phone numbers in the Stytch API must be valid E.164 phone numbers, i.e. +1XXXXXXXXXX, a sample regexp that you may use is ^+[1-9]d{1,14}$.

phone_number_fuzzy string

The phone_number_fuzzy filter allows you to search for a partial phone number match, e.g. you would like to return all Stytch Users who have a phone number that contains "415" as a substring.

phone_id array[strings]

The phone_id filter allows you to search for one or more exact phone_ids. The filter_value accepts an array of phone_ids, e.g. ["phone-number-test-d5a3b680-e8a3-40c0-b815-ab79986666d0"].

phone_verified boolean

The phone_verified filter allows you to filter your Users based on whether they have a verified phone number or not, i.e. has the phone number been used to successfully authenticate via Stytch.

email_address array[strings]

The email_address filter allows you to search for one or more exact email addresses. The filter_value accepts an array of email address strings, e.g. ["ghoppper@stytch.com"].

email_address_fuzzy string

The email_address_fuzzy filter allows you to search for a partial email address match across address and domain strings, i.e. address@domain.com. This filter matches strings starting from the prefix of both the address and domain, e.g. if you searched for "ada", you would match ada.lovelace@stytch.com and grace@ada.com but not sarah.adamson@stytch.com because "ada" does not match the first three characters of either the address or domain. If you'd like to return all Stytch Users who have an email address that belongs to a certain domain, e.g. the gmail.com domain, you may use "gmail" in this filter to return those users.

email_id array[strings]

The email_id filter allows you to search for one or more exact email_ids. The filter_value accepts an array of email_ids, e.g. ["email-test-81bf03a8-86e1-4d95-bd44-bb3495224953"].

email_verified boolean

The email_verified filter allows you to filter your Users based on whether they have a verified email address or not, i.e. has the email address been used to successfully authenticate via Stytch.

oauth_provider array[strings]

The oauth_provider filter allows you to filter your Users based on which OAuth provider they have authenticated with, e.g. ["Google", "Apple"].

webauthn_registration_id array[strings]

The webauthn_registration_id filter allows you to search for one or more exact webauthn_registration_ids. The filter_value accepts an array of webauthn_registration_ids, e.g. ["webauthn-registration-test-5c44cc6a-8af7-48d6-8da7-ea821342f5a6"].

webauthn_registration_verified boolean

The webauthn_registration_verified filter allows you to filter your Users based on whether they have a verified webauthn_registration_id or not, i.e. has the user successfully registered a Passkey or WebAuthn device via Stytch.

biometric_registration_id array[strings]

The biometric_registration_id filter allows you to search for one or more exact biometric_registration_ids. The filter_value accepts an array of biometric_registration_ids, e.g. ["biometric-registration-test-6966a6fc-5264-46ee-9ba4-98c6322a5134"].

biometric_registration_verified boolean

The biometric_registration_verified filter allows you to filter your Users based on whether they have a verified biometric_registration_id or not, i.e. has the user successfully registered their biometrics via Stytch.

totp_id array[strings]

The totp_id filter allows you to search for one or more exact totp_ids. The filter_value accepts an array of totp_ids, e.g. ["totp-test-81bf03a8-86e1-4d95-bd44-bb3495224953"].

totp_verified boolean

The totp_verified filter allows you to filter your Users based on whether they have a verified TOTP or not, i.e. has the TOTP been used to successfully authenticate via Stytch.

crypto_wallet_id array[strings]

The crypto_wallet_id filter allows you to search for one or more exact crypto_wallet_ids. The filter_value accepts an array of crypto_wallet_ids, e.g. ["crypto-wallet-test-81bf03a8-86e1-4d95-bd44-bb3495224953"].

crypto_wallet_address array[strings]

The crypto_wallet_address filter allows you to search for one or more exact crypto wallet addresses. The filter_value accepts an array of crypto wallet address strings, e.g. ["0x6df2dB4Fb3DA35d241901Bd53367770BF03123f1"].

crypto_wallet_verified boolean

The crypto_wallet_verified filter allows you to filter your users based on whether they have a verified crypto wallet or not, i.e. has the crypto wallet been used to successfully authenticate via Stytch.

password_exists boolean

The password_exists filter allows you to filter your users based on whether they have a password or not.


Response fields


request_id string

Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.


status_code int

The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.


results array[objects]

An array of results that match your search query.


results_metadata object

The search results_metadata object contains metadata relevant to your specific query like total and next_cursor.

next_cursor string

The next_cursor string is returned when your search result contains more than one page of results. This value is passed into your next search call in the cursor field.

total int

The total number of results returned by your search query. If totals have been disabled for your Stytch Workspace to improve search performance, the value will always be -1.

Search
​
Node
​
const stytch = require("stytch")

const client = new stytch.Client({
    project_id: "PROJECT_ID",
    secret: "SECRET",
    env: stytch.envs.test,
  }
);

const params = {
    limit: 200,
    cursor: "",
    query: {
      operator: "AND",
      operands: [
        {
          filter_name: "created_at_between",
          filter_value: {
            greater_than: "2020-12-03T08:58:26Z",
            less_than: "2021-12-18T00:00:00Z"
          }
        },
        {
          filter_name: "phone_number",
          filter_value: ["+12025550162", "+15551112222"]
        },
        {
          filter_name: "phone_verified",
          filter_value: true
        },
        {
          filter_name: "status",
          filter_value: "active"
        },
        {
          filter_name: "full_name_fuzzy",
          filter_value: "Grace"
        }
      ]
    }
};

client.users.search(params)
    .then(resp => {
        console.log(resp)
    })
    .catch(err => {
        console.log(err)
    });
RESPONSE 200
200
​
{
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "results": [
    {
      "created_at": "2021-12-17T04:02:28Z",
      "crypto_wallets": [],
      "emails": [
        {
          "email": "ghopper@stytch.com",
          "email_id": "email-test-81bf03a8-86e1-4d95-bd44-bb3495224953",
          "verified": false
        }
      ],
      "name": {
        "first_name": "Grace",
        "last_name": "Hopper",
        "middle_name": ""
      },
      "phone_numbers": [
        {
          "phone_id": "phone-number-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
          "phone_number": "+12025550162",
          "verified": true
        }
      ],
      "providers": [],
      "status": "active",
      "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6",
      "webauthn_registrations": []
    },
    { ...more users... }
  ],
  "results_metadata": {
    "next_cursor": "eyJ2IjoxLCJsIjo0NjkzfQ==",
    "total": 433
  },
  "status_code": 200
}
RESPONSE 200 - no more results
200
​
{
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "results": [
    {
      "created_at": "2021-12-17T04:02:28Z",
      "crypto_wallets": [],
      "emails": [
        {
          "email": "ghopper@stytch.com",
          "email_id": "email-test-81bf03a8-86e1-4d95-bd44-bb3495224953",
          "verified": false
        }
      ],
      "name": {
        "first_name": "Grace",
        "last_name": "Hopper",
        "middle_name": ""
      },
      "phone_numbers": [
        {
          "phone_id": "phone-number-test-d5a3b680-e8a3-40c0-b815-ab79986666d0",
          "phone_number": "+12025550162",
          "verified": true
        }
      ],
      "providers": [],
      "status": "active",
      "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6",
      "webauthn_registrations": []
    },
  ],
  "results_metadata": {
    "next_cursor": null,
    "total": 1
  },
  "status_code": 200
}
RESPONSE 401
200
​
{
  "status_code": 401,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "error_type": "unauthorized_credentials",
  "error_message": "Unauthorized credentials.",
  "error_url": "https://stytch.com/docs/api/errors/401"
}
RESPONSE 429
200
​
{
  "status_code": 429,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "error_type": "too_many_requests",
  "error_message": "Too many requests have been made.",
  "error_url": "https://stytch.com/docs/api/errors/429"
}
RESPONSE 500
200
​
{
  "status_code": 500,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "error_type": "internal_server_error",
  "error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
  "error_url": "https://stytch.com/docs/api/errors/500"
}

Common Error Types

  • invalid_email
  • invalid_email_id
  • invalid_phone_number
  • user_search_cannot_mix_internal_and_external_user_ids
  • user_search_expected_array_of_string
  • user_search_expected_bool
  • user_search_expected_object
  • user_search_expected_string
  • user_search_expected_timestamp
  • user_search_filter_name_must_be_string
  • user_search_filter_name_not_recognized
  • user_search_invalid_cursor
  • user_search_invalid_limit
  • user_search_invalid_oauth_provider_filter
  • user_search_invalid_operator
  • user_search_invalid_status_filter
  • user_search_maximum_filter_value_count_exceeded
  • user_search_missing_filter_name
  • user_search_missing_filter_value
  • user_search_missing_greater_than
  • user_search_missing_less_than