Skip to content

Governance

Service for inspecting governance policy enforcement on the UiPath platform.

See Define governance policies for how governance policies are configured in Automation Ops.

All methods require the caller to be an organization administrator.

Usage

Prerequisites: Initialize the SDK first - see Getting Started

import { Governance } from '@uipath/uipath-typescript/governance';

const governance = new Governance(sdk);
const traces = await governance.getPolicyTraces(new Date('2024-01-01'));

Methods

getOperationSummary()

getOperationSummary(startTime: Date, options?: GovernanceFilterOptions): Promise<GovernanceOperationSummary>

Gets aggregate governance enforcement counts across the requested time range.

Returns the total number of evaluations along with how many resolved to Allow, Deny, or NoOp.

Parameters

Parameter Type Description
startTime Date Inclusive lower bound on the evaluation time.
options? GovernanceFilterOptions Optional endTime upper bound and fullOrganization flag

Returns

Promise<GovernanceOperationSummary>

Promise resolving to GovernanceOperationSummary

Example

import { Governance } from '@uipath/uipath-typescript/governance';

const governance = new Governance(sdk);

// Get operation summary from the specified start time to right now
const summary = await governance.getOperationSummary(new Date('2024-01-01'));
console.log(summary.totalEvaluations, summary.allowedCount, summary.deniedCount, summary.noOpCount);

// Bounded range across the whole organization
const ranged = await governance.getOperationSummary(
  new Date('2024-01-01'),
  { endTime: new Date(), fullOrganization: true },
);

getPolicyTraces()

getPolicyTraces<T>(startTime: Date, options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<GovernancePolicyTrace> : NonPaginatedResponse<GovernancePolicyTrace>>

Gets per-policy enforcement decisions across the requested time range.

Each result row represents one policy's verdict within a single governance enforcement event. A single user action can produce multiple rows when multiple policies were consulted. Results are ordered by event start time, descending.

Type Parameters

Type Parameter Default type
T extends GovernancePolicyTraceGetAllOptions GovernancePolicyTraceGetAllOptions

Parameters

Parameter Type Description
startTime Date Inclusive lower bound on the trace start time.
options? T Optional filters and pagination options

Returns

Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<GovernancePolicyTrace> : NonPaginatedResponse<GovernancePolicyTrace>>

Promise resolving to NonPaginatedResponse of GovernancePolicyTrace without pagination options, or PaginatedResponse of GovernancePolicyTrace when pagination options are used.

Example

import { Governance, PolicyEvaluationResult } from '@uipath/uipath-typescript/governance';

const governance = new Governance(sdk);

// Get all policy traces from the specified start time
const recent = await governance.getPolicyTraces(new Date('2024-01-01'));
console.log(recent.items.length);

// Get all denied decisions across the whole organization
const page1 = await governance.getPolicyTraces(
  new Date('2024-01-01'),
  {
    endTime: new Date(),
    evaluationResult: [PolicyEvaluationResult.Deny, PolicyEvaluationResult.SimulatedDeny],
    fullOrganization: true,
    pageSize: 25,
  },
);

if (page1.hasNextPage) {
  const page2 = await governance.getPolicyTraces(
    new Date('2024-01-01'),
    { cursor: page1.nextCursor },
  );
}