Create a Stitch App (Stitch CLI)

On this page

MongoDB Stitch applications can be created and initialized with the stitch-cli import command.

New Stitch applications are created by running import from an application directory that cannot be linked to an existing application by Application ID.




Create an Application Directory

Create a new directory for your application and navigate into it.

Add a stitch.json file to the root level of the directory. The file should contain an empty JSON object.

echo \{\} > stitch.json


Upon successfully creating a new Stitch application, stitch-cli will immediately update stitch.json to reflect the new app.

This overwrites any existing values in stitch.json.


Optional: Initialize Application Entities

If you’d like to pre-configure any services in your application (including linking to a specific MongoDB Atlas cluster), create sub-directories and configuration files for those entities in the application directory. For details on the directory structure and contents, see Application File Schema.


If you are importing any new entities that require sensitive values (e.g. auth tokens, client secrets, etc.), define a secret for each sensitive value before you import.


Authenticate a MongoDB Atlas User

To create a MongoDB Stitch application with stitch-cli, users must authenticate with Atlas using an API Key.

stitch-cli login --api-key=my-api-key --private-api-key=my-private-api-key

Run the Import Command

Run the following command in your application directory:

stitch-cli import

Before importing, stitch-cli will search existing applications that the authenticated user has access to. If app_id was not provided or does not match any existing application, stitch-cli will ask you if you’d like to create a new Stitch application. After you confirm, stitch-cli will prompt you for the following information:

Field Description
Atlas Project ID The Project ID or Project Name of the Atlas project that you want to host your Stitch application. You can find these values on the Settings page of the Atlas UI.
App Name

The name of your application.

Application names may only contain ASCII letters, numbers, underscores, and hyphens.


stitch-cli converts application names to lowercase.


Verify Application Creation

You can confirm that your new application was successfully imported by checking stitch.json. If the creation was successful, the app_id and name fields will have updated values that reflect the new application.


New application imports happen in two phases:

  1. A new application is created on the server.
  2. The local application directory is imported to the new application.

It’s possible for stitch-cli to successfully create a new app but then throw an error during the import phase. In this case, no entities are imported but the new application is not deleted. If you encounter this, fix any errors causing the import to fail and run the import command again.