API Logs

Access and retrieve logs generated by the API. This endpoint is crucial for monitoring API behavior, debugging issues, and auditing activity.

Note: Access to detailed logs may be restricted based on user roles and permissions.

Endpoint Details

GET /logs
Permalink

Description

Retrieves a paginated list of API log entries. You can filter logs by timestamp, log level, and source service.

Query Parameters

Name Type Required Description
limit Integer No Maximum number of log entries to return. Defaults to 50.
offset Integer No Number of log entries to skip before starting to collect the result set. Defaults to 0.
startDate ISO 8601 Timestamp No Filter logs created on or after this timestamp. Example: 2023-10-27T10:00:00Z
endDate ISO 8601 Timestamp No Filter logs created on or before this timestamp. Example: 2023-10-27T12:00:00Z
level String No Filter logs by severity level. Possible values: DEBUG, INFO, WARN, ERROR, FATAL.
service String No Filter logs originating from a specific service. Example: user-service, payment-gateway.
search String No A keyword or phrase to search within log messages.
Permalink

Example Request


GET /logs?limit=10&level=ERROR&service=user-service&startDate=2023-10-27T09:00:00Z
        

Responses

GET 200 OK

Successfully retrieved a list of log entries.

Response Body


{
  "status": "success",
  "data": {
    "logs": [
      {
        "timestamp": "2023-10-27T10:35:15Z",
        "level": "ERROR",
        "service": "user-service",
        "message": "Failed to authenticate user: invalid credentials for user_id 12345",
        "details": {
          "user_id": 12345,
          "ip_address": "192.168.1.100"
        }
      },
      {
        "timestamp": "2023-10-27T10:30:01Z",
        "level": "INFO",
        "service": "product-service",
        "message": "Product with ID 9876 retrieved successfully.",
        "details": {
          "product_id": 9876,
          "user_agent": "PostmanRuntime/7.28.0"
        }
      }
      // ... more log entries
    ],
    "pagination": {
      "total": 150,
      "limit": 10,
      "offset": 0,
      "nextOffset": 10
    }
  }
}
            
Permalink

GET 400 Bad Request

Invalid query parameters provided (e.g., invalid date format, out-of-range limit).

Response Body


{
  "status": "error",
  "message": "Invalid date format for 'startDate'. Please use ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)."
}
            
Permalink

GET 401 Unauthorized

Authentication credentials are invalid or missing.

Response Body


{
  "status": "error",
  "message": "Authentication required. Please provide a valid API key or token."
}
            
Permalink

GET 403 Forbidden

The authenticated user does not have permission to access logs.

Response Body


{
  "status": "error",
  "message": "You do not have permission to access API logs."
}
            
Permalink

Log Entry Structure

Each log entry in the response array contains the following fields:

Permalink

Common Log Levels

INFO: General information about the application's operation.
WARN: Potentially harmful situations or unexpected events.
ERROR: Errors that prevent a specific operation from completing successfully.
FATAL: Severe errors that will likely lead to application termination.
DEBUG: Detailed information useful for debugging purposes. (Often only enabled in development environments)
Permalink