> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withsutro.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sutro CLI quickstart

> Create, preview, validate, and publish a SLang backend with the Sutro CLI.

## Overview

The Sutro CLI is the fastest way to build a SLang backend from your local editor. You write `.slang` files locally, and Sutro runs validation, preview, and publish workflows on the hosted Sutro backend.

In this guide, you'll:

* Install the CLI.
* Log in with your Sutro account.
* Link a local folder to a Sutro Project and Application.
* Run a remote dev session with live reload.
* Validate and publish the backend.

## Before you begin

You need:

* Node.js 22 or later.
* npm, pnpm, or yarn.
* A Sutro account.

Publishing requires a payment method on file. You can add one in [Sutro Studio](https://studio.withsutro.com/) or [Sutro Console](https://console.withsutro.com/).

## Steps

<Steps>
  <Step title="Install the CLI">
    Install the CLI globally:

    <CodeGroup>
      ```sh npm theme={null}
      npm install --global @sutro-dev/sutro-cli
      ```

      ```sh pnpm theme={null}
      pnpm add --global @sutro-dev/sutro-cli
      ```

      ```sh yarn theme={null}
      yarn global add @sutro-dev/sutro-cli
      ```
    </CodeGroup>

    Confirm that the `sutro` command is available:

    ```sh theme={null}
    sutro --version
    ```
  </Step>

  <Step title="Log in">
    Start the browser-based login flow:

    ```sh theme={null}
    sutro login
    ```

    The CLI opens Sutro Studio in your browser. After login completes, the CLI stores a local session for future commands.

    If your environment cannot open a browser automatically, print the login URL instead:

    ```sh theme={null}
    sutro login --no-open
    ```
  </Step>

  <Step title="Create a local project">
    Create a new folder and initialize it with Sutro:

    ```sh theme={null}
    mkdir task-api
    cd task-api
    sutro init --name "Task API"
    ```

    `sutro init` creates a remote Project and Application, writes `sutro.config.json`, and creates `app.slang` if it does not exist.

    To link an existing Application instead, pass its ID:

    ```sh theme={null}
    sutro init --application-id <APPLICATION_ID>
    ```
  </Step>

  <Step title="Write a SLang backend">
    Replace the generated `app.slang` with a small task API:

    ```slang theme={null}
    entity Task
      fields
        title: TEXT
        completed: BOOLEAN

    action CreateTask(title: TEXT): Task
      body
        return create Task {
          title := title
          completed := false
        }

    action ListTasks(): Page<Task>
      body
        return pageOf Task

    trigger CreateTask on HttpRequest
      endpoint POST /tasks
      arguments
        title := @request.body.title

    trigger ListTasks on HttpRequest
      endpoint GET /tasks
    ```
  </Step>

  <Step title="Start a remote dev session">
    Start the preview server:

    ```sh theme={null}
    sutro dev
    ```

    The CLI creates a remote dev session, uploads your local `.slang` files, and prints a preview API URL:

    ```text theme={null}
    Remote dev session ready.
      url:     https://dev-<SESSION_ID>.app.withsutro.com/api/latest/
      session: <SESSION_ID>
      version: 1.0.1
      files:   1
    ```

    Keep this command running while you edit. When a `.slang` file or `sutro.config.json` changes, the CLI uploads the latest source and refreshes the remote preview.

    Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to stop the dev session.
  </Step>

  <Step title="Call the preview API">
    Open a second terminal and call the URL printed by `sutro dev`:

    ```sh theme={null}
    export SUTRO_DEV_API="https://dev-<SESSION_ID>.app.withsutro.com/api/latest"

    curl -X POST "$SUTRO_DEV_API/tasks" \
      -H "Content-Type: application/json" \
      -d '{"title":"Write CLI docs"}'

    curl "$SUTRO_DEV_API/tasks"
    ```

    Replace `<SESSION_ID>` with the value printed by `sutro dev`.
  </Step>

  <Step title="Validate the project">
    Run validation before publishing:

    ```sh theme={null}
    sutro validate
    ```

    The CLI uploads the local SLang source to Sutro for validation and prints compiler diagnostics if the project does not compile.
  </Step>

  <Step title="Publish the backend">
    Publish the linked Application:

    ```sh theme={null}
    sutro publish
    ```

    The CLI uploads the local SLang source, publishes the Application, and prints the published API URL and version.
  </Step>

  <Step title="Inspect the published app">
    Check the linked Application:

    ```sh theme={null}
    sutro status
    ```

    Save the published OpenAPI spec:

    ```sh theme={null}
    sutro openapi --out openapi.json
    ```
  </Step>
</Steps>

<Check>
  You now have a local SLang project linked to Sutro, a remote dev preview, and a published backend API.
</Check>

## Learn more

* [CLI command reference](/docs/cli/command-reference)
* [Project configuration](/docs/cli/project-config)
* [Introduction to SLang](/docs/SLang/introduction)
* [SLang data modeling](/docs/SLang/data-modeling)
