The te command-line tool
te lets you sign in, look at your applications, manage API keys and fill in your app's .env.local from a terminal or a CI job, without opening the console for every step. It is also built for coding agents: every command takes --json.
Install
npx @tenancyengine/cli --help # run without installing
npm install -g @tenancyengine/cli # or install the `te` commandNeeds Node.js 18 or newer.
Sign in
te loginte prints a short code and opens the console. Confirm the code there (sign in if asked) and the terminal finishes by itself. The key it receives is saved in your operating system's credential store (Keychain on macOS, Secret Service on Linux, a current-user-encrypted file on Windows) and is never printed.
The key can do what your own role allows, never more. If you only see part of what you expect, ask an organization admin to approve the sign-in.
Sign in with a key you already have
te login --key-file ~/.tenancyengine/te-api-key --lane productionUse this when you created a key in the console (for example from Connect an AI assistant on an application) and saved it in a file. te reads the file, asks the platform what the key may do, and only then saves it to the credential store. It never prints the key and never changes the file. A key the platform rejects is not saved.
The file must be yours and unreadable by other users (mode 600, the same rule ssh applies to private keys). te refuses a file that other users can read, a file that belongs to someone else, a link to a file, and a file that holds anything other than one te_ key. On Windows te cannot check who can open a file, so keep it in a folder only your account can read. You must name the platform for the command with --lane production|staging|lab (or --base-url for the local loopback address). te prints the host it is about to contact before it sends the key, and refuses a custom address, plain http to anything but loopback, a platform that only came from TE_BASE_URL or a saved login, and a key file whose name ends in another lane (.lab, .staging, .production, .local). A key made for the lab works only with --lane lab, and a staging key only with --lane staging. te whoami then shows the key's level, application, environments, expiry and permissions.
Connect one application to Claude or Codex
te login --app <your-app-slug> --lane lab --key-filete prints a short code, you approve the connection in the console, and the new key goes straight into a private file named for the lane (te-api-key.lab in te's configuration folder, or the path you give after --key-file). The key is never printed and never touches the clipboard. te builds the console address itself from the lane, never follows a redirect, checks that the key is for the organization and application you approved before it saves anything, and never overwrites an existing key file unless you add --replace. If it cannot finish, it saves nothing and tells you to revoke the connection and connect again. Full guide: Connect Claude or Codex to your app.
In CI, skip te login and set TE_API_KEY in the job's secrets. It takes priority over a saved login. TE_API_KEY is your production key: for another lane te reads TE_API_KEY_LAB, TE_API_KEY_STAGING (or the TENANCYENGINE_API_KEY_LAB spelling), and it never sends the production key to a lab or staging host. A saved login is only used for the platform it was made on.
Use --lane lab|staging|production (--env is the same switch; default production), --base-url, or the TENANCYENGINE_ENVIRONMENT variable to point at another platform. te logout removes the saved key from this machine.
Commands
| Command | What it does |
|---|---|
te whoami | Shows the key, organization, level and scopes in use |
te apps list [--search text] | Lists the applications you can reach |
te apps create --name "My App" [--slug my-app] | Registers an application in your organization |
te doctor [--app app] | Checks the platform address, sign-in issuer, clock, key expiry and your webhook URLs, with a fix for each problem |
te keys list [--app app] | Lists API keys (never their secrets) |
te keys scopes | Lists the scopes a key can carry |
te keys create --scopes a,b [--app app] [--expires-days 90] | Creates a key |
te keys rotate <keyId> [--app app] [--grace-hours 24] | Replaces a key; the old one keeps working for the grace period |
te keys revoke <keyId> [--app app] | Revokes a key |
te env pull --app app [--environment name] | Writes your app's TE_ settings into .env.local |
te webhooks listen --app app --forward-to http://localhost:3000/hooks | Streams the app's Development or Staging webhook events to your machine, re-signed with a per-session secret. No tunnel needed |
te config export --app app [--environment name] | Saves the environment's features, offerings, roles, claims and webhooks to te.config.json |
te config plan --app app [--file te.config.json] | Shows what applying the file would change, without changing anything |
te config apply --app app --yes | Applies the file |
--app accepts an application id or its slug.
When something does not work: te doctor
te doctor --app my-appte doctor makes only read requests and tells you which of these is wrong, with the fix next to it:
- The platform address is unreachable, or you are pointed at the wrong lane (
--env lab|staging|production). - The issuer your app should use differs from the address you are calling. Tokens are rejected when the two do not match exactly.
- This computer's clock is more than a couple of minutes away from the platform's.
- The key has expired, was revoked, or expires within a week.
.env.localnames a different platform than the one you are checking.- With
--app: a webhook URL cannot be reached, answers with a server error, points at your own computer (usete webhooks listeninstead), or was switched off after repeated failures.
It exits with status 1 when something is broken, so you can run it in a CI step. Add --json for a list your coding agent can read.
Keys are shown once
A new key is revealed a single time, by keys create and keys rotate. Prefer sending it straight into your env file so it never appears on screen or in a log:
te keys create --app my-app --scopes applications.read,features.read --write-env .env.localKeys expire after 90 days unless you pass --expires-days. Give each key the narrowest scopes your integration needs (see te keys scopes).
Pull settings into .env.local
te env pull --app my-app --environment ProductionThis adds or updates TE_BASE_URL, TE_APPLICATION_ID, TE_APPLICATION_SLUG, TE_ENVIRONMENT and TE_ENVIRONMENT_ID in the file and leaves every other line alone. By default it prints only the names it wrote. Add --print to also show the values, or --with-key --scopes ... to create a fresh application key and write it to the file (not printed). The variable it is written to depends on the lane: TE_API_KEY for production, TE_API_KEY_LAB for --lane lab, TE_API_KEY_STAGING for --lane staging. te prints the name it wrote.
te warns you when the file is not covered by a .gitignore entry. Never commit it.
Develop against lab or staging: te lane
te lane picks the TenancyEngine a development machine talks to, without a code change, and keeps the development setting out of every file that gets deployed.
te lane exec lab -- npm run dev # one command, lane and tier set for that command only
te lane use lab --write-env # writes .env.lane.local (gitignored): node --env-file=.env.lane.local app.js
te lane use lab --print-env # prints the assignments, writes nothing (scripts, agents, worktrees)
te lane use lab --dotnet-secrets # .NET: sets TenancyEngine:Lane in the project's user secrets
te lane lint # fails when TENANCYENGINE_DEPLOYMENT=local could be deployed
te lane doctor # what this shell resolves, which key variable it would read, and why a file is ignoredexecworks from apackage.jsonscript ("dev:lab": "te lane exec lab -- npm run dev"), an IDE run configuration or an AI agent. It forwards input, output, signals and the exit code.execrefuses on a deployed machine: aTENANCYENGINE_DEPLOYMENToflab,stagingorproduction, a staging or productionNODE_ENV, or a CI environment. Inside a container it refuses too, unless you setTENANCYENGINE_EXEC_ALLOW=container(one line in the output records it). Running a production-mode build locally against a lab or staging lane is not supported.--write-envonly ever writes.env.lane.localor.env.lane.<name>.local, never.env,.env.localor a mode file such as.env.production.local, because frameworks load those into production builds. It adds the file to.gitignoreand.dockerignore.te lane initadds the ignore lines and a commented block to.env.example. A copy of that file to.envchanges nothing.- The project file
.tenancyengine/config.jsonis yours to review:te lane use,registerandinitnever change a file you have not reviewed, andte lane trustshows it before you confirm.
Keep your configuration in a file
Export an environment, review the file in a pull request, and apply it to another environment:
te config export --app my-app --environment Staging # writes te.config.json
te config plan --app my-app --environment Production # what would change?
te config apply --app my-app --environment Production --yesThe file lists features, offerings (with their feature limits), roles (with the claims they grant), claims and webhooks. Leave a section out and te does not touch it; include a section and it is the complete list, so anything missing from it is shown as a removal.
- Nothing secret is in the file. A webhook that apply creates gets a new signing secret; open the webhook in the console and rotate it once to read it.
- Removals are checked. You cannot remove an offering that still has subscribers (set
isActivetofalseinstead), or a feature an offering still lists.planmarks these BLOCKED andapplyrefuses the whole file until they are fixed. - Prices need a second yes. A change to an offering's price, availability or removal is shown as a billing change and only applies with
--allow-billing, signed in as a person (te login). An API key can never confirm it. - Webhooks belong to the whole application, not one environment, so
applyadds and updates them but never removes one, and an API key cannot add or change one. applyre-checks that the environment has not changed since the plan (a stale plan is refused), and every apply is recorded in the audit log with who ran it and a before and after fingerprint.- Use
te config plan --fail-on-driftin CI to fail a build when an environment no longer matches the committed file.
A CI key needs configascode.read (export), configascode.plan (plan) and, only for a deploy job, configascode.write (apply).
Troubleshooting
| You see | Do this |
|---|---|
Not signed in | Run te login, or set TE_API_KEY (production) / TE_API_KEY_LAB / TE_API_KEY_STAGING |
TE_API_KEY is bound to production and is not used for lane 'lab' | Set TE_API_KEY_LAB (te keys create --lane lab --write-env .env.lane.local writes it), or unset TE_API_KEY to use your saved login |
te lane exec refused | You are on a deployed or CI machine, or in a container. See the te lane section |
401 | The key expired or was revoked. Run te login again |
403 | The key lacks the scope or your role lacks the permission. Sign in as an organization admin, or use a key with the needed scopes |
Could not reach ... | Check --lane / --base-url and your network |