Retrieve Recent Logins

Available Since Version 1.4.0

This API is used to retrieve recent logins.

Request#

Global API Key Authentication
Retrieve recent logins
GET/api/user/recent-login?limit={limit}&offset={offset}&userId={userId}
OpenAPI Spec

Request Parameters#

limitIntegeroptionalDefaults to 10

This parameter indicates the maximum amount of logins to return for a single request.

offsetIntegeroptionalDefaults to 0

This parameter provides the offset into the result set. Generally speaking if you wish to paginate the results, you will increment this parameter on subsequent API request by the size of the limit parameter.

userIdUUIDoptional

This parameter will narrow the results to only logins for a particular user. When this parameter is omitted, the most recent logins for all of FusionAuth will be returned.

Response#

The response will contain recent logins containing no more than the value set by the limit parameter. By design, this API does not return the total number of results and only lets paginate through the results from newest to oldest.

Response Codes
CodeDescription
200The request was successful. The response will contain a JSON body.
400The request was invalid and/or malformed. The response will contain an Errors JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present.
401You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See Authentication.
404The object you requested doesn't exist. The response will be empty.
500There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty.
503The search index is not available or encountered an exception so the request cannot be completed. The response will contain a JSON body.

Response Body#

loginsArray

A list of recent logins.

logins[x].applicationIdUUID

The unique Id of the application that is represented by this login record.

logins[x].applicationNameString

The name of the application at the time this record was created.

logins[x].instantLong

The instant this login occurred.

logins[x].ipAddressString

The IP address if provided during the login request.

logins[x].location.cityStringAvailable since 1.30.0

The city where the login request originated.

Note: To use login location, you'll need an Enterprise plan.

logins[x].location.countryStringAvailable since 1.30.0

The country where the login request originated.

Note: To use login location, you'll need an Enterprise plan.

logins[x].location.latitudeDoubleAvailable since 1.30.0

The latitude where the login request originated.

Note: To use login location, you'll need an Enterprise plan.

logins[x].location.longitudeDoubleAvailable since 1.30.0

The longitude where the login request originated.

Note: To use login location, you'll need an Enterprise plan.

logins[x].location.regionStringAvailable since 1.30.0

The geographic location where the login request originated.

Note: To use login location, you'll need an Enterprise plan.

logins[x].location.zipcodeStringAvailable since 1.30.0

The zipcode where the login request originated.

Note: To use login location, you'll need an Enterprise plan.

logins[x].loginIdString

The User's email address or username at the time of the login request.

logins[x].userIdUUID

The unique Id of the user that is represented by this login record.

Example Response JSON

{
  "logins": [
    {
      "applicationId": "3c219e58-ed0e-4b18-ad48-f4f92793ae32",
      "applicationName": "PiedPiper",
      "instant": 1549493410058,
      "ipAddress": "42.42.42.42",
      "location": {
        "city": "Seattle",
        "country": "US",
        "latitude": 47.60621,
        "longitude": -122.33207,
        "region": "WA"
      },
      "loginId": "jared@piedpiper.com",
      "userId": "4469bea7-8b10-4ad3-94f2-bc8df962b489"
    },
    {
      "applicationId": "3c219e58-ed0e-4b18-ad48-f4f92793ae32",
      "applicationName": "Acme Corp.",
      "instant": 1549485962036,
      "ipAddress": "42.42.42.42",
      "location": {
        "city": "Denver",
        "country": "US",
        "latitude": 39.73913,
        "longitude": -104.9845,
        "region": "CO"
      },
      "loginId": "admin@acme.com",
      "userId": "4469bea7-8b10-4ad3-94f2-bc8df962b489"
    },
    {
      "applicationId": "3c219e58-ed0e-4b18-ad48-f4f92793ae32",
      "applicationName": "Support Portal",
      "instant": 1549387234024,
      "ipAddress": "42.42.42.42",
      "location": {
        "city": "Dhaka",
        "country": "BD",
        "latitude": 23.7104,
        "longitude": 90.40744,
        "region": "81"
      },
      "loginId": "bob@gmail.com",
      "userId": "6a802b03-17e3-404f-830f-ea5c30ca50df"
    }
  ]
}