Skip to main content

DBOS CLI

Workflow Management Commands​

These commands all require the URL of your DBOS system database. You can supply this URL through the --sys-db-url argument or through a dbos-config.yaml configuration file.

npx dbos workflow list​

Description: List workflows run by your application in JSON format ordered by recency (most recently started workflows last).

Arguments:

  • -s, --sys-db-url <string>: Your DBOS system database URL
  • -n, --name <string> Retrieve functions with this name
  • -l, --limit <number> Limit the results returned (default: "10")
  • -u, --user <string> Retrieve workflows run by this user
  • -t, --start-time <string> Retrieve workflows starting after this timestamp (ISO 8601 format)
  • -e, --end-time <string> Retrieve workflows starting before this timestamp (ISO 8601 format)
  • -S, --status <string> Retrieve workflows with this status (PENDING, SUCCESS, ERROR, MAX_RECOVERY_ATTEMPTS_EXCEEDED, ENQUEUED, DELAYED, or CANCELLED)
  • -v, --application-version <string> Retrieve workflows with this application version
  • -a, --application-name <string> Retrieve workflows owned by this application (workflows owned by no application are always included)

Output: A JSON-formatted list of workflow statuses. The input, output, and error fields are rendered as human-readable strings rather than as JSON values.

npx dbos workflow get​

Description: Retrieve information on a workflow run by your application.

Arguments:

  • -s, --sys-db-url <string>: Your DBOS system database URL
  • <workflow-id>: The ID of the workflow to retrieve.

Output: A JSON-formatted workflow status. The input, output, and error fields are rendered as human-readable strings rather than as JSON values.

npx dbos workflow steps​

Arguments:

  • -s, --sys-db-url <string>: Your DBOS system database URL
  • <workflow-id>: The ID of the workflow to retrieve

Output: A JSON-formatted list of workflow steps. The output and error fields are rendered as human-readable strings rather than as JSON values.

npx dbos workflow cancel​

Description: Cancel a workflow so it is no longer automatically retried or restarted. If the workflow is executing, it is interrupted at the beginning of its next step.

Arguments:

  • -s, --sys-db-url <string>: Your DBOS system database URL
  • <workflow-id>: The ID of the workflow to cancel.

npx dbos workflow resume​

Description: Resume a workflow from its last completed step. You can use this to resume workflows that are cancelled or that have exceeded their maximum recovery attempts. You can also use this to start an ENQUEUED workflow, bypassing its queue.

Arguments:

  • -s, --sys-db-url <string>: Your DBOS system database URL
  • <workflow-id>: The ID of the workflow to resume.

npx dbos workflow fork​

Description: Fork a new execution of a workflow, starting at a given step. This new workflow has a new workflow ID but the same code version, unless you specify a different one with --application-version. Forking from step N copies the results of all previous steps to the new workflow, which then starts running from step N.

Arguments:

  • <workflow-id>: The ID of the workflow to fork.
  • -s, --sys-db-url URL: Your DBOS system database URL.
  • -f, --forked-workflow-id: Custom ID for the forked workflow
  • -v, --application-version: Custom application version for the forked workflow
  • -S, --step INTEGER: Restart from this step (required)

npx dbos workflow queue list​

Description: Lists all currently enqueued workflows in JSON format ordered by recency (most recently enqueued workflows last).

Arguments:

  • -s, --sys-db-url <string>: Your DBOS system database URL
  • -n, --name <string> Retrieve functions with this name
  • -t, --start-time <string> Retrieve functions starting after this timestamp (ISO 8601 format)
  • -e, --end-time <string> Retrieve functions starting before this timestamp (ISO 8601 format)
  • -S, --status <string> Retrieve functions with this status (ENQUEUED, PENDING, or DELAYED)
  • -l, --limit <number> Limit the results returned
  • -q, --queue <string> Retrieve functions run on this queue
  • -a, --application-name <string> Retrieve functions owned by this application (functions owned by no application are always included)

Output: A JSON-formatted list of workflow statuses. The input, output, and error fields are rendered as human-readable strings rather than as JSON values.

Application Management Commands​

npx dbos schema​

Description: Create the DBOS system database and internal tables. By default, a DBOS application automatically creates these on startup. However, in production environments, a DBOS application may not run with sufficient privilege to create databases or tables. In that case, this command can be run with a privileged user to create all DBOS database tables.

After creating the DBOS database tables with this command, a DBOS application can run with minimum permissions, requiring only access to the DBOS schema in the system database. Use the -r flag to grant a role access to that schema. Such an application should also be configured with runMigrations: false, so it never attempts to alter the schema and instead verifies at launch that this command has brought the system database up to date.

Arguments:

  • systemDatabaseUrl: A connection string for your DBOS system database, in which DBOS stores its internal state. This command will create that database if it does not exist and create or update the DBOS system tables within it.
  • -r, --app-role <string>: The role with which you will run your DBOS app. This role is granted the minimum permissions needed to access the DBOS schema in your system database.
  • -s, --schema <string>: The schema name for the DBOS system tables. Defaults to dbos.
  • --print-migrations <all|NUMBER>: Instead of running the migrations, print their SQL to standard output, either all of them (for a fresh database) or starting from a migration number (to upgrade an existing database). Postgres only.
  • --print-user-role: Instead of executing them, print the SQL statements granting --app-role access to the DBOS system tables.

Use these last two flags to emit SQL you can apply yourself, for example if your database is managed by a DBA. They never connect to a database, so the systemDatabaseUrl argument is optional when using them (if supplied, it is only used to annotate the output). The output is only SQL and comments, but it contains CREATE INDEX CONCURRENTLY, so it must run outside a transaction block.

npx dbos schema --print-migrations all ${DBOS_SYSTEM_DATABASE_URL} > migrations.sql
npx dbos schema --print-user-role -r my_app_role ${DBOS_SYSTEM_DATABASE_URL} > grants.sql

npx dbos reset​

Reset your DBOS system database, deleting metadata about past workflows and steps. Use only in a development environment.

Arguments:

  • --sys-db-url, -s <string>: Your DBOS system database URL
  • --yes, -y: Skip confirmation prompt.

npx dbos rename-application​

After renaming an application, transfer ownership of everything in the system database (workflows, steps, queues, schedules, and application versions) from its old name to its new name. Equivalent to DBOSClient.renameApplication; see there for details. Prints the number of rows transferred, by table. Stop the application being renamed before running this.

Arguments:

  • -s, --sys-db-url <string>: Your DBOS system database URL
  • -f, --from <string>: The application's previous name. Omit to only adopt rows owned by no application (requires --adopt-unclaimed-rows).
  • -t, --to <string>: The application that ends up owning the rows. Required.
  • --adopt-unclaimed-rows: Also transfer rows owned by no application.
  • --batch-size <number>: The number of completed workflows and steps transferred per transaction (default: 10000)
  • --schema <string>: The schema name for the DBOS system tables. Defaults to dbos.
  • -y, --yes: Skip confirmation prompt.

npx @dbos-inc/create​

Description: This command initializes a new DBOS application from a template into a target directory.

Arguments:

  • -n, --appName <app-name>: The name and directory to which to instantiate the application. Application names should be between 3 and 256 characters and must contain only lowercase letters and numbers, dashes (-), and underscores (_).
  • -t, --template <template>: The template to use for project creation. If not provided, will prompt with a list of available templates.

npx dbos start​

Description: Start your DBOS application by executing the start command defined in dbos-config.yaml. For example:

runtimeConfig:
start:
- "node dist/main.js"

DBOS Cloud executes this command to start your app.