API keys
Publishable and secret project keys, account-level keys, how to create, scope, rotate and revoke them.
There are two kinds of keys.
Project keys
In Project Settings > Project API Keys:
- Publishable (
pgb_pub_...): safe in web and mobile apps. SQL runs under row-level security, so a table with RLS off is open to publishable traffic and with RLS on and no policies is closed. To scope to a signed-in end user, also send their access token in theX-PGB-User-Tokenheader; without it requests run as the anonymous role. - Secret (
pgb_sec_...): backend servers only. Full access, bypasses RLS. Never put it in a browser or app.
Send keys as x-api-key: pgb_pub_... or Authorization: Bearer pgb_sec_....
Create a key
- Choose + Generate Key.
- Enter a Key Name / Label and choose Publishable or Secret Key.
- Choose Generate Key.
- Copy it from the dialog, then choose I Have Saved My Key. The full token is shown once; the table keeps only a prefix, creation date and last use.
Keys created with the project, Default Secret Key and Default Publishable Key, are not displayed; generate your own to get a value.
Rotate and revoke
There is no rotate button. Generate a new key, deploy it, then Revoke the old one (watch Last Used). Removing a member revokes keys they issued. Keys cannot manage members or billing.
Account keys
Account Security > API Keys & AI Agent Access holds up to 10 keys (pgb_live_...) for SDKs and AI tools. Generate New API Key asks for a label, scope (Account-Wide or Project-Scoped) and an IAM policy: Full Admin Access, Developer, Read-Only, Queues Only or custom rules. Each row offers Usage, Copy MCP, Revoke, Reinstate and Delete; Revoke all API keys disables everything.
Good to know
- Store secret keys in environment variables, never in code.
- Give each app its own key so you can revoke one.
- See Protect your account.
More guides in Console: APIs, SDKs & tools
The REST API: query your data over HTTPS
Read and write rows, run SQL and call actions with plain HTTP requests to your project address.
Use the TypeScript SDK
Install @pgb/sdk, create a client, run a first query, and find the calls for each service.
Use the Python SDK
Install pgbhub, create a sync or async client, run a first query, and use auth, mail, storage and actions.
Use the Go and Rust SDKs
Install the Go and Rust clients and run a first call with each, then find auth, mail, storage and actions.
Connect AI coding tools with the MCP server
Let tools such as Claude Code, Cursor and Windsurf inspect your schema and run your actions through the PGB MCP server.
Webhooks: receiving and sending
Receive webhooks in a function, send them from event rules, cron jobs, jobs and actions, and verify signatures.