PgBeam Docs
Policies

replayPolicy

Replay recorded agent traffic against a policy

Replays the project's recorded agent audit traffic against a candidate policy (either a draft supplied inline or an existing policy referenced by id) and reports what would change: which queries that ran would now be blocked, which blocked queries would now be permitted, and which results would be masked or row-filtered. Traffic is deduplicated by normalized query shape, newest first, and every statement is evaluated through the data plane's own policy engine, so the verdicts match real enforcement. Stateful checks (budgets, approvals, write-mode routing) are reported as informational notes on each result, not verdicts. This endpoint reads only the audit log; it never connects to the upstream database and persists nothing.

Usage

const result = await api.policies.replayPolicy({
    pathParams: { project_id: "prj_xxx" },
    body: {
      ,
    },
  });

Parameters

ParameterTypeRequiredDescription
pathParams.project_idstringYesUnique project identifier (prefixed, e.g. prj_xxx).
body.policy_idstringNoID of an existing saved policy profile to replay against.
body.policyPolicyProfileInputNo
body.credential_idstringNoRestrict the replay to traffic recorded for one agent credential.
body.start_tsstringNoStart of the traffic window (inclusive). Defaults to 7 days before end_ts.
body.end_tsstringNoEnd of the traffic window (exclusive). Defaults to now.
body.limitnumberNoMaximum number of distinct queries to replay, newest first. Traffic is deduplicated by normalized query hash before evaluation.

Response

Promise<PolicyReplayResult>: the replay summary and per-query decisions.

Example

import { PgBeamClient } from "pgbeam";

const client = new PgBeamClient({
  token: "pbk_...",
  baseUrl: "https://api.pgbeam.com",
});

const result = await client.api.policies.replayPolicy({
  pathParams: { project_id: "prj_xxx" },
  body: {
      ,
    },
});

Errors

StatusDescription
400Invalid request parameters.
401Missing or invalid authentication.
403Operation not allowed by current plan limits.
404Resource not found.
429Rate limited. Try again later.

On this page