Get Users API does not handle falsy values for "blocked" query param

I am using api/v2/users to search for all non-blocked users (among some other search criteria). Looking over the searchable-fields documentation, I am passing in blocked:false to my query, like so:

curl  https://{tenant}.us.auth0.com/api/v2/users?include_totals=true&q=blocked%3Afalse

But I am noticing a strict comparison when checking the blocked field on the RAW JSON of the user. (Something like this psuedo code: if (user.blocked === false) { /* add to results */ }

For example, I have hundreds of non-blocked users in my Username-Password-Authentication database, but only one of those users has a "blocked": false and the rest do not have the "blocked" field.

Response from API

{
    "start": 0,
    "limit": 1,
    "length": 1,
    "users": [/* only 1 record */],
    "total": 1
}

Raw JSON for user with “blocked” field

{
    "created_at": "2021-06-13T19:07:14.966Z",
    "email": "REDACTED",
    "blocked": false,
    /* lots of other fields */
}

Raw JSON for one user without “blocked” field

{
    "created_at": "2021-08-13T19:14:18.114Z",
    "email": "REDACTED",
    // No "blocked" field
    /* lots of other fields */
}

I guess my question and/or request could be fixed one of two ways:

  1. Update the search function to include all falsy values for the "blocked" field.
  2. OR document the current behavior so others don’t have to find out the same way I did.

Option #1 is preferred, but I realize that will probably take more dev time.

Thank you,

David

The following query should do what you want:

blocked:false OR -blocked

The auth0 docs could use a lot more detail and examples of common and advanced queries.

3 Likes

Awesome. Thanks @markd. It works perfectly.

1 Like