# API Keys & Connect Tokens

> Understanding the Public Key vs Secret Key security model and endpoint permission gates.

- **Category:** Authentication
- **Canonical Guide:** https://pottr.tangble.com/docs/api-keys

---

>
Understanding the Public Key vs Secret Key security model and endpoint permission gates.

## Key Types & Prefixes

<table class="docs-table">
<thead>
<tr>
<th>Key Type</th>
<th>Prefix</th>
<th>Environment</th>
<th>Permitted Scope</th>
</tr>
</thead>
<tbody>
<tr>
<td>**Public Key**</td>
<td>`pk_live_...`</td>
<td>Frontend Web, Mobile, Jamstack</td>
<td>
• App bootstrapping (`POST /auth/bootstrap`)<br />
• User authentication (Signup, Login, Refresh, Password Reset)<br />
• Public collection reads<br />
• User-owned collection writes (paired with User JWT)
</td>
</tr>
<tr>
<td>**Secret Key**</td>
<td>`sk_live_...`</td>
<td>Backend Servers, CI/CD Pipelines</td>
<td>
• Full administrative access across all endpoints<br />
• Blueprint provisioning (`POST /blueprint`)<br />
• Schema discovery (`GET /schema`)<br />
• Webhooks management (`/webhooks`)<br />
• Bypasses row-level user ownership restrictions
</td>
</tr>
</tbody>
</table>

<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
</path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>
Security Rule: Never Expose Secret Keys

<p>
Never embed your `sk_live_...` secret key in frontend JavaScript bundles, mobile app binaries, or public Git repositories. Secret keys have administrative privileges to manage webhooks, blueprints, and view un-scoped data.

## How Keys Are Sent

Send keys in the `Authorization: Bearer` header. Secret keys are accepted in the header only, never in a query string, so they cannot leak into logs or browser history. Public keys may appear in a query string only on live event streams, where browsers cannot set headers.

Requests made from the WordPress admin by a logged-in administrator (with the WordPress REST nonce) are treated as trusted, so the admin screens work without a key.

## Secret-Only Routes

A public key receives `403 insufficient_key_scope` on these routes:

<ul>
<li>`POST /blueprint` (provision from a server or pipeline)</li>
<li>`/webhooks` (create, list, update, delete, test, regenerate secret)</li>
<li>`GET /schema` (schema discovery)</li>
<li>Auth usage and limits routes</li>
</ul>

Use `POST /auth/bootstrap` with a public key when a frontend needs to declare collections at boot; it is additive and rejects secret keys by design.

## Key Regeneration

If a secret key is compromised, navigate to **Pottr › API Keys** in WordPress Admin and click **Regenerate**. Regenerating a key immediately invalidates the previous key across all active API requests, so update your environment variables and redeploy straight away. The API Keys screen also shows a ready-made `.env` snippet.
