---
title: "Go SDK installation"
description: "Install the pgbeam-go SDK, configure the client, authenticate, and learn the service-based access pattern with a full agent-gateway quickstart."
canonical: "https://pgbeam.com/docs/go-sdk"
last-updated: "2026-09-14T19:37:21.000Z"
---

# Go SDK installation

> Install the pgbeam-go SDK, configure the client, authenticate, and learn the service-based access pattern with a full agent-gateway quickstart.

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

The PgBeam Go SDK is the official client for the PgBeam control-plane API. It covers every API resource — projects and databases, plus the agent gateway: agent credentials, policy profiles, approvals, webhooks, anomalies, and audit logs — so you can provision safe, scoped Postgres access for AI agents from Go.

The module path is `go.pgbeam.com/sdk` (a vanity import that resolves to the public mirror). The package name is `pgbeam`.

## Installation

Requires Go 1.24 or newer. Import it as:

## Client setup

## Constructor options

Option

Type

Description

`APIKey`

`string`

PgBeam API key (required, prefix `pgb_`)

`BaseURL`

`string`

API base URL (default: `https://api.pgbeam.com`)

`HTTPClient`

`*http.Client`

Custom HTTP client for proxies, timeouts, etc.

## Authentication

See API Keys for key creation and rotation.

## Usage pattern

The Go SDK uses service-based access, matching the TypeScript SDK's tag-based `api.projects.*`, `api.databases.*` pattern:

Each service field on the client maps to an API tag:

Service

Go

Covers

`Projects`

`client.Projects`

Projects, replicas, custom domains, cache rules

`Databases`

`client.Databases`

Upstream database connections

`Policies`

`client.Policies`

Policy profiles (read-only, allowlists, masking)

`Agents`

`client.Agents`

Agent credentials, rotation, audit logs

`Approvals`

`client.Approvals`

Held-statement approval requests

`Webhooks`

`client.Webhooks`

Webhook endpoints for gateway events

`Anomalies`

`client.Anomalies`

Anomaly alerts

`Branches`

`client.Branches`

Database branches

`Migrations`

`client.Migrations`

Migration safety linting

`Analytics`

`client.Analytics`

Plans, usage, spend limits, insights

`Platform`

`client.Platform`

Health, regions

`Account`

`client.Account`

Account export, onboarding

## Quickstart: provision an agent credential

This end-to-end example creates a read-only policy profile and issues a scoped agent credential against it. The connection string and MCP token are returned **once** — capture them immediately.

## Examples across the surface

## List and inspect policy profiles

## Rotate or revoke an agent credential

## Approve a held statement

When a policy holds a write for approval, decide on it from the approvals service:

## Register a webhook endpoint

## Page through the audit log

For per-method reference — every parameter, response type, and error code — see the service pages in the sidebar. For error handling, retries, and idempotency, see Error Handling.