Command Line Interface
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. Entities are Users, Access Keys, and Tenants.
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.
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.
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
:
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.
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:
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.
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:
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.
Note
To learn more about project import/export and how to handle project secrets properly see here
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.