---
title: "Publishable keys"
description: "Learn what a project's publishable key reaches, the origin rules that keep it safe in a page's code, how a native app uses one, and how its origins change."
url: "https://agentpost.tools/docs/platform/concepts/publishable-keys"
kind: concept
---

# Publishable keys

A publishable key starts a sign-in from a browser or a native app: `pk_test_…` in `dev` and `pk_live_…` in `prd`. It is public, so it is safe in a page’s or an app’s code, because it is limited in two ways:

-   **It works only from the origins it lists,** such as `https://app.example.com`, and, when it allows native apps, from a native app, which sends no `Origin` header. Any other request answers [`origin_not_allowed`](/docs/errors.md#origin_not_allowed).
-   **It reaches only the operations a service opens before sign-in.** Each service’s reference lists them.

Once a principal has signed in, the browser or app sends its [session token](/docs/platform/concepts/credentials.md#session-tokens) or [user token](/docs/platform/concepts/user-tokens.md), depending on the operation. A project’s server sends its [secret key](/docs/platform/concepts/secret-keys.md) for its own calls.

## Origins

A publishable key lists up to 20 origins, and at least 1 unless it allows native apps:

-   **Each origin** is a scheme, a hostname, and a port when it isn’t the default, exactly as a browser sends it in `Origin`, with no path and no wildcard.
-   **Origins are `https`,** except that a `dev` key may list `http` on `localhost`, `127.0.0.1`, or `[::1]`.

An invalid entry in the list answers [`invalid_request`](/docs/errors.md#invalid_request), with the entry and reason in `details.invalid`. An invalid list size answers `invalid_request` as well. A change to the list takes effect on the next request, so the site needs no redeploy.

## Native apps

A native app, such as an iOS, Android, Expo, or React Native app, has no website, so it sends no `Origin` header. A key accepts such a request only when it is issued or updated with `allowNativeApps: true`; otherwise it answers `origin_not_allowed`. Never set `Origin` by hand to get past the check.

-   **What it reaches** is exactly what a browser reaches with the key: the operations that start a session and an invitation’s preview, under the same per-address limits. After sign-in, the app sends the principal’s session or user token, as a browser does.
-   **A request that sends an `Origin`** is still held to the key’s list, whether or not the key allows native apps. A key for an app that is also a website may list its origins and allow native apps; a key that only native apps use may list none.
-   **Issue one key for each platform,** such as `ios` and `android`, rather than sharing your website’s key. Each can then be revoked or changed alone, and a notice to the owners names which one changed.

A publishable key reaches only the start of a sign-in, which still needs the principal’s emailed code or its provider account, and is throttled by address. That bound matters because a key that allows native apps proves nothing about which program sends it: anyone can copy the key out of an app and send it from a script, as anyone can already send a forged `Origin` from outside a browser. The origin check keeps another website’s pages from using your key in their visitors’ browsers.

## Replacing a key

A publishable key is public, so you replace it rather than rotate it: issue a new key, deploy it, and revoke the old one.

## Where to act on it

-   [Create a project and issue a key](/docs/platform/guides/keys.md) issues one.
-   [Update a publishable key](/docs/platform/reference/keys.md#update-a-publishable-key) changes its origins, whether native apps may use it, or both.
-   [Revoke a key](/docs/platform/reference/keys.md#revoke-a-key) stops one at once.
-   The [keys reference](/docs/platform/reference/keys.md) has every field.
-   [Workspaces](/docs/platform/concepts/workspaces.md) explains which key changes email the owners.
