# CARTO CLI

The CARTO CLI is our command line interface for interacting with CARTO directly from the terminal (or through an AI agent). With it, users can:

* Find and manage Maps, Workflows, connections and developer credentials
* Transfer Maps and Workflows between different organizations
* Check your organization's quotas and activity
* Interact with existing AI Agents in the organization
* Transfer assets between users

For a full list of features, please refer to the [**CLI's documentation**](https://www.npmjs.com/package/@carto/carto-cli).

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2F0spQzTUTSDPS3wBL6agU%2Fcarbon.png?alt=media&#x26;token=fa90e268-40eb-4689-9899-c907512a57c2" alt="" width="563"><figcaption></figcaption></figure>

## Getting started

To get started with the CARTO CLI, head over to the NPM package page and follow the installation instructions:

{% embed url="<https://www.npmjs.com/package/@carto/carto-cli>" %}

Once the CLI is installed, you can use the following command to authenticate to your CARTO account using the browser. Organizations with [SSO](https://docs.carto.com/carto-user-manual/settings/sso) configured must include their organization name: `carto auth login --organizaion-name acme`.

```
carto auth login
```

To work with multiple organizations in the CLI, create **named profiles**. This step will be necessary for transferring maps and workflows between organizations. Each profile stores separate credentials and their names must be unique. Use `carto auth use <profile>` to switch between them. To create a profile, simply add its desired name to the end of the login command:

```
carto auth login team2
```

Your authentication token will eventually expire (typically within 24 hours). The CLI will warn you when your token is expiring and prompt you to reauthenticate. You can check your authentication status, user details and available CLI profiles at any time with:

```
carto auth status
```

## Transferring maps and workflows between organizations

Users can use the CLI to transfer maps and workflows from one organization to another. As a prerequisite, you need to be authenticated to both organizations (the one containing the asset and the one receiving it) using **profiles**.&#x20;

Once the profiles are set up, you will need the **ID** of the map or workflow that you wish to copy across. You can get this ID from the CARTO Workspace, by clicking on the three dots of the Map/Workflow card in the workspace or from the Map/Workflow URL. Alternatively, you can search for a specific Map/Workflow by name directly in the CLI using the command `carto maps list --search map name` and `carto workflows list --search  workflow name`&#x20;

Once you have the ID, run the following command to copy the Map/Workflow across to the other organization:

```
carto maps copy <id> --dest-profile <profile name>
```

```
carto workflows copy <id> --dest-profile <profile name>
```

By default, CARTO will try to map the connection(s) used by the Map/Workflow with connections in the second organization that have **the same name** (i.e if a map is using a Snowflake connection called *production,* the CLI will look for another connection with the same name in the second organization to use it in the newly copied map)**.**  If there are no connections with the same name, you will have to map them manually using `--connection-mapping` . For example:

{% code overflow="wrap" %}

```
carto maps copy <id> --dest-profile <profile name> --connection-mapping "dev-bq=prod-bq,dev-postgres=prod-postgres" 
```

{% endcode %}

{% code overflow="wrap" %}

```
carto workflows copy <id> --dest-profile <profile name> --connection <connection name>
```

{% endcode %}

{% hint style="info" %}
The CLI assumes mapped connections **have the same data access permissions**. If not, the copied resources will fail to load.
{% endhint %}

{% hint style="info" %}
Copying does not delete the original resource.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.carto.com/carto-user-manual/carto-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
