Keys, your team and going live
Your organization's keys are how your servers and your CI call OpenLegion, each with only the scopes it needs. Your team signs in to the console with a role each, and an owner or admin asks for live mode once your app has passed its test-mode checks.
Keys
A key is olp_test_… or olp_live_…, and it stays on your server: the SDK refuses one in a browser page. Make keys on the console's Keys page, one per thing that calls OpenLegion.
- The form starts with nothing ticked. Four starting points tick a set of scopes for you, and you can still change every box before the key exists:
- Your app's server (recommended): the scopes of the key
npx openlegion initmakes (below), pluslimits:write: eleven in all. For the server your app runs on once it is deployed, including changing your customers' spending limits. - Your deploy pipeline (CI):
templates,connectors,webhooks. For your deploy pipeline. It can't read workspaces or messages. - Support desk:
workspaces:read,usage:read,limits:write. For your support team's tools. - Data rights:
workspaces:readanddata_rights, nothing else. For exporting a customer's data and erasing it. Erasing can't be undone, so keep this key separate.
- Your app's server (recommended): the scopes of the key
- Your app's data-rights key,
OPENLEGION_DATA_RIGHTS_KEY.npx openlegion deploy --preparemakes it with the right scopes and sets it in your linked Vercel project: in test mode by default, and in live mode with--prepare --live --data-rights. A key you make here and set by hand must havedata_rightsandworkspaces:read, and come from the same organization and mode (test or live) as your app'sOPENLEGION_API_KEY; otherwise your app's erases are refused, and nothing is deleted. To check a key, call the SDK'skeys.self.retrieve()on your server, with a client made with that key: it answers the key'sscopes,livemode,organdexpires_at, never its secret. - The key
npx openlegion initmakes for your app has what the quickstart and the guides use:workspaces:read,workspaces:write,sessions,act_as(naming your user,OpenLegion-Subject),messages,approvals,inbound,usage:read,vaultandconnections. It has nolimits:write: that key sits in your app's.env.local, and a leaked one must not be able to raise a cap or grant credits. For server code that changes limits, make a key withlimits:writehere and use it for those calls; the starting point Your app's server is that key withlimits:writeadded. - A test key can be shown again on the Keys page. A live key is shown once, when it is made: if it is lost, rotate it.
GET /keys/self(npx openlegion whoami) answers the calling key's id, name, scopes and expiry, and its organization, never a secret.POST /keys/self/revoke(npx openlegion logout) revokes it at once.
Rotating a key
Rotate makes a new key to replace an old one, and you choose how long the old one keeps working, so you can deploy the new one first. Choose none, and requests with the old key fail at once. A rotation never extends a key: one due to expire sooner stops then. The Keys page shows both sides of a rotation: the old key names its replacement and when it stops.
A key npx openlegion login made belongs to that machine's sign-in: it is revoked, never rotated, and npx openlegion login makes a new one.
The two keys npx openlegion deploy makes for a deployed app (in test mode, for a linked Vercel project) are sent once, to the terminal that ran it, which puts them into Vercel without printing or storing them. The Keys page shows them as made by npx openlegion deploy; they can't be revealed or rotated there. Approve a deploy only if you started it in your own terminal: the keys go to whichever terminal shows the code. npx openlegion deploy --prepare replaces them in Vercel, and the old ones keep working for 24 hours. Revoke one on the Keys page to cut the deployment off at once.
Your team
Everyone on your team signs in to the console as themselves, with one role in your organization, the same in test and live:
| Role | What they may do |
|---|---|
| Owner | Everything, including the team's owners and admins. |
| Admin | Keys, workspaces, webhooks, money and the team (support and viewers). |
| Support | Reads everything and helps customers; changes nothing. |
| Viewer | Reads everything; changes nothing. |
An owner may give any role; an admin may give support and viewer. Only an owner may change or remove an owner or an admin. These are your team's roles in the console. Your users' roles inside a workspace (owner, admin, member) are a different thing: see Approvals and roles.
Going live
Your organization starts in test mode. When your app works end to end there, an owner or admin requests live access on the console's Go live page. The request needs five checks to pass, all read in test mode:
- A connector passes Test connection: an HTTPS connector whose last test passed, including the mis-signed call it must refuse.
- A webhook endpoint answered a test event: an HTTPS endpoint that answered
pingwith a2xx. - Your own template has a promoted version.
- New customers start with a spending limit: that promoted version has
default_limitswith a monthly or a daily spending limit. - The test journey ran end to end: a test key was used, a test workspace exists, and a run in it finished.
OpenLegion reviews the request. A declined request says why, and you can request again once that is fixed.
After approval: move your app to live
Live mode has its own connector, webhook endpoint, template and keys, and they start empty. Your production deployment runs in live mode. A deployment verifies one connector secret, so keep test mode on a preview or staging deployment.
-
Run one command from a terminal in your app's folder, signed in as for test mode (or ask your coding agent to run it):
npx openlegion deploy --url https://your.app --prepare --live --wait -
Approve the code. An owner or admin opens the link it prints and types the code; every owner and admin is emailed about the approval. OpenLegion then makes your app's live key and a key for this run only, which lasts an hour, is never written anywhere, and is revoked when the run ends. With a linked Vercel project, your app's key goes into its production environment as
OPENLEGION_API_KEY(add--data-rightsfor a liveOPENLEGION_DATA_RIGHTS_KEYtoo, needed only if your app exports or erases customer data). The run makes the live connector and webhook endpoint, sets their two secrets the same way, and waits up to 10 minutes while you redeploy to production. Then it runs Test connection, pins your tools, and pushes and promotes your template in live mode. -
Fund your live pool, the sixth check, which can pass only after approval. With no credits, your customers' messages are turned away.
Without a linked Vercel project, the run makes only its own key: it says which files hold the two secrets, and you make your app's key on the Keys page in live mode (starting point Your app's server) and set it in your host.
From CI, or when the CLI says live keys can't be made from it on this deployment, use a console key instead. On the Keys page in live mode, make a key with the starting point Your deploy pipeline (CI), and run the command with it as OPENLEGION_CLI_KEY (it then makes no keys, so make your app's key there too). A later run from a terminal asks for a new approval.
Your app's own sign-in decides who chats: the currentSession() that npx openlegion init writes answers no one outside next dev, so replace it before your customers use the chat.
npx openlegion deploy --prepare --live again later gives both secrets new values; the old ones keep working for 24 hours, so redeploy before the time it prints. In CI, set OPENLEGION_BASE_URL only for a stack other than OpenLegion's: a key from OPENLEGION_CLI_KEY goes to https://api.openlegion.ai/platform/v1 otherwise.