Audit Log API

The Audit Log API provides endpoints for retrieving records of actions and changes within your Nected workspace. These logs are essential for tracking user activities, monitoring changes, and maintaining security within the workspace.

All Audit Log API endpoints require an authenticated request using the nected-api-key header. This key is specific to your workspace and must be kept secure.

Note: By default, the nected-api-key is set to private for security purposes. To retrieve your nected-api-key, follow these steps:

  1. Log in to Nected.

  2. Go to Authorization page from the left sidebar

  3. View or regenerate your nected-api-key to use in API requests.

For easier testing and exploration, the Audit Log API endpoints are available in a Postman Collection.


Endpoints

1. Get All Audit Logs

Retrieve a paginated list of audit logs for a specified module within your workspace. This endpoint is useful for monitoring actions performed by users in different modules.

Endpoint: GET /dev/audit/:module/search

Method: GET

Description: Retrieves a list of audit logs for a specified module in your workspace.

Request Parameters

  • Headers:

    • nected-api-key (string, required) - Your API key to authenticate and link the request to your workspace. Learn how to get it here.

  • Path Parameters:

    • module (string, required) - Specifies the module for which audit logs are requested. For example, user-management, rule-engine, etc.

  • Query Parameters:

    • pageNo (integer, optional) - Page number for paginated results. Default is 1.

    • pageSize (integer, optional) - Number of records per page. Default is 10, maximum is 10.

Example Request

GET /dev/audit/user-management/search?pageNo=1&pageSize=10
Headers:
  nected-api-key: YOUR_API_KEY

Response Parameters

  • logId (string) - Unique identifier of the audit log entry.

  • timestamp (integer) - Unix timestamp indicating when the action was performed.

  • user (string) - Identifier of the user who performed the action.

  • action (string) - Type of action recorded (e.g., create, update, delete).

  • module (string) - Module where the action occurred.

  • details (object) - Additional information about the action, such as affected entities or parameters.

Example Response

{
  "data": [
    {
      "logId": "abc123",
      "timestamp": 1675804800,
      "user": "user123",
      "action": "create",
      "module": "user-management",
      "details": {
        "entity": "user",
        "id": "user123",
        "changes": {
          "name": "John Doe",
          "role": "Admin"
        }
      }
    }
  ],
  "pagination": {
    "pageNo": 1,
    "pageSize": 10,
    "totalRecords": 50,
    "totalPages": 5
  }
}

Errors

  • 401 Unauthorized: Missing or invalid nected-api-key.

    • Example: {"error": "Unauthorized access. Invalid API key."}

  • 404 Not Found: Specified module does not exist in the workspace.

    • Example: {"error": "Module not found."}


2. Get Audit Log Detail

Retrieve detailed information for a specific audit log entry. This endpoint provides in-depth information about a particular action.

Endpoint: GET /dev/audit/:module/:log-id

Method: GET

Description: Retrieves details of a specific audit log entry by log-id within the specified module.

Request Parameters

  • Headers:

    • nected-api-key (string, required) - Your API key to authenticate and link the request to your workspace.

  • Path Parameters:

    • module (string, required) - The module associated with the log entry (e.g., user-management, rule-engine).

    • log-id (string, required) - The unique identifier for the specific audit log entry.

Example Request

GET /dev/audit/rule-engine/abc123
Headers:
  nected-api-key: YOUR_API_KEY

Response Parameters

  • logId (string) - Unique identifier of the audit log entry.

  • timestamp (integer) - Unix timestamp when the action occurred.

  • user (string) - Identifier of the user who performed the action.

  • action (string) - Type of action recorded.

  • module (string) - Module within which the action took place.

  • description (string) - A detailed description of the action taken.

  • details (object) - Additional data related to the action, such as the affected entity and fields.

Example Response

{
  "logId": "abc123",
  "timestamp": 1675804800,
  "user": "user123",
  "action": "update",
  "module": "rule-engine",
  "description": "Updated rule conditions",
  "details": {
    "entity": "rule",
    "ruleId": "rule456",
    "changes": {
      "condition": {
        "previous": "x > 10",
        "new": "x > 20"
      }
    }
  }
}

Errors

  • 401 Unauthorized: Missing or invalid nected-api-key.

    • Example: {"error": "Unauthorized access. Invalid API key."}

  • 404 Not Found: Specified log-id not found within the module.

    • Example: {"error": "Audit log entry not found."}


Error Responses

The Audit Log API may return specific errors if the request fails. Common error responses include:

  • 401 Unauthorized: Indicates that the nected-api-key is missing or invalid. Ensure that you are using the correct API key for your workspace.

    • Example Response:

      {
        "error": "Unauthorized access. Invalid API key."
      }
      
  • 404 Not Found: This error occurs if the specified module or log ID does not exist in the workspace.

    • Example Response:

      {
        "error": "Module not found."
      }
      
    • Example Response for log ID:

      {
        "error": "Audit log entry not found."
      }
      

Pagination

The Get All Audit Logs endpoint supports pagination to help manage large sets of audit records. The following query parameters control pagination:

  • pageNo (integer, optional) - Specifies the page number to retrieve, with a default of 1.

  • pageSize (integer, optional) - Specifies the number of records per page, with a default of 10 and a maximum of 10.

Example usage of pagination in the API:

GET /dev/audit/user-management/search?pageNo=2&pageSize=5
Headers:
  nected-api-key: YOUR_API_KEY

This concludes the Audit Log API Documentation. These endpoints provide secure and comprehensive access to audit logs within your Nected workspace, empowering you to track and review actions for improved security and operational oversight.

Last updated