Summary
Use the Yext CLI to create a new Yext account or clone an existing account's configuration into another account. This is useful for building demo accounts, setting up a sandbox for testing, or backing up a configuration before making large changes.
This article covers two workflows:
- Clone an account's configuration into a new or existing account
- Create a demo account, either with default settings or a custom configuration file
Prerequisites
- The Yext CLI installed. See Get Started with the Yext CLI.
- For cloning: the Account ID of the account you want to copy (the "source account") and the Account ID of the account you're cloning into (the "destination account")
Clone an Account's Configuration
The "source account" is the account you want to copy. The "destination account" is the account you're cloning into.
1. Log in to the source account
Run yext init.
- For a production account:
yext init
- For a sandbox account:
yext init -u sandbox
When prompted, select Create new credentials if this is the first time you're connecting the CLI to this account. Enter your Account ID when prompted, then select the link to authenticate.
2. Pull resources from the source account
yext resources pull ~/source-account
This creates a directory named source-account in your root directory. You can change the destination by editing the path in the command.
3. Edit resources locally (optional)
If you want to change anything before applying to the destination account, edit the files now and save your changes.
- To exclude a resource from the destination account, delete its file.
- If your account configuration includes a repository, such as a Search frontend built with Jambo or Theme:
- To create a new repo, set
repoConfigto:
- To create a new repo, set
"repoConfig": {
"targetRepoName": "${{youraccount_targetRepo}}"
}- To copy an existing repo set as a template repo, set
repoConfigto:
"repoConfig": {
"targetRepoName": "${{youraccount_targetRepo}}",
"templateRepo": "https://github.com/your-org/your-repo-url"
}- Find your repo URL for
repoConfig.templateRepoin the Sites section of your account. - Use
${{insertVariablePrompt}}syntax to add variables to your configuration files. TheinsertVariablePromptstring is surfaced as a prompt during the apply step, so you can name values like the destination repository at that time.
4. Log in to the destination account
Run yext init again, this time authenticating into the destination account:
- For a production account:
yext init
- For a sandbox account:
yext init -u sandbox
5. Apply resources to the destination account
yext resources apply ~/source-account
If you pulled your resources into a different directory in step 2, use that directory name instead of source-account.
Expected result
The CLI applies the source account's configuration to your destination account. If the command returns an error, review the error message for the specific resource that failed.
Troubleshooting
- If you get an authentication error or land in the wrong account, confirm you're using the correct
-uflag for that account. - If you're moving between production and sandbox environments, you may see configuration discrepancies. Return to the local edit step to resolve conflicts before reapplying.
Create a Demo Account
Create a new account directly from the CLI, either with default settings or with a custom configuration file.
Create a default account
- Run the following command:
yext accounts create
- The command returns a JSON response with the new account's ID and the user credentials to log in to it.
By default, this creates a production account with a name of "Test Account" and an owner user. To create the account in sandbox instead, add the -u or --universe flag:
yext accounts create -u sandbox
Create an account with a custom configuration
To set specific properties on the new account, such as its name, account type, users, locations, or entities, supply a TOML configuration file:
yext accounts create test-account-config.toml
A configuration file can define fields including the account name, account type, country, language, users and their roles, locations, entities, categories, and subscription features. For example:
name = "Test Account" accountType = "DIAGNOSTIC" country = "US" language = "en" defaultLocationType = "LOCATION" [users.OWNER] firstName = "Test" lastName = "User" emailPrefix = "testUser" password = "<PASSWORD>" [[acl.OWNER]] roles = ["FULL_CONTROL"] [templateLocations.LOC_] count = "2" template = "test_basic_location"
Expected result
The command returns the new account's ID and confirms the account was created with the properties you specified.