FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    API for getting users that have been updated since a timestamp

    Scheduled Pinned Locked Moved
    Q&A
    0
    3
    467
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jason
      last edited by

      Is there an API which can provide all users that have been updated since a certain timestamp? By updated I mean their name, username, email, or password has changed.

      We are using the Java client (but can use HttpClient to access FusionAuth web APIs directly) and are calling FusionAuthClient.searchUsersByQuery(). I am unable to find an example of a query we can use in UserSearchCriteria.queryString of the SearchRequest - is there a way to do this?

      1 Reply Last reply Reply Quote 0
      • joshuaJ
        joshua
        last edited by joshua

        Hi @jason!

        You have a few choices to consider.

        Option A - On User

        You could consider the below attributes on the user and mold your query by accessing them.

        On Users/User, you have the ability to access

        • user.insert_instant , users[x].insert_instant
          This is when the searched for user/users were created.

        • user.last_update_instant
          Is another option as well. However, the user tends to be updated frequently in the database without any data actually changing. It simply represents the last time the DB table was written to. See webhooks below for a better solution.
          Screen Shot 2021-04-16 at 1.39.28 PM.png
          Screen Shot 2021-04-16 at 1.40.05 PM.png

        Some documentation can be found here, but admittedly, we will be updating it shortly to reflect the fields mentioned above. You may have already reviewed this, but posting for others benefit as well 🙂

        • Data type - instant
        • User(s) API
        • Retrieve a user
        • Search for users

        Option B - Webhooks

        A more compelling option might be to use webhooks to record when a user record changes and act per your business requirements to that change.

        The webhooks documentation can be found here:

        • https://fusionauth.io/docs/v1/tech/events-webhooks/#overview
        • https://fusionauth.io/docs/v1/tech/events-webhooks/events/

        I hope this helps!

        Thanks,
        Josh

        1 Reply Last reply Reply Quote 0
        • danD
          dan
          last edited by

          To add to what @joshua said, we don't record when "name, username, email, or password" has changed. The last update timestamp will be modified whenever anything about a user object changes. So if you are only interested in those changes, a webhook to an external system is the best solution.

          If you are ok with using the last update timestamp, I don't think you can query that with the queryString. I think you'll need to use a full query parameter. There are examples of ranges in the user search docs Joshua links to, but here's an example I copied and munged from there (so haven't tested it, but it should give you a starting point):

          {
          	"range": {
          		"lastUpdateInstant": {
          			"gte": 1618691124000,
          			"lte": 1618691224000
          		}
          	}
          }
          

          You'll need to escape that JSON and provide it as the query parameter (either in the url query string or in the form post object).

          --
          FusionAuth - Auth for devs, built by devs.
          https://fusionauth.io

          1 Reply Last reply Reply Quote 0
          • First post
            Last post