Skip to main content

Install and use the Permit CLI

Install the Permit CLI, sign in, and run your first permission check from the terminal. This page is for developers who want to manage Permit.io policies, environments, users, and policy decision points (PDPs) from a terminal or a CI/CD pipeline. It ends with an index of every command and the page that documents it.

The Permit CLI is open source. The code is in the permitio/permit-cli repository on GitHub.

Prerequisites

  • Node.js version 22 or later, with npm.
  • A Permit.io account. Sign up at app.permit.io.
  • For the PDP commands that run a container: Docker.

Install the Permit CLI

Install the @permitio/cli package globally with npm:

npm install -g @permitio/cli

The package adds the permit command to your path.

Sign in to Permit

Most commands call the Permit API, so they need your credentials. Run permit login once before you use them, or pass --api-key to each command.

permit login

permit login opens your browser to sign in to Permit. After you sign in, the CLI asks you to choose a workspace, a project, and an environment. Later commands run against that environment.

FlagAliasDescription
--api-key <string>-kSign in with a Permit API key instead of the browser.
--workspace <string>The workspace key to use, which skips the workspace selection step.
--region <string>-rThe Permit region: us or eu. Defaults to us.
$ permit login

The CLI stores the credentials in your operating system's keychain.

permit logout

permit logout signs you out and deletes the stored credentials from your keychain.

$ permit logout

Run a command

Every command follows this form:

$ permit [command] [options]

Flags use kebab-case, for example --api-key and --pdp-url. To list the commands and flags of a command group, add --help, for example permit pdp check --help.

Confirm that the CLI works

After you sign in, check a permission against the Cloud PDP of your environment. Replace the user, action, and resource with ones from your policy:

$ permit pdp check --user user@permit.io --action list --resource transactions

The CLI prints ALLOWED or DENIED. An error instead of a decision means the CLI isn't signed in, or the Permit API is out of reach. For all permit pdp check flags, see PDP commands.

Command index

Policy decision point (PDP) commands

CommandWhat it does
permit pdp runStarts a PDP Docker container for your environment.
permit pdp checkChecks whether a user can perform an action on a resource.
permit pdp check-urlChecks whether a user can call a URL with an HTTP method.
permit pdp statsShows statistics about a PDP.

Environment and Terraform commands

CommandWhat it does
permit env createCreates an environment.
permit env copyCopies an environment's policy to a new or existing environment.
permit env deleteDeletes an environment.
permit env memberInvites a member to an environment with a role.
permit env selectChanges the active environment.
permit env export terraformExports an environment as a Terraform HCL file.

Policy commands

CommandWhat it does
permit initStarts a wizard that takes you from a policy to an enforced permission check.
permit policy create simpleCreates resources, actions, and roles from flags or a table wizard.
permit policy create aiGenerates a role-based access control (RBAC) policy from a natural language description.
permit env template listLists the policy templates.
permit env template applyApplies a policy template to the active environment.
permit env apply openapiCreates a policy from an OpenAPI spec with x-permit extensions.
permit env apply trinoCreates resources from the catalogs, schemas, and tables of a Trino cluster.
permit opa policyPrints the policies loaded in a running Open Policy Agent (OPA) server.

API commands

CommandWhat it does
permit api sync userCreates or updates a user with attributes and role assignments.
permit api users listLists the users in an environment.
permit api users assignAssigns a role to a user in a tenant.
permit api users unassignRemoves a role assignment from a user.
permit api create proxyCreates a Permit Proxy configuration.
permit api list proxyLists the Permit Proxy configurations in an environment.

Policy testing commands

CommandWhat it does
permit test run auditRuns the checks from recent audit logs against a PDP and lists the decisions that differ.
permit test generate e2eGenerates end-to-end test cases, and optionally test data, for your policy.
permit test generate code-sampleGenerates a Jest, Vitest, or pytest file that runs the generated test cases.

GitOps commands

CommandWhat it does
permit gitops create githubConnects a GitHub repository to an environment for GitOps.
permit gitops env cloneClones an environment branch or the whole policy repository.