Retrieving Last Logins in a Specific Period Using Harness API



In today’s world of remote work and cloud-based infrastructure, it’s essential to monitor user activity on different platforms, including login information. Harness offers a simple solution to retrieve the last logins in a specific period. In this tutorial, we will guide you on how to use the Harness API to retrieve login information for a specified time period.


Step 1: Find your Harness Account ID

To retrieve login information, you need to know your Harness account ID. You can find your account ID by navigating to your account settings in Harness.

Account Settings → Overview → Account Details

Step 2: Generate an API Key

Before you can access Harness API, you must obtain an access token that grants access to that API. The access token allows you to make authorized API calls to Harness. These can be created at the Account/Org/Project level. If you already have one, you can skip this step.

Step 3: Generate Timestamps in Milliseconds

You need to generate the timestamps in milliseconds for the specific time period you want to retrieve login information for. You can use an online tool like to generate the timestamps.

Step 4: Use the Curl Command to Retrieve Login Information

curl --location --request POST '<ACCOUNT_ID>&pageIndex=0&pageSize=50' \
--header 'x-api-key: <API-TOKEN>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
    "scopes": [
        "accountIdentifier": "<ACCOUNT_ID>"
    "actions": [
    "filterType": "Audit"
  • Replace the <ACCOUNT-ID> field in the curl command with your Harness account ID
  • Replace the <START_TIMESTAMP_MILLISECONDS> and <END_TIMESTAMP_MILLISECONDS> fields with the timestamps generated in step 3.
  • Replace the <API-TOKEN> field with the key generated in step 2.

Step 5: Understanding the Curl Command

The curl command sends a POST request to the Harness API to retrieve a list of audits for the specified account ID and time period. The "actions" field is set to "LOGIN" to filter out any other audit actions and only retrieve login information. The "pageSize" parameter determines how many results are retrieved per page, and the "pageIndex" parameter determines which page of results to retrieve.


Retrieving login information for a specific period is a vital task for IT administrators and developers. With the Harness API and the curl command, you can quickly and easily retrieve this information. By following this tutorial, you should now be able to use the Harness API to retrieve the last logins in a specific period.
If you have any suggestions on how to improve this article that may be of use to others, please leave a comment. If this article cannot resolve your issue, don’t hesitate to contact Harness support through the Zendesk portal or at