descope
The descope Command Line Interface (CLI) helps manage your Descope project by leveraging its management APIs. It enables handling tasks like creating users, managing tenants, generating access keys, and modifying project settings through the command line.
With support for exporting, validating, and importing snapshots, the CLI simplifies project configuration and transfer. Its ability to output JSON makes it ideal for automation in scripts and CI/CD workflows, saving time and reducing errors. To see more about our CI/CD check out our Github CI/CD guide and Github CI/CD Template.
Prerequisites
The repository for the descope CLI can be found here.
-
Install the CLI tool according to your device, instructions can be found in the repository.
-
You will need the Project ID for the project you want to manage, this can be found in Project Settings
-
You will also need to generate a management key within Company Settings.
To set your Project ID and Management Key for the CLI, use the commands below. If you want to update them permanently add them to your terminal profile, such as .zshrc or .bashrc.
Note
If you need help on any command or sub-command you can put the -h flag at the end of the full command to get more information and flags.
Creating and Managing Project Entities
With the CLI you can create and manage different Descope entities.
You can create: Users, Access Keys, Tenants, and Inbound Applications.
Access-Keys
These are the available commands for creating and managing access keys:
When creating an access key there are several attributes you can pass in. You can get these attributes with the -h flag:
All the information about the command is returned:
As an example say we wanted to create an access key that expires Nov 21, 2026 which is 1795345322 Unix Time, is associated with a tenant, and takes all the project and tenant level roles and permissions of one of our users:
The access key is returned, it is in the cleartext field:
You can see your newly created access key in the Access Key tab.
![]()
To activate or deactivate an access key:
To load a specific access key:
To load all access keys:
To delete an access key:
Tenants
These are the available commands for creating and managing tenants:
When creating a Tenant we can pass the following flags:
As an example let's create a tenant with self provisioning domains and a custom tenant id:
To load the tenant we just created we can use the load command:
We can see the name, self-provisioning domains, authentication methods, and created time:
We can see our tenant and its settings in the Tenants Page.
![]()
To load all tenants:
To delete a tenant:
Users
These are the available commands for managing and creating users and test users:
The following flags are available for user creation:
As an example let's say we wanted to create a user associated with tenants, we can do the following:
They will be set as invited in the descope console:
![]()
Their status can be manually changed from Invited to Active using the activate sub-command.
Now if we load the user we can see their status is set to enabled:
To load a user by userId instead of loginId:
To load all users with pagination:
To delete a user:
To deactivate a user:
User Roles
We can manage a user's roles through the roles sub-command. These are the available commands for roles:
Note
Adding a role will append to current roles. Setting roles will overwrite any existing roles.
Here is an example of adding a tenant-level role to a user:
If we wanted to add project-level roles we can run the command again with no input for tenant.
To set roles (overwrites existing roles):
To remove roles:
User Passwords
We can set active and temporary passwords for a user as well as expire their existing password using the password sub-command:
We can set a temporary password which will require a user to change their password on the next authentication:
This can be accomplished by having a replace password section of the flow like below, the user will be able to use this temporary password to create a new one:
![]()
![]()
To set an active password:
To expire a user's password:
Test Users
Using the CLI we can programmatically create test users and generate logins for these users with the test sub-command:
Creating a test user works the same as creating a regular user:
You can generate a test verification code for a test user. Let's create a SMS OTP we can use and reuse for this test user:
We get back the OTP code we can use in place of a real OTP code during verification.
The generate sub-command supports the following methods:
Examples:
For magic link:
For enchanted link:
To delete all test users:
Inbound Applications
These are the available commands for managing inbound apps:
When creating an inbound app, you must provide a flow hosting URL and at least one permission scope (you may provide more than one if needed):
Note
The following example demonstrates how to provide multiple permission scopes using the -p flag. Only one permission scope is required, but you can specify additional scopes as needed.
Example of creating an inbound app:
The inbound app will be created with the following settings:
![]()
To update an inbound app:
To load an inbound app:
To load all inbound apps:
To delete an inbound app:
Inbound App Secrets
The secret sub-command allows you to manage secrets for inbound apps:
To load the secret for an inbound app:
To rotate the secret for an inbound app:
Managing the Project
The descope CLI allows you to manage flows, audits, projects, and themes
Audit
You can use the audit search command to do a fuzzy search of audit logs from the past 30 days:
Here is an example of searching for all audit logs that include the word Mozilla:
To store logs longer than 30 days you must stream them to your own service, see here
Flow
Using the CLI we can programmatically import and export flows:
Here is an example of exporting a flow to a JSON file:
To export a flow to a specific file:
To list all flows:
To import a flow from a JSON file:
The convert command allows you to convert flows between different formats:
The convert command supports:
- Converting from snapshot format (directory with metadata.json, contents.json, and screen files) to exported format (single JSON file)
- Converting from console format (flow and screens structure) to exported format
- Converting from exported format to snapshot format
Example:
Project
Using the CLI you can manage the creation of project snapshots and validation. These are the available base commands:
The snapshot subcommand allows you to import and export projects. These commands are useful for CI/CD automation.
Clone Project
To clone an existing project:
Example:
List Projects
To list all projects in a company:
Note
This command requires a company management key.
Delete Project
To delete a project:
Note
The --force flag is required when using --json to delete a project.
Example:
Project Snapshots
To export a snapshot:
If no path is specified, the snapshot will be exported to a directory named project-<projectId>.
Example:
To import a snapshot:
If no path is specified, the snapshot will be read from a directory named project-<projectId>.
Example:
To validate a snapshot:
Example:
If validation fails, the command will exit with status code 2. The --secrets-output flag can be used to generate a template file with all missing secrets that need to be provided.
Theme
Using the CLI tool you can manage the export and import of the project theme. These are the available commands:
Exporting the theme gives a JSON file with all the styles that exist in a project.
To export to standard output:
To import a theme: