Import Content Using the Seed Command

The “seed” command in Contentstack CLI allows users to import content to your stack, from Github repositories. It's an effective command that can help you to migrate content to your stack with minimal steps.

To import content to your stack, you can choose from the following two sources:

  • Contentstack’s GitHub organization: In this organization, we have provided sample content, which you can import directly to your stack using the seed command. Learn more.
  • Non-Contentstack's GitHub repository: You can import stack content available on Github’s repository belonging to any organization or individual. Learn more.

Now let’s import content to your stack by performing the following steps:

  1. Log in to the CLI session
  2. Use the “seed” command


  1. Log in to the CLI Session

    To use the "seed" command, you will first have to generate the authtoken.

    Note: By default, this CLI session will work for the app hosted in the North America region. If you want to switch to the Europe region, follow the steps mentioned in the Set Region command section.

    To generate the authtoken, open your terminal, and run the following command to log in to your Contentstack account:

    csdx auth:login

    It will ask you to provide your email address and password of your Contentstack account. Once you log in successfully, an authtoken will be generated and saved to the CLI session until you log out from this session.

    Additional Resource: To learn more about the login command, refer to the Login command section.

  2. Use the “seed” command

    Now to use the "seed" command, you can choose from the following options to import the content to your stack, as mentioned above.

    Note: If you want to upload your stack’s content onto your Github repository for other users to import it, refer to the steps mentioned in the Upload stack's content on the Github section.

    Let's discuss the above two options in detail.

    Option 1: Import from Contentstack’s GitHub Organization

    In this option, you can import content that Contentstack provides from its Github organization. To use this option, run the following command in your terminal:

    csdx cm:seed

    After running the above command, it will ask you to provide the following inputs:

    • Organization name: You’ll get a list of organizations to which you have access. Select the one from the list where your source stack is located. You can also create a new stack if required.
    • Stack preference: Next, you need to select your choice to create a new stack:
      • If you select Yes, you’ll receive a list of all organizations you are a member of. You can choose an organization to which you either have the owner or the admin rights to create a new stack. Then, provide a name to the newly created stack.
      • If you select No, you need to choose the organization where your destination stack resides. You will then need to select that particular stack on which you have permissions to import content. Refer to the Stack Roles documentation to learn more about permissions.

    Tip: To ensure the above operations are error-free, we recommend that you select the option of creating a new destination stack. This is because the new stack will be empty and you can easily import content to it. If you choose to import content to an existing stack, you first need to ensure that the stack is empty and then proceed with the import operation.

    Finally, you’ll get the content imported to the destination stack.

    Option 2: Import from Non-Contentstack's Github Repository

    In this option, you can import content from your Github repository to your stack. However, first, ensure the content is available on your Github repository. To upload content on Github, perform the steps specified in the Upload stack’s content on Github section.

    Note: The Github repository needs to be public.

    To import content from the Github repository, run the “seed” command in the following format:

    csdx cm:seed -r “<github_org_name_or_github_user_name/repo_name>”

    For example, if you want to import stack content from the “blog” repository belonging to the “Stackcontent” organization, the “seed” command should follow this format: csdx cm:seed -r “Stackcontent/blog”

    Likewise, you can use the above format if the stack content resides in an individual’s Github repository by replacing the organization’s name with the individual’s username.

    After running this command, you'll be prompted to select an organization and a stack, as discussed in the Option 1 section.

Upload Stack’s Content on Github

Note: We assume that you are familiar with Github and Git. If not, go through Github’s documentation to create and upload files to a Github repository.

Before uploading stack content on your Github repository, you need to create a public repository in this format: stack-<name>. For example, stack-exportdata, stack-gatsby-website, etc.

To upload your stack’s content to your recently-created Github repository, first, you need to export the stack’s content. To do so, follow these steps:

  1. Create a folder named “stack” in your machine.
  2. Then, open your terminal and run this command to log in to the CLI session:
    csdx auth:login
    This command will ask you to provide your Contentstack account credentials.
  3. After successful login, run this command to export your stack’s content to the “stack” folder:
    csdx cm:export -A -s <stack_ApiKey> -d “<path_to_store_content>”
    For example, csdx cm:export -A -s blt********** -d “C:\Users\Name\Desktop\content\stack”

    This command will export your stack’s content and save it to the “stack” folder
  4. Open your Git Bash terminal and follow the steps specified in Github’s documentation to upload the “stack” folder to your repository.

    Refer to this Sample repository present in Contentstack's GitHub organization to learn the folder structure while uploading content to your Github repository. 

Now any user can import your stack’s content to their stack by performing the steps mentioned in the Option 2 section.

Points to Remember

  • To import content into an existing destination stack, make sure you have permissions to create content in the destination stack.
  • If you want to create a new stack for storing content, make sure you have the “owner” or “admin” rights in that organization.

Was this article helpful?

Thanks for your feedbackSmile-icon

On This Page