Skip to content

Activities Log GraphQL API User Guide

Overview

The Activities Log GraphQL API allows clients to query logs, providing detailed information about actions performed within the system. This guide will help you understand how to use the API, including the available queries, types, and how to filter and sort the results.

Note: In the UI, this functionality is referred to as the "Activities log," but for API use, it is referred to as the "Audit Log" due to backwards compatibility concerns.

Schema

The GraphQL schema for the Audit Log API is defined in auditLog.graphqls. Below is an overview of the schema:

Types

AuditLog

Represents an audit log entry.

"""
Represents an audit log entry.
"""
type AuditLog {
    """
    The unique identifier of the audit log entry.
    """
    id: ID!
    """
    The resource identifier associated with the audit log entry.
    """
    sourceId: String!
    """
    The sequence key for the audit log entry representing a sequence of changes to the same resource.
    """
    sequenceKey: String!
    """
    The UUID of the website associated with the audit log entry.
    """
    websiteUuid: String
    """
    The company identifier associated with the audit log entry.
    """
    companyId: String!
    """
    Indicates if the log entry is a keypoint, meaning one of the crutual changes as e.g. saving the design.
    """
    keypoint: Boolean!
    """
    Indicates if the log entry is an dead end, like the draft, which was deleted.
    """
    endpoint: Boolean!
    """
    The fields of the specific resource that were changed in the audit log entry.
    """
    changedFields: [String]!
    """
    The title of the resource associated with the audit log entry.
    """
    resourceTitle: String!
    """
    The type of resource associated with the audit log entry - several resource titles can have one parent resource type.
    """
    resourceType: AuditResourceType!
    """
    The session information for the audit log entry, providing info on the user, making changes.
    """
    auditLogSession: AuditLogSession
    """
    The timestamp when the audit log entry was created, e.g. the timestamp of a performed change.
    """
    createdAt: DateTime!
}

AuditLogSession

"""
Represents an audit log session.
"""
type AuditLogSession {
    """
    The unique identifier of the audit log session.
    """
    sessionId: String!
    """
    The user identifier associated with the audit log session. Normally should be username, API key or email.
    """
    authenticatedEntityName: String
    """
    The information about actions performed in the session.
    """
    sessionEvents: [String]
}

AuditResourceType

"""
Enum for audit resource types. Please be aware, that this could be changed in future to accomodate more resource types.
"""
enum AuditResourceType {
    EVENT,
    WEBSITE,
    FEED_CONFIG,
    PAGES_DESIGN,
    PAGES_CONFIG,
    RECOM_DESIGN,
    RECOM_CONFIG,
    SEARCH_CONFIG,
    TRIGGER_DESIGN,
    TRIGGER_CONFIG,
    NEWSLETTER_DESIGN,
    NEWSLETTER_CONFIG,
}

Queries

auditLogs

Fetches a list of audit logs.

"""
Fetches a list of audit logs.
"""
type Query {
  auditLogs(
    """
    Filters to apply to the audit log query.
    """
    filter: AuditLogFilterInput, 
    """
    Sorting options for the audit log query.
    """
    sort: AuditLogSort, 
    """
    The number of results to return.
    """
    first: Int, 
    """
    The cursor for pagination.
    """
    after: String
  ): AuditLogConnection!
}

Inputs

AuditLogFilterInput

Input type for filtering audit logs.

input AuditLogFilterInput {
    """
    The UUID of the website to filter by.
    """
    websiteUuid: String
    """
    The company identifier to filter by.
    """
    companyId: String
    """
    The source identifier to filter by.
    """
    sourceId: String
    """
    The sequence key of the series of changes to the same resource to filter by.
    """
    sequenceKey: String
    """
    The keypoint flag to filter by.
    """
    keypoint: String
    """
    The endpoint flag to filter by.
    """
    endpoint: String
    """
    String represantation of the resource type enum to filter by.
    """
    resourceType: String
    """
    The timestamp of the audit log entry to filter by with the "less than or equal to" operator.
    """
    createdAtBefore: String
    """
    The timestamp of the audit log entry to filter by with the "greater than or equal to" operator.
    """
    createdAtAfter: String
}

AuditLogFilterArgumentSort

Enum for sorting audit logs.

enum AuditLogFilterArgumentSort {
    createdAt_ASC
    createdAt_DESC
    resourceType_ASC
    resourceType_DESC
}

Connections

AuditLogConnection

Represents a paginated list of audit logs.

type AuditLogConnection {
  edges: [AuditLogEdge!]!
  pageInfo: PageInfo!
}

type AuditLogEdge {
  node: AuditLog!
  cursor: String!
}

type PageInfo {
  endCursor: String
  hasNextPage: Boolean!
}

Usage

Querying Audit Logs

To query audit logs, use the auditLogs query. You can apply filters and sorting to refine the results.

Example Query

query {
  auditLogs(
    filter: {
      companyId: "company-123"
      createdAtAfter: "2023-01-01T00:00:00Z"
    }
    sort: CREATED_AT_DESC
    first: 10
  ) {
    edges {
      node {
        id
        timestamp
        action
        userId
        details
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}

Filtering

You can filter audit logs using the AuditLogFilterInput fields. For example, to filter by companyId and createdAtAfter:

{
  auditLogs(
    filter: {
      companyId: "company-123"
      createdAtAfter: "2023-01-01T00:00:00Z"
    }
  ) {
    edges {
      node {
        id
        timestamp
        action
        userId
        details
      }
    }
  }
}

Sorting

You can sort audit logs using the AuditLogSort enum. For example, to sort by createdAt in descending order:

{
  auditLogs(
    sort: CREATED_AT_DESC
  ) {
    edges {
      node {
        id
        timestamp
        action
        userId
        details
      }
    }
  }
}

Pagination

The auditLogs query supports pagination using the first and after arguments. Use the endCursor from the pageInfo to fetch the next page of results.

{
  auditLogs(
    first: 10
  ) {
    edges {
      node {
        id
        timestamp
        action
        userId
        details
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}

To fetch the next page:

{
  auditLogs(
    first: 10
    after: "cursor-from-previous-query"
  ) {
    edges {
      node {
        id
        timestamp
        action
        userId
        details
      }
      cursor
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}