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

result, err := client.Policies.ReplayPolicy(ctx, "prj_xxx", pgbeam.PolicyReplayInput{

  })

Parameters

ParameterTypeRequiredDescription
ctxcontext.ContextYesRequest context
projectIDstringYesUnique project identifier (prefixed, e.g. prj_xxx).
reqpgbeam.PolicyReplayInputYesRequest body
req.PolicyID*stringNoID of an existing saved policy profile to replay against.
req.Policy*pgbeam.PolicyProfileInputNo
req.CredentialID*stringNoRestrict the replay to traffic recorded for one agent credential.
req.StartTs*stringNoStart of the traffic window (inclusive). Defaults to 7 days before end_ts.
req.EndTs*stringNoEnd of the traffic window (exclusive). Defaults to now.
req.Limit*intNoMaximum number of distinct queries to replay, newest first. Traffic is deduplicated by normalized query hash before evaluation.

Response

(*pgbeam.PolicyReplayResult, error): the replay summary and per-query decisions.

Example

import pgbeam "go.pgbeam.com/sdk"

client := pgbeam.NewClient(&pgbeam.ClientOptions{
  APIKey: "pgb_your_api_key",
})

result, err := client.Policies.ReplayPolicy(ctx, "prj_xxx", pgbeam.PolicyReplayInput{
    PolicyID: "pol_01h455vb4pex5vsknk084sn02q",
    Policy: pgbeam.PolicyProfileInput{ /* ... */ },
    CredentialID: "cred_01h455vb4pex5vsknk084sn02q",
    StartTs: "...",
    EndTs: "...",
    Limit: 200,
  })
if err != nil {
  log.Fatal(err)
}
fmt.Println(result)

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