---
title: "Crossplane"
description: "Manage PgBeam projects, databases, replicas, custom domains, cache rules, spend limits, agent credentials, policy profiles, webhook endpoints, self host enrollments, honeytokens, anomaly rules, and approval rules as Kubernetes custom resources using the Crossplane provider."
canonical: "https://pgbeam.com/docs/crossplane"
last-updated: "2026-10-08T14:03:05.000Z"
---

# Crossplane

> Manage PgBeam projects, databases, replicas, custom domains, cache rules, spend limits, agent credentials, policy profiles, webhook endpoints, self host enrollments, honeytokens, anomaly rules, and approval rules as Kubernetes custom resources using the Crossplane provider.

URL: https://pgbeam.com/docs/crossplane

Manage your PgBeam infrastructure as Kubernetes custom resources with Crossplane. The `provider-pgbeam` package provides managed resources for projects, databases, replicas, custom domains, cache rules, spend limits, agent credentials, policy profiles, webhook endpoints, self host enrollments, honeytokens, anomaly rules, and approval rules.

## Setup

## Install the provider

The Crossplane provider is coming soon. Registry publishing is on the roadmap.

## Configure credentials

Create a Secret with your PgBeam API key, then reference it in a ProviderConfig:

## Create a project

## Apply

Crossplane creates the PgBeam project and its primary database atomically. The proxy hostname is available in `status.atProvider.proxyHost` and published to the connection secret.

## Resources

**Every policy rule type is managed as code.** Policy profiles, honeytokens,
anomaly rules and approval rules are managed resources, so the enforcement
rules, the decoys, the detection sensitivity and what needs a human all live
in your reviewed IaC flow and are covered by drift detection. Approving or
rejecting an individual held statement is an operational decision rather than
configuration, so it stays in the dashboard, the CLI and the API.

## Project

Manages a PgBeam project with a primary database.

**Status:** `proxyHost`, `queriesPerSecond`, `burstSize`, `maxConnections`, `databaseCount`, `activeConnections`, `createdAt`, `updatedAt`, `primaryDatabaseID`

## Database

Manages an upstream database connection within a PgBeam project.

**Status:** `connectionString`, `createdAt`, `updatedAt`

## Replica

Manages a read replica for a PgBeam database.

Replicas are immutable; any spec change triggers recreation.

**Status:** `createdAt`, `updatedAt`

## CustomDomain

Manages a custom domain for a PgBeam project.

CustomDomains are immutable; any spec change triggers recreation.

**Status:** `verified`, `verifiedAt`, `tlsCertExpiry`, `dnsVerificationToken`, `dnsInstructions`, `createdAt`, `updatedAt`

## CacheRule

Manages a per-query cache rule. Deletion disables caching (soft-delete).

**Status:** `queryHash`, `normalizedSQL`, `queryType`, `callCount`, `avgLatencyMs`, `p95LatencyMs`, `avgResponseBytes`, `stabilityRate`, `recommendation`, `firstSeenAt`, `lastSeenAt`

## SpendLimit

Manages the monthly spend limit for an organization.

**Status:** `orgID`, `plan`, `billingProvider`, `subscriptionStatus`, `currentPeriodEnd`, `enabled`, `customPricing`, `spendCapped`, `spendCappedAt`, `limits`, `createdAt`, `updatedAt`

## AgentCredential

Manages a scoped agent credential (a PgBeam-issued Postgres login plus a hosted MCP token) for an AI agent. The connection string and MCP token are one-time secrets returned only at creation and exposed as sensitive computed outputs; they cannot be retrieved again. To rotate the secrets, taint/replace the resource (or use the rotate endpoint out of band).

**Status:** `pgUsername`, `authMethod`, `lastUsedAt`, `createdAt`, `updatedAt`, `connectionString`, `mcpURL`, `mcpToken`

## PolicyProfile

Manages a policy profile: a named bundle of agent-gateway enforcement rules (access mode, table allow/deny lists, statement-kind rules, PII masking rules, per-relation row filters, query/egress budgets, write mode, approvals, and migration safety) attached to agent credentials and enforced in the PG wire protocol. Nested-list fields (masking_rules, row_filters) and the nested statement_rules object are expressed as structured config.

**Status:** `createdAt`, `updatedAt`

## WebhookEndpoint

Manages a webhook endpoint that receives project audit and anomaly event deliveries. The signing secret is write-only and never returned by the API.

**Status:** `createdAt`, `updatedAt`

## SelfHostEnrollment

Manages a self-host (BYOC) enrollment: a token a self-hosted proxy uses to authenticate to the control plane's config/audit stream. The token is a one-time secret returned only at creation and exposed as a sensitive computed output; it cannot be retrieved again. To rotate the token, replace the resource. Deletion revokes the enrollment.

SelfHostEnrollments are immutable; any spec change triggers recreation.

**Status:** `createdBy`, `createdAt`, `lastSeenAt`, `revokedAt`, `token`

## Honeytoken

Manages a honeytoken: a decoy (canary) relation that no legitimate query should ever touch. Any agent statement referencing it is blocked and recorded as a canary_tripped audit event; the kill action additionally disables the tripping credential via the kill-switch. The relation does not have to exist in the upstream database: enforcement is by name, in the wire protocol, before the statement reaches Postgres.

**Status:** `createdAt`, `updatedAt`

## AnomalyRule

Manages an anomaly rule: the sensitivity of one detection metric for one project, or for one agent credential in it. Without a rule every metric resolves to the deployment default, so a credential that legitimately runs at 3am cannot be exempted and a noisy one cannot be loosened. Note the polarity of enabled: the rule IS the switch, so enabled=false silences the metric for that scope rather than deactivating the rule. One rule exists per (project, credential, metric); a second one for the same scope is a conflict. Detection runs in the control plane and re-reads the rules on every pass, so a write takes effect at the next detection pass rather than being pushed to the proxy.

**Status:** `createdAt`, `updatedAt`

## ApprovalRule

Manages an approval rule: a named, project-scoped rule that sends the agent statements it matches to a human for approval, whatever the policy profile's approval_mode says. A rule can only add approval; no rule can exempt a statement from approval_mode. Match on statement kinds, a schema, a relation, and optionally a minimum affected-row count. The name is shown to the reviewer on every approval request the rule holds and must be unique within the project. enabled=false switches the rule off. A write is pushed to connected data planes immediately.

**Status:** `createdAt`, `updatedAt`

## Configuration

Setting

Source

Description

`apiKeySecretRef`

ProviderConfig

Secret reference for the API key

`baseUrl`

ProviderConfig

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

## Replacement vs update

Some spec changes trigger resource recreation rather than in-place updates:

Resource

Recreation triggers

Project

`orgID`, `cloud`, `selfHosted`

Database

`projectID`

Replica

Any spec change (immutable)

CustomDomain

Any spec change (immutable)

CacheRule

`projectID`, `databaseID`, `queryHash`

SpendLimit

`orgID`

AgentCredential

`projectID`, `policyProfileID`, `name`, `principalType`, `expiresAt`

PolicyProfile

`projectID`

WebhookEndpoint

`projectID`

SelfHostEnrollment

Any spec change (immutable)

Honeytoken

`projectID`

AnomalyRule

`projectID`

ApprovalRule

`projectID`

## Further reading

Connection Pooling: pool modes and sizing

Caching: query caching and SWR

Read Replicas: replica routing

Custom Domains: DNS setup and verification

API Keys: managing API credentials

Plans: plan limits and pricing