On this page
Install and sign in to the Patrii CLI
The Patrii CLI, patrii, lets you manage your projects and resources from a terminal or a script, with the same rights you have in the console.
The CLI is a Python package named patrii-cli. It talks only to the Patrii Cloud API, so every command maps to something you can also do in the console, and it follows your project roles.
You can sign in with your email and password (plus your MFA code when it is enabled), with single sign-on in your browser, or, for scripts and pipelines, with an application credential that needs no interactive sign-in.
Key concepts
Profile — A saved set of credentials and defaults. Use several profiles to keep accounts or projects apart.
Application credential — A project-scoped ID and secret for automation; see Projects and Access.
Output format — Results print as a table by default; --output json or --output yaml suit scripts.
Before you start
- Python 3.12 or later and
pip. - A Patrii Cloud account, and an SSH key pair on your computer: the CLI encrypts the credentials it stores with your SSH public key.
Step by step
- Install the package
Install
patrii-cliwith pip, ideally in a virtual environment, then check thatpatrii --versionanswers. - Save your credentials
Run
patrii config init. It asks for the API URL (keep the default), your email, password and project, and stores them encrypted with your SSH key. - Sign in
- Run
patrii auth login. When MFA is enabled, add--mfa-codeor setPATRII_MFA_CODE. - Prefer
patrii auth sso-loginwhen your organization signs in with SSO: it prints a verification link and opens your browser.
- Run
- Pick the project and format
Commands use your default project. Switch it with
patrii project switch, or override it for one command with the global--projectoption. Global options go right afterpatrii. - Automate with an application credential
In a pipeline, export
PATRII_APP_CREDENTIAL_IDandPATRII_APP_CREDENTIAL_SECRET; the CLI then signs in with them and needs no saved password or MFA code.
Examples
python3 -m venv ~/.venvs/patrii source ~/.venvs/patrii/bin/activate pip install ./patrii-cli # folder containing the package patrii --version
patrii config init patrii auth login --mfa-code 123456 patrii auth whoami
patrii auth sso-login
patrii project list patrii --project <project-id> server list patrii --output json server list
patrii auth app-credential create --name ci-deploy # store the secret now, it is shown only once export PATRII_APP_CREDENTIAL_ID=<credential-id> export PATRII_APP_CREDENTIAL_SECRET=<credential-secret> patrii server list
patrii auth login --profile staging patrii auth use staging patrii auth list
Limits & specifications
Global options (before the command):
| Option | Effect |
|---|---|
--project, -p | Run the command in another project than your default. |
--output, -o | table (default), json or yaml. |
--region, -r | Override the default region. |
--profile | Use a named profile for this command. |
--debug | Print request details to troubleshoot. |
Best practices
- Use an application credential, never your own password, in CI and scripts, and give it an expiry date.
- Use
--output jsonwhen a script reads the result.
FAQ
Can I use the CLI with Terraform credentials?
PATRII_APP_CREDENTIAL_ID and PATRII_APP_CREDENTIAL_SECRET, while the Terraform provider reads PATRII_APPLICATION_CREDENTIAL_ID and PATRII_APPLICATION_CREDENTIAL_SECRET.Where is the full list of commands?
patrii --help, then --help on any group or command, for example patrii server create --help.Learn more
Everything you can do here in the console is also available through the Patrii Cloud API for automation and scripting.