---
title: "ReplayPolicy"
description: "Replay recorded agent traffic against a policy"
canonical: "https://pgbeam.com/docs/go-sdk/policies/replayPolicy"
last-updated: "2026-09-05T14:02:29.000Z"
---

# ReplayPolicy

> Replay recorded agent traffic against a policy

URL: https://pgbeam.com/docs/go-sdk/policies/replayPolicy

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

## Parameters

Parameter

Type

Required

Description

ctx

`context.Context`

Yes

Request context

projectID

`string`

Yes

Unique project identifier (prefixed, e.g. prj\_xxx).

req

`pgbeam.PolicyReplayInput`

Yes

Request body

req.PolicyID

`*string`

No

ID of an existing saved policy profile to replay against.

req.Policy

`*pgbeam.PolicyProfileInput`

No

Mutable fields of a policy profile (used for create and update).

req.CredentialID

`*string`

No

Restrict the replay to traffic recorded for one agent credential.

req.BoundPolicyID

`*string`

No

Restrict the replay to traffic recorded for the agent credentials currently bound to this policy profile. Use it to preview a change to a live policy against the traffic that policy actually governs: without it the replay covers every credential in the project, including credentials bound to other profiles, whose behaviour saving this candidate cannot change. Mutually exclusive with credential\_id.

req.StartTs

`*string`

No

Start of the traffic window (inclusive). Defaults to 7 days before end\_ts.

req.EndTs

`*string`

No

End of the traffic window (exclusive). Defaults to now.

req.Limit

`*int`

No

Maximum 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

## Errors

Status

Description

400

Invalid request parameters.

401

Missing or invalid authentication.

403

Operation not allowed by current plan limits.

404

Resource not found.

429

Rate limited. Try again later.