Skip to content

/admin/users/:id/user_logs

Path: /admin/users/:id/user_logs

Namespace: admin

Parent Resource: users

Overview

User logs represent activity logs for a specific user. Each log entry contains action, timestamp, IP address, and other audit information.

Available Operations

List User Logs (GET)

Endpoint: GET /admin/users/:id/user_logs.json

Description: Retrieve all activity logs for a specific user.

Request Example:

bash
GET /admin/users/123/user_logs.json

Response (200 OK):

json
{
  "user_logs": [
    {
      "id": 1,
      "user_id": 123,
      "action": "login",
      "ip_address": "192.168.1.1",
      "created_at": "2024-01-15T10:00:00Z"
    }
  ]
}

Show User Log (GET /:id)

Endpoint: GET /admin/users/:id/user_logs/:id.json

Description: Retrieve a specific user log entry.

Request Example:

bash
GET /admin/users/123/user_logs/1.json

Response (200 OK):

json
{
  "user_log": {
    "id": 1,
    "user_id": 123,
    "action": "login",
    "ip_address": "192.168.1.1",
    "created_at": "2024-01-15T10:00:00Z"
  }
}

Batch Actions (POST /batch_action)

Endpoint: POST /admin/users/:id/user_logs/batch_action.json

Description: Perform batch operations on selected user logs.

Request Example:

bash
POST /admin/users/123/user_logs/batch_action.json
Content-Type: application/json

{
  "batch_action": "export",
  "collection_selection": [1, 2, 3]
}

Response (200 OK):

json
{
  "message": "Batch action completed",
  "affected_count": 3
}

Released under an open source license.