# Logs & Analytics

Query moderation logs to audit who took which action. Flag counts use `entity_creator_id`. There is no export, analytics, or usage-stats endpoint. Use `queryReviewQueue` and `queryModerationLogs` instead.

## Query Moderation Logs

`POST /api/v2/moderation/logs`

Query moderation action logs with filtering, sorting, and pagination. Logs record every moderation action taken -- who did what, when, and on which content.

```ruby label="Ruby"
response = client.moderation.query_moderation_logs(
  GetStream::Generated::Models::QueryModerationLogsRequest.new(
    filter: { "entity_type" => "stream:chat:v1:message" },
    sort: [GetStream::Generated::Models::SortParam.new(field: "created_at", direction: -1)],
    limit: 50
  )
)
```

### Request Parameters

| Key    | Required | Type   | Description                              |
| ------ | -------- | ------ | ---------------------------------------- |
| filter | false    | object | Filter conditions for logs.              |
| sort   | false    | array  | Sort parameters (e.g., by `created_at`). |
| limit  | false    | number | Maximum number of logs to return.        |
| next   | false    | string | Cursor for pagination.                   |

### Response

| Key  | Type   | Description                                                                                                                                                                                                                                                   |
| ---- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| logs | array  | List of moderation log entries. Each entry includes action type, actor, target, timestamp, and details. `reason` holds the moderator's note, if one was sent. See [Moderator notes](https://getstream.io/moderation/docs/ruby/content-moderation/actions/#moderator-notes). |
| next | string | Next cursor for pagination.                                                                                                                                                                                                                                   |

## Get Flag Count

`POST /api/v2/moderation/flag_count`

Get the number of moderation flags created against a specific user's content. Useful for building moderation dashboards and identifying repeat offenders.

```ruby label="Ruby"
response = client.moderation.get_flag_count(
  GetStream::Generated::Models::GetFlagCountRequest.new(
    user_id: "user_123"
  )
)
```

### Request Parameters

| Key         | Required | Type   | Description                       |
| ----------- | -------- | ------ | --------------------------------- |
| user_id     | true     | string | User ID to get flag count for.    |
| entity_type | false    | string | Optionally filter by entity type. |

### Response

| Key   | Type   | Description                                   |
| ----- | ------ | --------------------------------------------- |
| count | number | Total number of flags for the specified user. |

---

For the most recent version of this documentation, visit [https://getstream.io/moderation/docs/ruby/content-moderation/logs-and-analytics/](https://getstream.io/moderation/docs/ruby/content-moderation/logs-and-analytics/).