---
title: "UpdatePolicyProfile"
description: "Update a policy profile"
canonical: "https://pgbeam.com/docs/go-sdk/policies/updatePolicyProfile"
last-updated: "2026-10-30T13:45:52.000Z"
---

# UpdatePolicyProfile

> Update a policy profile

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

{/* Auto-generated from OpenAPI. Do not edit. Run `pnpm generate:sdk-docs` to regenerate. */}

Updates a policy profile. Changes hot-reload to active agent sessions.

## Usage

```go
result, err := client.Policies.UpdatePolicyProfile(ctx, "prj_xxx", "pol_xxx", pgbeam.PolicyProfileInput{
    Name: "...",
  })
```

## Parameters

| Parameter                   | Type                                        | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| --------------------------- | ------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ctx                         | `context.Context`                           | Yes      | Request context                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| projectID                   | `string`                                    | Yes      | Unique project identifier (prefixed, e.g. prj_xxx).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| policyID                    | `string`                                    | Yes      | Unique policy profile identifier (prefixed, e.g. pol_xxx).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| body                        | `pgbeam.PolicyProfileInput`                 | Yes      | Request body                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| body.Name                   | `string`                                    | Yes      | Human-readable name for the policy profile.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| body.AccessMode             | `*pgbeam.PolicyProfileInputAccessMode`      | No       | read_only blocks all data and schema mutations.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| body.StatementRules         | `*pgbeam.StatementRules`                    | No       | Per-statement-kind allow/deny lists. Empty allow means all kinds permitted by the access mode.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| body.TableAllowlist         | `*[]string`                                 | No       | If non-empty, only these relations are reachable. A bare entry grants the public schema only; list another schema in full, as in billing.orders.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| body.TableDenylist          | `*[]string`                                 | No       | Relations explicitly blocked. A bare entry blocks that relation in every schema.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| body.MaskingRules           | `*[]pgbeam.MaskingRule`                     | No       | Column masking rules applied to query results.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| body.BudgetQueriesPerHour   | `*int`                                      | No       | Max queries per rolling hour window. 0 means unlimited.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| body.BudgetQueriesPerDay    | `*int`                                      | No       | Max queries per day window. 0 means unlimited.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| body.MaxRows                | `*int`                                      | No       | Max rows returned per query. 0 means unlimited.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| body.StatementTimeoutMs     | `*int`                                      | No       | Upstream statement timeout for agent sessions. 0 uses the project default.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| body.RowFilters             | `*[]pgbeam.RowFilter`                       | No       | Per-relation row filters ANDed into agent reads.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| body.WriteMode              | `*pgbeam.PolicyProfileInputWriteMode`       | No       | How writes are handled. normal commits, rollback auto-rolls back, sandbox routes to an ephemeral branch.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| body.ApprovalMode           | `*pgbeam.PolicyProfileInputApprovalMode`    | No       | Which statement classes require human approval before execution.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| body.ApprovalAutoMaxRows    | `*int`                                      | No       | Statements touching at most this many rows are auto-approved. 0 means none.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| body.ApprovalTimeoutSeconds | `*int`                                      | No       | How long a held statement waits for a decision before expiring.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| body.MigrationSafety        | `*pgbeam.PolicyProfileInputMigrationSafety` | No       | Migration safety mode. warn surfaces findings, block refuses unsafe DDL.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| body.EgressBytesPerDay      | `*int64`                                    | No       | Per-day egress budget in bytes. 0 means unlimited.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| body.MaxAffectedRows        | `*int`                                      | No       | Hard cap on rows a single write (INSERT/UPDATE/DELETE) may affect. A write whose affected-row count would exceed this is executed inside a transaction, checked, and rolled back so nothing persists, then blocked. Enforced independently of human approval. 0 means unlimited.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| body.ContentScanMode        | `*pgbeam.PolicyProfileInputContentScanMode` | No       | Result-content scanning, enforced on the data-plane relay path: values on their way out to an agent are checked for instruction-shaped content (stored prompt injection). off scans nothing and costs nothing. annotate scans and forwards every value unchanged, recording what it found. block scans the same way and refuses instead: a value the structural detectors report at high confidence withholds that row and the rest of the exchange, and the statement's completion is replaced with an error (SQLSTATE 42501) naming the column, so a withheld result reads as a failed statement rather than a short one. Rows the scan had already cleared stay delivered, because this is a streaming protocol; what block guarantees is that no value carrying such a finding is ever sent to the agent. A lower-confidence finding never refuses, under any mode. No mode rewrites a value or withholds a row without saying so. A flagged statement records one content_flagged audit entry naming the columns, the techniques and whether the scan covered the whole result, alongside the proxy's own metrics and logs; the entry carries no value from the row itself, and it is delivered to any endpoint subscribed to the content_flagged webhook event, at either confidence, with decision_rule telling them apart. A finding the structural detectors report at high confidence also raises an anomaly alert, at most one per credential per hour; lower-confidence findings stay in the audit trail and the webhook stream. Values the scan cannot read (binary-format columns, columns this profile masks, and anything past content_scan_max_bytes) are counted as unscanned rather than reported clean. A proxy build older than result-content scanning ignores this field. |
| body.ContentScanMaxBytes    | `*int64`                                    | No       | Byte budget for one statement's content scan, spanning all values in the result. Values past it are reported unscannable rather than skipped quietly. The budget covers a whole statement, so the statements of one simple-query batch share it rather than each getting a fresh allowance. 0 uses the scanner default (4 MiB), which covers an interactive result set and deliberately does not cover a bulk export.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| body.QueryMode              | `*pgbeam.PolicyProfileInputQueryMode`       | No       | What an agent on this profile may send. sql admits any statement the rest of the profile allows. templates admits only the project's enabled query templates and refuses everything else with SQLSTATE 42501 and decision rule template_required; a matched template still meets every other rule on this profile, so it narrows and never grants access. Setting templates is refused with 400 when the project has no enabled template, since that profile would admit nothing, and with 409 while the organization has a live self-hosted enrollment, since an older self-hosted proxy ignores this field and would run unrestricted SQL. On create, omitting the field means sql. On update, omitting it keeps the stored mode, so a client that predates this field cannot widen a templates profile back to sql by saving it; send sql to do that.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |

## Response

`(*pgbeam.PolicyProfile, error)`: updated policy profile.

## Example

```go
import pgbeam "go.pgbeam.com/sdk"

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

accessMode := pgbeam.PolicyProfileInputAccessMode("read_only")
budgetQueriesPerHour := 0
budgetQueriesPerDay := 0
maxRows := 0
statementTimeoutMs := 0
result, err := client.Policies.UpdatePolicyProfile(ctx, "prj_xxx", "pol_xxx", pgbeam.PolicyProfileInput{
    Name: "...",
    AccessMode: &accessMode,
    BudgetQueriesPerHour: &budgetQueriesPerHour,
    BudgetQueriesPerDay: &budgetQueriesPerDay,
    MaxRows: &maxRows,
    StatementTimeoutMs: &statementTimeoutMs,
  })
if err != nil {
  log.Fatal(err)
}
fmt.Println(result)
```

## Errors

| Status | Description                                                                                                                                                                                                                                                                                           |
| ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400    | The request was rejected. `code` is `INVALID_INPUT`, and `errors` names the offending fields when the failure was a validation one.                                                                                                                                                                   |
| 401    | Missing or invalid authentication. `code` is `UNAUTHORIZED`.                                                                                                                                                                                                                                          |
| 403    | The caller is authenticated but not allowed to perform this operation. `code` is `FORBIDDEN` when the caller's role is insufficient, and `PLAN_LIMIT_REACHED` when the organization's plan is what stands in the way. The two are answered differently, so branch on the code rather than the status. |
| 404    | The resource does not exist, or the caller is not entitled to know that it does. `code` is `NOT_FOUND`.                                                                                                                                                                                               |
| 412    | The `If-Match` entity tag does not match the current representation, so the resource changed after the read this write was based on. Nothing was modified. `code` is `PRECONDITION_FAILED`. Re-read the resource, re-apply the change, and retry with the new tag.                                    |
| 413    | The request body exceeds the 2 MB limit. `code` is `PAYLOAD_TOO_LARGE`.                                                                                                                                                                                                                               |
| 415    | The request body is not JSON, or carries a body without declaring a Content-Type. `code` is `UNSUPPORTED_MEDIA_TYPE`.                                                                                                                                                                                 |
| 429    | Rate limited. `code` is `RATE_LIMITED`.                                                                                                                                                                                                                                                               |
| 500    | The request failed for a reason on our side. `code` is `INTERNAL_ERROR`. Quote `request_id` when reporting it.                                                                                                                                                                                        |