PgBeam Docs
Policies

CreatePolicyProfile

Create a policy profile

Creates a policy profile that can be attached to agent credentials.

Usage

result, err := client.Policies.CreatePolicyProfile(ctx, "prj_xxx", pgbeam.PolicyProfileInput{
    Name: "...",
  })

Parameters

ParameterTypeRequiredDescription
ctxcontext.ContextYesRequest context
projectIDstringYesUnique project identifier (prefixed, e.g. prj_xxx).
reqpgbeam.PolicyProfileInputYesRequest body
req.NamestringYesHuman-readable name for the policy profile.
req.AccessMode*stringNoread_only blocks all data and schema mutations.
req.StatementRules*pgbeam.StatementRulesNo
req.TableAllowlist*[]stringNoIf non-empty, only these relations are reachable.
req.TableDenylist*[]stringNoRelations explicitly blocked.
req.MaskingRules*[]pgbeam.MaskingRuleNoColumn masking rules applied to query results.
req.BudgetQueriesPerHour*intNoMax queries per rolling hour window. 0 means unlimited.
req.BudgetQueriesPerDay*intNoMax queries per day window. 0 means unlimited.
req.MaxRows*intNoMax rows returned per query. 0 means unlimited.
req.StatementTimeoutMs*intNoUpstream statement timeout for agent sessions. 0 uses the project default.
req.RowFilters*[]pgbeam.RowFilterNoPer-relation row filters ANDed into agent reads.
req.WriteMode*stringNoHow writes are handled. normal commits, rollback auto-rolls back, sandbox routes to an ephemeral branch.
req.ApprovalMode*stringNoWhich statement classes require human approval before execution.
req.ApprovalAutoMaxRows*intNoStatements touching at most this many rows are auto-approved. 0 means none.
req.ApprovalTimeoutSeconds*intNoHow long a held statement waits for a decision before expiring.
req.MigrationSafety*stringNoMigration safety mode. warn surfaces findings, block refuses unsafe DDL.
req.EgressBytesPerDay*intNoPer-day egress budget in bytes. 0 means unlimited.

Response

(*pgbeam.PolicyProfile, error) — policy profile created.

Example

import pgbeam "go.pgbeam.com/sdk"

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

result, err := client.Policies.CreatePolicyProfile(ctx, "prj_xxx", pgbeam.PolicyProfileInput{
    Name: "...",
    AccessMode: "read_only",
    StatementRules: pgbeam.StatementRules{ /* ... */ },
    TableAllowlist: nil,
    TableDenylist: nil,
    MaskingRules: nil,
  })
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.
409Resource already exists or conflicts with current state.
429Rate limited. Try again later.

On this page