Skip to main content

Prismatic CLI Usage

CLI Tool Overview#

The Prismatic CLI tool allows you to interact with the Prismatic API programmatically so you can build, deploy, and support integrations from the command line. The CLI tool is built using the Prismatic API, so any action that can be completed through the web app or API can be completed through the CLI tool, as well.

Installing the CLI Tool#

Prismatic's CLI tool, prism, is available at https://www.npmjs.com/package/@prismatic-io/prism and can be installed using npm or yarn:

npm install -g @prismatic-io/prism# ORyarn global add @prismatic-io/prism

Authenticating with the CLI Tool#

Once prism has been installed login by typing:

prism login

This will open a web browser for you to authenticate with your Prismatic credentials. Once you authenticate, your CLI tool will store an authentication token for subsequent prism commands.

To verify that you are logged in you can run prism me to see information about your user.

prism meName: Alex CooperEmail: alexander.cooper@progix.ioOrganization: Progix Software

If you want to view the authentication token that your CLI tool uses, run prism me:token.

prism me:tokeneyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik5lVV9aYzFNdFRrSE93bXB1T2ZlUCJ9.eyJodHRwczovL3ByaXNtYXRpYy5pby9lbWFpbCI6InRlc3QudXNlckBlbWFpbC5jb20iLCJodHRwczovL3ByaXNtYXRpYy5pby9sYXN0X2xvZ2luIjoiMzAyMS0wMS0wMVQwMDowMDowMC4wMDFaIiwiaXNzIjoiaHR0cHM6Ly9wcmlzbWF0aWMtaW8udXMuYXV0aDAuY29tLyIsImF1ZCI6WyJodHRwczovL3ByaXNtYXRpYy5pby9hcGkiLCJodHRwczovL3ByaXNtYXRpYy1pby51cy5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNjEyMjA4NjQyLCJleHAiOjE2MTIyOTUwNDIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgZW1haWwgb2ZmbGluZV9hY2Nlc3MifQ.iKQWx95vUWTxF62O3-mZFqHPgfapH7TQjsy-BunqWWDJrhk88byJpJQYy__hJE779qAahkEtZD914zgpZ8UnjGW0i_PUcCf5nZsDJBR-jfTEARCLmeVYge3Hy40BAFzj3eCcCouDFqxMNaD3oeXSjfizO9Cy_P-XKEkDdIOJ-rk

To clear your token from memory and log out, run prism logout.

Running CLI Commands and Getting Help#

All Prismatic CLI commands generally follow the form prism COMMAND. For example, you can run prism customers:list to list all of your customers, or prism integrations:create to create an integration. A full list of prism commands can be found on the Prismatic CLI Command Reference page.

Typing prism --help will also list top-level commands that you can run.

prism --help
Build, deploy, and support integrations in Prismatic from the comfort of your command line
VERSION  @prismatic-io/prism/3.0.0 darwin-x64 node-v14.15.5
USAGE  $ prism [COMMAND]
TOPICS  alerts                 Manage Alerting resources  authorization-methods  List Authorization Methods that Components can use  components             Manage, create, and publish Components  customers              Manage Customers  executions             Fetch results of Instance executions or Integration test runs  instances              Manage Instances  integrations           Manage and import Integrations  logs                   List Log Severities for use by Alert Triggers  me                     Print your user profile information  organization           Manage your Organization
COMMANDS  help    display help for prism  login   Log in to your Prismatic account  logout  Log out of your Prismatic account  me      Print your user profile information

To see subcommands of top level commands, you can type prism COMMAND --help. For example, to see what you can do with customers run

prism customers --help
Manage Customers
USAGE  $ prism customers:COMMAND
TOPICS  customers:credentials  Manage Customer Credentials  customers:users        Manage Customer Users
COMMANDS  customers:create  Create a new Customer  customers:delete  Delete a Customer  customers:list    List your Customers  customers:update  Update a Customer

For a list of all required arguments of a command, type prism COMMAND:SUBCOMMAND --help. For example, to see the required arguments to create a customer, run

prism customers:create --help
Create a new Customer
USAGE  $ prism customers:create
OPTIONS  -d, --description=description  longer description of the customer  -n, --name=name                (required) short name of the new customer

Listing Resources#

All types of prismatic resources (customers, components, integrations, instances, actions, etc.) have :list subcommands. By default, list commands show basic information about the resource, like name and description, but additional information like resource ID can be displayed. You can optionally select exactly what attributes of resources you want to list, you can filter the results, and you can format the results as CSV, JSON, or YAML.

prism components:list
 Label                   Public Description                                                                                   Version Category ─────────────────────── ────── ───────────────────────────────────────────────────────────────────────────────────────────── ─────── ────────────────────── Acme ERP                false  Interact with Acme ERP's inventory and customer systems                                       2       null Airtable                true   Manage items (records) in an Airtable Base                                                    2       Data Platforms Amazon DynamoDB         true   Create, update, fetch, or delete items in an Amazon (AWS) DynamoDB database                   5       Data Platforms Amazon S3               true   Manage files within an Amazon (AWS) S3 bucket                                                 34      Data Platforms Amazon SES              true   Send Emails through Amazon (AWS) SES                                                          5       Application Connectors Amazon SNS              true   Manage subscriptions, topics, and messages within Amazon (AWS) SNS                            7       Data Platforms Amazon SQS              true   Send, receive and manage messages within an Amazon (AWS) SQS queue                            10      Data Platforms AMQP                    true   Send and receive messages on an AMQP-based message broker                                     5       Data Platforms

Listing Resource IDs#

All Prismatic resources have unique IDs. IDs are not displayed by default through list subcommands, but can optionally be displayed with the --extended flag. For example, to see IDs for components, run

prism components:list --extended
 Id                                                               Key                     Label                   Public Description                                                                                   Version Category ──────────────────────────────────────────────────────────────── ─────────────────────── ─────────────────────── ────── ───────────────────────────────────────────────────────────────────────────────────────────── ─────── ────────────────────── Q29tcG9uZW50OjI3ZWM4ODlmLTI1ODUtNDFiMy05MDdlLWI2YWExNTg5ZGNhNA== acmeerp                 Acme ERP                false  Interact with Acme ERP's inventory and customer systems                                       2       null Q29tcG9uZW50OmVkMjcwNmExLThiMTEtNDI0YS05MjM0LTgzZjU4NDBmNzA3NQ== airtable                Airtable                true   Manage items (records) in an Airtable Base                                                    2       Data Platforms Q29tcG9uZW50Ojg3NzE3YThhLTFiODktNDY5My1hYmZlLWRjY2VkMjMxM2RlZg== aws-dynamodb            Amazon DynamoDB         true   Create, update, fetch, or delete items in an Amazon (AWS) DynamoDB database                   5       Data Platforms Q29tcG9uZW50OjE3NmRjYWU3LWEzMzktNDQ2NC1iYmJkLTU4ODllNzdmOWJjYQ== aws-s3                  Amazon S3               true   Manage files within an Amazon (AWS) S3 bucket                                                 34      Data Platforms Q29tcG9uZW50Ojg3NjlhODE1LTY1OTEtNDliZC1hMGQ5LTNhMWNlYjUxZmZkYQ== aws-ses                 Amazon SES              true   Send Emails through Amazon (AWS) SES                                                          5       Application Connectors Q29tcG9uZW50OjNkMzFkYjYxLWFlYzItNDRjZS05NGNkLTVhZWJjMjIxNjlhZg== aws-sns                 Amazon SNS              true   Manage subscriptions, topics, and messages within Amazon (AWS) SNS                            7       Data Platforms Q29tcG9uZW50OmQ5ZmJkYzViLTFhMGUtNDRlMS1hNDcxLTNjMWE0NzFhYzAwNQ== aws-sqs                 Amazon SQS              true   Send, receive and manage messages within an Amazon (AWS) SQS queue                            10      Data Platforms Q29tcG9uZW50OmFmYjNlMTNmLTg0NDctNGJmMC05MWIyLTAxNGQ1OTliYThkYg== amqp                    AMQP                    true   Send and receive messages on an AMQP-based message broker                                     5       Data Platforms

Configuring Columns of a List to Display#

You can optionally choose which attributes of a resource to display using the --columns flag. For example, to get the Key, Label, and ID of all components, you can run

prism components:list --columns key,label,id
 Key          Label           Id ──────────── ─────────────── ──────────────────────────────────────────────────────────────── acmeerp      Acme ERP        Q29tcG9uZW50OjI3ZWM4ODlmLTI1ODUtNDFiMy05MDdlLWI2YWExNTg5ZGNhNA== airtable     Airtable        Q29tcG9uZW50OmVkMjcwNmExLThiMTEtNDI0YS05MjM0LTgzZjU4NDBmNzA3NQ== aws-dynamodb Amazon DynamoDB Q29tcG9uZW50Ojg3NzE3YThhLTFiODktNDY5My1hYmZlLWRjY2VkMjMxM2RlZg== aws-s3       Amazon S3       Q29tcG9uZW50OjE3NmRjYWU3LWEzMzktNDQ2NC1iYmJkLTU4ODllNzdmOWJjYQ== aws-ses      Amazon SES      Q29tcG9uZW50Ojg3NjlhODE1LTY1OTEtNDliZC1hMGQ5LTNhMWNlYjUxZmZkYQ== aws-sns      Amazon SNS      Q29tcG9uZW50OjNkMzFkYjYxLWFlYzItNDRjZS05NGNkLTVhZWJjMjIxNjlhZg== aws-sqs      Amazon SQS      Q29tcG9uZW50OmQ5ZmJkYzViLTFhMGUtNDRlMS1hNDcxLTNjMWE0NzFhYzAwNQ== amqp         AMQP            Q29tcG9uZW50OmFmYjNlMTNmLTg0NDctNGJmMC05MWIyLTAxNGQ1OTliYThkYg==

Filtering List Output#

You can filter the output that a :list subcommand displays using a --filter flag. For example, to only show the component with the key "aws-s3", run

prism components:list --filter 'key=^aws-s3$'
 Label     Public Description                                   Version Category ───────── ────── ───────────────────────────────────────────── ─────── ────────────── Amazon S3 true   Manage files within an Amazon (AWS) S3 bucket 34      Data Platforms
Filter uses regex

The --filter flag uses regex pattern matching, hence the "start of string" ^ character, and "end of string" $ character.

In a bash script, you can combine the --filter flag with the --columns and --no-header flags to get the ID of a specific resource

AWS_S3_COMPONENT_ID=$(prism components:list --filter 'key=aws-s3' --no-header --columns id)echo ${AWS_S3_COMPONENT_ID}Q29tcG9uZW50OjJlMDcyMGU4LTFjNTUtNDY1Ni04NzY0LTI1N2RmZDVhNTE3Mw==

Formatting List Output#

Lists can be optionally formatted as CSV, JSON, or YAML using the --output flag. This flag can be combined with the --columns FORMAT and --filter flag, as well. For example, if you want id and key of all components in CSV format, run

prism components:list --output csv --columns id,key
Id,KeyQ29tcG9uZW50OjNiODQ1NGVkLTE5MjEtNGYxNS04MDhmLTBlZjkxNDEzNGRhZA==,airtableQ29tcG9uZW50OjE5YWYzMzQzLTU2OWQtNDY0Yy1iNTAwLWUzM2RhNjg3YmQxYQ==,aws-dynamodbQ29tcG9uZW50OjQ1ZGVkMzEyLTE2ZmUtNGY0Mi04OWVlLWZhOTIzNTQ0ZDEyYQ==,aws-s3Q29tcG9uZW50OmEyNjRjMTVkLThjM2QtNGY0Yi1hNDNkLWEzYzMzZjgxZGY0MQ==,aws-sesQ29tcG9uZW50OjRmNTM5MWVkLWE3ZDEtNDljZi1hNjViLTE4ZGNmMTRmNGJlMA==,aws-snsQ29tcG9uZW50OmQ0YjhmOTllLWU3YTYtNDUxMS04YWIxLWNkOGQ1M2QyNDJiZg==,aws-sqs

Using the Prismatic CLI in Bash Scripts#

Multiple prism commands can be strung together to manage prismatic resources. For example, to create an instance of an integration you need to know the ID of the integration, and the ID of the customer you want to deploy an instance to. You can use customers:list, integrations:list and instances:create commands together to create a new instance.

# Get the Customer IDCUSTOMER_ID=$(  prism customers:list \    --columns id \    --filter 'Name=^FTL Rockets$' \    --no-header)
# Get the Integration IDINTEGRATION_ID=$(  prism integrations:list \    --columns id \    --filter 'name=Fabricate 3D Model' \    --no-header)
# Create the instanceprism instances:create \  --customer ${CUSTOMER_ID} \  --integration ${INTEGRATION_ID} \  --name 'Fabricate 3D Model for FTL Rockets' \  --description 'Queue the 3D printing job for a model rocket'

Troubleshooting Common Problems#

Misconfiguration of WSL or NodeJS can result in odd behaviors for a Node-based package like prism. Here are a couple of common problems with their respective solutions:

Error: spawn cmd.exe ENOENT#

When you run prism login from within Windows Subsystem for Linux (WSL), you might see Error: spawn cmd.exe ENOENT. This is a problem with the WSL distribution's PATH environment variable. Ensure that your PATH environment variable contains System32, which is where cmd.exe is located. Usually, you can run something like this:

export PATH=$PATH:/mnt/c/Windows/System32

Error: spawn xdg-open ENOENT#

If you run prism login in a headless Linux environment (a Linux environment without a desktop or web browser such as an Ubuntu server or docker container), prism will be unable to open a GUI web browser to authenticate you. You might see an error that reads Error: spawn xdg-open ENOENT or Error: Exited with code 3.

You will need to authenticate on a computer with a desktop environment and web browser, and copy over the cached API tokens to your headless Linux environment. Your cached API key is available in $HOME/.config/prism/config.yml and it will look something like this:

accessToken: >-  eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL3ByaXNtYXRpYy5pby9lb...expiresIn: 86400refreshToken: AKES5555555551zpAKJcA19Kx5O9AKc90-1zpAKJcA19Kscope: openid profile email offline_accesstokenType: Bearer

Copy this file to your headless Linux system at $HOME/.config/prism/config.yml.

prism: command not found#

If you have followed the instructions above to install prism, but then see prism: command not found on Linux or MacOS, or 'prism' is not recognized as an internal or external command, operable program or batch file. on Windows when you run prism, you likely don't have your NodeJS PATH configured correctly. Ensure that your PATH environment variable contains the bin/ directory of your NodeJS installation.