From your console or terminal

Deploy content to Connect Cloud from your R console or a terminal using the rsconnect package for R, the rsconnect-python CLI for Python, or the Quarto CLI. This is useful for scripting deployments and for running them from non-interactive environments such as CI/CD pipelines.

rsconnect Package

Note

Deploy R content programmatically from any R session

You can deploy R content programmatically to Connect Cloud using the rsconnect package.

Deployment Process

1. Install the package

install.packages("rsconnect")

2. Sync with Connect Cloud

Interactively
rsconnect::connectCloudUser()

This will open your browser to authorize access, and prompt you to choose an account if you have multiple. You can confirm that the account was successfully added by running rsconnect::accounts().

Noninteractively

First, add a credential for use with Connect Cloud. Then add it, specifying the name of your account, which can be found here:

rsconnect::connectCloudClientCredentials(
  clientId="<YOUR_CLIENT_ID_HERE>",
  clientSecret="<YOUR_CLIENT_SECRET_HERE>",
  account="<YOUR_ACCOUNT_HERE>"
)

The client ID and secret are shown when you create the credential. Each credential has its own pair, and the secret is only displayed once.

3. Deploy the content

Imagine you have a Shiny application named app.R stored in a directory named Dashboard.

/MyProject/
├── Dashboard/
│   └── app.R
└── other_code.R

To start the deployment, run the following code.

rsconnect::deployApp(appDir='Dashboard')

Please note:

  • You do not need to provide the appDir argument if your application is stored in the root directory.
  • If you have multiple accounts configured, you will be asked which account you would like to use for the deployment.

4. Access the content

A successful deployment will open your browser and bring you to your content’s administration page.

If your deployment fails, please review the logs and error messages provided in the R session console.

Additional Resources

Other useful rsconnect functions include accounts(), remove_account(), deployDoc(), and deploySite(). For a complete list of packages and their functionality, please visit the official rsconnect documentation.

rsconnect-python CLI

Note

Deploy Python content programmatically from any terminal. Requires rsconnect-python version 1.31.0 or higher.

You can deploy Python content programmatically to Connect Cloud using the rsconnect-python command-line interface.

Deployment Process

1. Install the CLI

pip install rsconnect-python

uv tool install rsconnect-python and pipx install rsconnect-python also work, and keep the CLI out of your project’s environment.

2. Sync with Connect Cloud

Interactively

Add your Connect Cloud account under a nickname, specifying the name of your account, which can be found here. The nickname is any name you choose, and you pass it to --name when you deploy — the examples below use cloud:

rsconnect add --connect-cloud \
  --account "<YOUR_ACCOUNT_HERE>" \
  --name "<NAME_OF_YOUR_ACCOUNT_CREDENTIAL>"

This will open your browser to authorize access. You can confirm that the account was successfully added by running rsconnect list.

Noninteractively

First, add a credential for use with Connect Cloud. Then add it, specifying the name of your account:

rsconnect add --connect-cloud \
  --account "<YOUR_ACCOUNT_HERE>" \
  --name "<NAME_OF_YOUR_ACCOUNT_CREDENTIAL>" \
  --client-id "<YOUR_CLIENT_ID_HERE>" \
  --client-secret "<YOUR_CLIENT_SECRET_HERE>"

The client ID and secret are shown when you create the credential. Each credential has its own pair, and the secret is only displayed once.

--client-id and --client-secret also read from the CONNECT_CLOUD_CLIENT_ID and CONNECT_CLOUD_CLIENT_SECRET environment variables. Setting them there keeps the secret out of your shell history and out of process listings on the build machine.

Every rsconnect deploy command accepts the same options, so CI does not need a separate rsconnect add step. A client ID and secret together with an account identify the target on their own, so a build can deploy in one command:

export CONNECT_CLOUD_CLIENT_ID="<YOUR_CLIENT_ID_HERE>"
export CONNECT_CLOUD_CLIENT_SECRET="<YOUR_CLIENT_SECRET_HERE>"

rsconnect deploy shiny "<PATH_TO_YOUR_APP_DIRECTORY>" \
  --connect-cloud \
  --account "<YOUR_ACCOUNT_HERE>"

Credentials supplied this way are used for that command only and are not written to the credential store.

3. Deploy the content

Imagine you have a Shiny for Python application named app.py stored in a directory named Dashboard.

/MyProject/
├── Dashboard/
│   ├── app.py
│   └── requirements.txt
└── other_code.py

To start the deployment, run the following command.

rsconnect deploy shiny Dashboard --name cloud

Please note:

  • Replace shiny with the command for your content type: streamlit, dash, bokeh, notebook, quarto, or html. Connect Cloud accepts these types; rsconnect deploy --help lists every command, including ones that only Posit Connect accepts.
  • Some commands take a file rather than a directory. notebook takes the .ipynb file itself, and quarto and html accept either.
  • For the commands that take a directory, you can use . if your application is stored in the root directory.
  • --name selects which configured account to deploy to. After the first deployment, the directory’s deployment record remembers the target, so you can omit it.
  • The directory needs a dependency file: requirements.txt, or a uv.lock or pyproject.toml named with --requirements-file. Without one the deployment stops before uploading. Add --force-generate to snapshot the active environment with pip freeze instead.

4. Access the content

A successful deployment prints the URL of your content, which brings you to its administration page.

If your deployment fails, please review the logs and error messages printed in your terminal.

To capture the URL in a script, add --quiet. This suppresses the progress lines and the streamed build log, leaving the content URL as the only thing written to standard output:

URL=$(rsconnect deploy shiny Dashboard --name cloud --quiet)

Warnings and errors still go to standard error, and a failed deployment writes no URL, so $URL is only set when the deployment succeeded. --quiet cannot be combined with -v/--verbose.

Additional Resources

Other useful rsconnect-python commands include rsconnect list, rsconnect remove, rsconnect write-manifest, and rsconnect content. For a complete list of commands and their functionality, please visit the official rsconnect-python documentation.

Quarto CLI

Note

Publish Quarto documents and websites from the command line. Requires Quarto version 1.9 or higher.

You can publish Quarto documents, websites, books, and dashboards to Connect Cloud directly using the Quarto CLI. From your project directory, run:

quarto publish

Select Posit Connect Cloud from the list of available providers.

The first time you publish, Quarto will open your browser to authenticate with your Posit account. After authorization, your content is rendered and deployed automatically, and a _publish.yml file is created in your project to record the content ID and URL for future updates. This file does not store credentials and is safe to check into version control.

For more information, see the Quarto publishing documentation.

Retrieving Your Source Code

Content published from your console or terminal is uploaded directly rather than pulled from a repository, so Connect Cloud holds the only copy of what was deployed. If you have permission to edit the content, you can download the source of any revision as a .zip archive from the content history page.