PgBeam Docs
Agents

RotateAgentCredential

Rotate an agent credential's secrets

Generates a new Postgres password and MCP token for the credential in place, keeping the same id, username, name, and policy. Live connections using the old password are dropped within seconds. The new secrets are returned once and cannot be retrieved again.

Usage

result, err := client.Agents.RotateAgentCredential(ctx, "prj_xxx", "agt_xxx")

Parameters

ParameterTypeRequiredDescription
ctxcontext.ContextYesRequest context
projectIDstringYesUnique project identifier (prefixed, e.g. prj_xxx).
agentIDstringYesUnique agent credential identifier (prefixed, e.g. agt_xxx).

Response

(*pgbeam.AgentCredentialSecrets, error) — secrets rotated. new secrets shown once.

Example

import pgbeam "go.pgbeam.com/sdk"

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

result, err := client.Agents.RotateAgentCredential(ctx, "prj_xxx", "agt_xxx")
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.
409The credential is revoked and cannot be rotated.

On this page