Skip to content
Docs

    List Audit Logs

    client.AuditLogs.List(ctx, query) (*Cursor[AuditLog], error)
    GET/v1/audit_logs

    List Audit Log entries for an organization

    ParametersExpand Collapse
    query AuditLogListParams
    Action param.Field[string]Optional

    Filter by recorded action

    ActorID param.Field[string]Optional

    Filter by the acting user or API key

    ActorType param.Field[AuditLogListParamsActorType]Optional

    Filter by the kind of actor that acted

    const AuditLogListParamsActorTypeUser AuditLogListParamsActorType = "user"
    const AuditLogListParamsActorTypeAPIKey AuditLogListParamsActorType = "api_key"
    ClientIP param.Field[string]Optional

    Filter by client IP address, matched exactly

    CreatedAtMax param.Field[Time]Optional

    Only entries at or before this RFC 3339 instant

    formatdate-time
    CreatedAtMin param.Field[Time]Optional

    Only entries at or after this RFC 3339 instant

    formatdate-time
    Cursor param.Field[string]Optional

    Pagination cursor returned by a previous request. Only valid for the same filters and sort order.

    Limit param.Field[int64]Optional

    Maximum number of items to return

    maximum100
    minimum10
    Method param.Field[string]Optional

    Filter by HTTP method

    Path param.Field[string]Optional

    Filter by a case-insensitive substring of the request path

    Sort param.Field[string]Optional

    Comma-separated sort terms in precedence order, each field:asc or field:desc. Fields: created_at, status_code

    StatusCodeMax param.Field[int64]Optional

    Only entries with a status code at or below this

    StatusCodeMin param.Field[int64]Optional

    Only entries with a status code at or above this, e.g. 400 for failures only

    TargetID param.Field[string]Optional

    Filter by the resource acted on

    TargetType param.Field[string]Optional

    Filter by the kind of resource acted on

    ReturnsExpand Collapse
    type AuditLog struct{…}

    Audit log entry.

    ID string

    Unique identifier for the audit log entry.

    Action string

    The action that was performed.

    The entity that performed the action.

    ID string

    Unique identifier for the actor.

    Name string

    Display name of the actor.

    Type of actor.

    One of the following:
    const AuditLogTypeUser AuditLogType = "user"
    const AuditLogTypeAPIKey AuditLogType = "api_key"
    ClientIP string

    Client IP address.

    CreatedAt Time

    When the action occurred.

    formatdate-time
    Method string

    HTTP method of the request.

    Path string

    Request path.

    StatusCode int64

    HTTP status code of the response.

    UserAgent string

    User agent string.

    Target AuditLogTargetOptional

    The target resource of the action.

    ID string

    Unique identifier for the target resource.

    Type string

    Type of the target resource.

    List Audit Logs

    package main
    
    import (
      "context"
      "fmt"
    
      "github.com/nirvana-labs/nirvana-go"
      "github.com/nirvana-labs/nirvana-go/audit_logs"
      "github.com/nirvana-labs/nirvana-go/option"
    )
    
    func main() {
      client := nirvana.NewClient(
        option.WithAPIKey("My API Key"),
      )
      page, err := client.AuditLogs.List(context.TODO(), audit_logs.AuditLogListParams{
    
      })
      if err != nil {
        panic(err.Error())
      }
      fmt.Printf("%+v\n", page)
    }
    
    {
      "items": [
        {
          "id": "123e4567-e89b-12d3-a456-426614174000",
          "action": "vm.created",
          "actor": {
            "id": "123e4567-e89b-12d3-a456-426614174000",
            "name": "Alice Smith",
            "type": "user"
          },
          "client_ip": "203.0.113.1",
          "created_at": "2025-01-01T00:00:00Z",
          "method": "GET",
          "path": "/v1/compute/vms",
          "status_code": 200,
          "user_agent": "Mozilla/5.0",
          "target": {
            "id": "123e4567-e89b-12d3-a456-426614174000",
            "type": "vm"
          }
        }
      ],
      "pagination": {
        "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
        "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
        "total_count": 125
      }
    }
    Returns Examples
    {
      "items": [
        {
          "id": "123e4567-e89b-12d3-a456-426614174000",
          "action": "vm.created",
          "actor": {
            "id": "123e4567-e89b-12d3-a456-426614174000",
            "name": "Alice Smith",
            "type": "user"
          },
          "client_ip": "203.0.113.1",
          "created_at": "2025-01-01T00:00:00Z",
          "method": "GET",
          "path": "/v1/compute/vms",
          "status_code": 200,
          "user_agent": "Mozilla/5.0",
          "target": {
            "id": "123e4567-e89b-12d3-a456-426614174000",
            "type": "vm"
          }
        }
      ],
      "pagination": {
        "next_cursor": "RhwniMT4B74siYZcPF8TnCdGI1l9rpPvg",
        "previous_cursor": "ARhwnmi1hA7wEbHbMjdYQlOB_ZusP4fYvw",
        "total_count": 125
      }
    }