> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AuditLogs SDK Reference

> SDK reference for the AuditLogs API, available in Node.js and Python.

## AuditLogs

### Query an AuditLog

Queries audit logs from your workspace with filters, sorting, and cursor pagination.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.audit_logs.query(filters={
          "operator": "and",
          "filters": [
              {
                  "type": "string",
                  "path": "entity_type",
                  "operator": "is",
                  "value": "skill",
              },
          ],
      }, pagination={
          "limit": 20,
      }, sorting=[
          {
              "key": "created_at",
              "direction": "desc",
          },
      ])

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.auditLogs.query({
      filters: {
        operator: "and",
        filters: [
          {
            type: "string",
            path: "entity_type",
            operator: "is",
            value: "skill",
          },
        ],
      },
      pagination: {
        limit: 20,
      },
      sorting: [
        {
          key: "created_at",
          direction: "desc",
        },
      ],
    });

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "filters": {  # required
            "search": Optional[str],
            "operator": str,  # required
            "filters": [{  # required
                "type": str,  # required
                "path": str,  # required
                "operator": str,  # required
                "value": Any,  # required
            }],
        },
        "pagination": {  # required
            "limit": Optional[int],
            "starting_after": Optional[str],
            "ending_before": Optional[str],
        },
        "sorting": [{  # optional
            "key": str,  # required
            "direction": Optional[str],
        }],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      filters: {  // required
        search?: string;
        operator: string;  // required
        filters: {  // required
          type: string;  // required
          path: string;  // required
          operator: string;  // required
          value: any;  // required
        }[];
      };
      pagination: {  // required
        limit?: number;
        startingAfter?: string;
        endingBefore?: string;
      };
      sorting?: {
        key: string;  // required
        direction?: string;
      }[];
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "audit_logs": [{
            "audit_log_id": str,
            "project_id": Optional[str],
            "entity_id": str,
            "entity_type": Literal["ORIGIN_UNSPECIFIED", "ui", "api", "scim", "system", "router", "mcp", "automation", "internal"],
            "action": Literal["ORIGIN_UNSPECIFIED", "ui", "api", "scim", "system", "router", "mcp", "automation", "internal"],
            "actor_id": Optional[str],
            "actor_ip": Optional[str],
            "actor_type": Optional[Literal["ORIGIN_UNSPECIFIED", "ui", "api", "scim", "system", "router", "mcp", "automation", "internal"]],
            "actor_display": Optional[str],
            "origin": Optional[Literal["ORIGIN_UNSPECIFIED", "ui", "api", "scim", "system", "router", "mcp", "automation", "internal"]],
            "request_id": Optional[str],
            "created_at": str,
            "metadata": Dict[str, Any],  # optional
        }],
        "overall_total": str,
        "has_more": bool,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      auditLogs: {
        auditLogId: string;
        projectId?: string;
        entityId: string;
        entityType: "ORIGIN_UNSPECIFIED" | "ui" | "api" | "scim" | "system" | "router" | "mcp" | "automation" | "internal";
        action: "ORIGIN_UNSPECIFIED" | "ui" | "api" | "scim" | "system" | "router" | "mcp" | "automation" | "internal";
        actorId?: string;
        actorIp?: string;
        actorType?: "ORIGIN_UNSPECIFIED" | "ui" | "api" | "scim" | "system" | "router" | "mcp" | "automation" | "internal";
        actorDisplay?: string;
        origin?: "ORIGIN_UNSPECIFIED" | "ui" | "api" | "scim" | "system" | "router" | "mcp" | "automation" | "internal";
        requestId?: string;
        createdAt: Date;
        metadata?: Record<string, unknown>;
      }[];
      overallTotal: string;
      hasMore: boolean;
    }
    ```
  </CodeGroup>
</Expandable>
