<p>
The Apprite CLI allows you to create and deploy databases, collections, buckets, teams and functions to your Appwrite project from a configuration file. This is especially helpful if you're trying to track project setup using version control.
</p>

<h2><a href="/docs/command-line-deployment#initializeProject" id="initializeProject">Initializing Your Project</a></h2>

<p>After you're logged in, the CLI needs to be initialized with your Appwrite project. You can initialize the CLI using:</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite init project</code></pre>
</div>

<p>The following prompts will guide you through the setup process. The init command also creates an <a href="/docs/command-line-deployment#appwriteJSON">appwrite.json</a> file representing your Appwrite project.

<p>You can fetch all the existing databases and collections in your current project using:</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite init collection</code></pre>
</div>

<p>You can fetch all the existing teams in your current project using:</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite init team</code></pre>
</div>


<h2><a href="/docs/command-line-deployment#deployFunctions" id="deployFunctions">Deploying Appwrite Functions</a></h2>

<p>The CLI also handles the creation and deployment of Appwrite Functions. Run this command in the folder holding your <code>appwrite.json</code> file.</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite init function
? What would you like to name your function? My Awesome Function
? What runtime would you like to use? Node.js (node-15.5)
✓ Success</code></pre>
</div>

<p>This command creates a new function <b>My Awesome Function</b> in your current Appwrite project and also creates a template function for you to get started.</p>

<p>You can now deploy this function by running this command in the folder holding your <code>appwrite.json</code> file.</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite deploy function
? Which functions would you like to deploy? Awesome Function (621229798628cf5bf712)
ℹ Info Deploying function Awesome Function ( 621229798628cf5bf712 )
✓ Success Deployed Awesome Function ( 621229798628cf5bf712 )</code></pre>
</div>

<h2><a href="/docs/command-line-deployment#deployCollections" id="deployCollections">Deploying Databases and Collections</a></h2>

<p>The Appwrite CLI also helps you deploy your project's databases and collections schema from one project to another.</p>

<p>
    You can deploy all the databases and collections in your <a href="/docs/command-line-deployment#appwriteJSON">appwrite.json</a> file by running this command in the folder holding your <code>appwrite.json</code> file. 
</p>

<p>
    The deploy command will overwrite existing collections causing existing data to be lost. 
    If you already have data in your project, you will need to write your own migration script using a Server SDK instead of using the CLI.
</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite deploy collection</code></pre>
</div>

<h2><a href="/docs/command-line-deployment#teams" id="teams">Deploying Teams</a></h2>

<p>The Appwrite CLI can create teams to organize users. Teams can be used to grant access permissions to a group of users. <a href="/docs/permissions#permission-roles">Learn more about permissions</a>.</p>

<p>Deploy teams by running this command in the folder holding your <code>appwrite.json</code> file. </p>
<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite deploy team</code></pre>
</div>

<h2><a href="/docs/command-line-deployment#deployBucket" id="deployBucket">Deploying Storage Buckets</a></h2>

<p>The Appwrite CLI allows you to configure and deploy buckets across projects. All the bucket's settings are available through the <a href="/docs/command-line-deployment#appwriteJSON">appwrite.json</a> file.</p>

<p>Deploy storage buckets by running this command in the folder holding your <code>appwrite.json</code> file. </p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite deploy bucket</code></pre>
</div>

<h2><a href="/docs/command-line-deployment#avoidingConflicts" id="avoidingConflicts">Avoiding Conflicts</a></h2>
<p>When using <code>appwrite.json</code>, changes made in the Appwrite Console can cause conflicts with the local config. To avoid conflicts, prefer updating configuration locally and deploying instead of using the console.</p>

<h2><a href="/docs/command-line-deployment#appwriteJSON" id="appwriteJSON">The appwrite.json File</a></h2>

<p>An <code>appwrite.json</code> file is created by the CLI when you initialize your project. It stores all the configuration for the CLI to be able to interact with your Appwrite project in JSON format. When using the <code>appwrite deploy</code> command, the CLI uses information from <code>appwrite.json</code> to deploy your functions and collections.</p>

<h3><a href="/docs/command-line-deployment#configurable-options" id="configurable-options">Configurable Options</a></h3>
<p>Here's a complete list of all configurable options in <code>appwrite.json</code>:</p>
<table cellspacing="0" cellpadding="0" border="0" class="full margin-bottom-large">
    <thead>
        <tr>
            <th style="width: 150px">Option</th>
            <th>Type</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>projectId</code></td>
            <td>string</td>
            <td>ID of your Appwrite Project.</td>
        </tr>
        <tr>
            <td><code>projectName</code></td>
            <td>string</td>
            <td>Name of your Appwrite Project.</td>
        </tr>
        <tr>
            <td><code>functions</code></td>
            <td>array of <a href="/docs/command-line-deployment#function-options">functions</a></td>
            <td>Configuration of functions in your project.</td>
        </tr>
        <tr>
            <td><code>databases</code></td>
            <td>array of <a href="/docs/command-line-deployment#databases-options">databases</a></td>
            <td>Configuration of databases in your project.</td>
        </tr>
        <tr>
            <td><code>collections</code></td>
            <td>array of <a href="/docs/command-line-deployment#collection-options">collections</a></td>
            <td>Configuration of collections in your project.</td>
        </tr>
        <tr>
            <td><code>teams</code></td>
            <td>array of <a href="/docs/command-line-deployment#teams-options">teams</a></td>
            <td>Configuration of teams in your project.</td>
        </tr>
        <tr>
            <td><code>buckets</code></td>
            <td>array of <a href="/docs/command-line-deployment#buckets-options">buckets</a></td>
            <td>Configuration of teams in your project.</td>
        </tr>
    </tbody>
</table>

<h3><a href="/docs/command-line-deployment#function-options" id="function-options">Function Options</a></h3>
<table cellspacing="0" cellpadding="0" border="0" class="full margin-bottom-large">
    <thead>
        <tr>
            <th style="width: 150px">Option</th>
            <th>Type</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>$id</td>
            <td>string</td>
            <td>Function ID.</td>
        </tr>
        <tr>
            <td><code>name</td>
            <td>string</td>
            <td>Function Name.</td>
        </tr>
        <tr>
            <td><code>runtime</td>
            <td>string</td>
            <td>Function runtime, must be enabled. <a href="/docs/functions#supportedRuntimes">Learn more about runtimes</a>.</td>
        </tr>
        <tr>
            <td><code>path</code></td>
            <td>string</td>
            <td>Path to folder containing the function's source code.</td>
        </tr>
        <tr>
            <td><code>entrypoint</code></td>
            <td>string</td>
            <td>Entry point of the function relative to the folder specified in path.</td>
        </tr>
        <tr>
            <td><code>ignore</code></td>
            <td>array of strings</td>
            <td>Files to ignore inside the function. <a href="/docs/functions#ignoreFiles">Learn more about ignoring files</a>.</td>
        </tr>
        <tr>
            <td><code>execute</code></td>
            <td>array of strings</td>
            <td>Grants execute permissions to users. <a href="/docs/rest#permissions">Learn more about role strings</a>.</td>
        </tr>
        <tr>
            <td><code>events</code></td>
            <td>array of strings</td>
            <td>Events that trigger the function to execute. <a href="/docs/events">Learn more about events</a>.</td>
        </tr>
        <tr>
            <td><code>schedule</code></td>
            <td>string</td>
            <td>Execute schedule for the function. <a href="/docs/functions#scheduled-execution">Learn more about scheduled executions</a>.</td>
        </tr>
        <tr>
            <td><code>timeout</code></td>
            <td>int</td>
            <td>Execution timeout of the function in seconds, with a maximum configurable limit of 900 seconds.</td>
        </tr>
        <tr>
            <td><code>variables</code></td>
            <td>JSON object</td>
            <td>Variables provided to the function on execution stored as a key-value JSON object.</td>
        </tr>
    </tbody>
</table>

<h3><a href="/docs/command-line-deployment#databases-options" id="databases-options">Databases Options</a></h3>
<table cellspacing="0" cellpadding="0" border="0" class="full margin-bottom-large">
    <thead>
        <tr>
            <th style="width: 150px">Option</th>
            <th>Type</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>$id</code></td>
            <td>string</td>
            <td>Database ID.</td>
        </tr>
        <tr>
            <td><code>name</code></td>
            <td>string</td>
            <td>Database Name.</td>
        </tr>
    </tbody>
</table>

<h3><a href="/docs/command-line-deployment#collection-options" id="collection-options">Collection Options</a></h3>
<table cellspacing="0" cellpadding="0" border="0" class="full margin-bottom-large">
    <thead>
        <tr>
            <th style="width: 150px">Option</th>
            <th>Type</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>$id</code></td>
            <td>string</td>
            <td>Collection ID.</td>
        </tr>
        <tr>
            <td><code>name</code></td>
            <td>string</td>
            <td>Collection Name.</td>
        </tr>
        <tr>
            <td><code>databaseId</code></td>
            <td>string</td>
            <td>ID of the database to which this collection belongs.</td>
        </tr>
        <tr>
            <td><code>enabled</code></td>
            <td>bool</td>
            <td>If the collection is enabled.</td>
        </tr>
        <tr>
            <td><code>documentSecurity</code></td>
            <td>bool</td>
            <td>If access permissions can be defined at the document level.</td>
        </tr>
        <tr>
            <td><code>$permissions</code></td>
            <td>array of strings</td>
            <td>Grants access permissions to users at the collection level. <a href="/docs/rest#permissions">Learn more about permissions</a>.</td>
        </tr>
        <tr>
            <td><code>attributes</code></td>
            <td>array of objects</td>
            <td>Defines a list of attributes in the collection. <a href="/docs/models/attributeList">Learn more about the Attributes List Object</a>.</td>
        </tr>
        <tr>
            <td><code>indexes</code></td>
            <td>array of objects</td>
            <td>Defines a list of indexes in the collection. <a href="/docs/models/indexList">Learn more about the Indexes List Object</a>.</td>
        </tr>
    </tbody>
</table>

<h3><a href="/docs/command-line-deployment#buckets-options" id="buckets-options">Buckets Options</a></h3>
<table cellspacing="0" cellpadding="0" border="0" class="full margin-bottom-large">
    <thead>
        <tr>
            <th style="width: 150px">Option</th>
            <th>Type</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>$id</code></td>
            <td>string</td>
            <td>Bucket ID.</td>
        </tr>
        <tr>
            <td><code>name</code></td>
            <td>string</td>
            <td>Bucket Name.</td>
        </tr>
        <tr>
            <td><code>$permissions</code></td>
            <td>array of strings</td>
            <td>Grants access permissions to users at the bucket level. <a href="/docs/rest#permissions">Learn more about permissions</a>.</td>
        </tr>
        <tr>
            <td><code>fileSecurity</code></td>
            <td>boolean</td>
            <td>Whether file-level security is enabled. <a href="/docs/rest#permissions">Learn more about permissions</a>.</td>
        </tr>
        <tr>
            <td><code>enabled</code></td>
            <td>boolean</td>
            <td>Whether the bucket is enabled or disabled.</td>
        </tr>
        <tr>
            <td><code>maximumFileSize</code></td>
            <td>integer</td>
            <td>Maximum file size supported.</td>
        </tr>
        <tr>
            <td><code>allowedFileExtensions</code></td>
            <td>string[]</td>
            <td>List of allowed file extensions.</td>
        </tr>
        <tr>
            <td><code>compression</code></td>
            <td>string</td>
            <td>Preferred algorithm for compression. Will be one of <code>none</code>, <code>gzip</code>, or <code>zstd</code>.</td>
        </tr>
        <tr>
            <td><code>encryption</code></td>
            <td>boolean</td>
            <td>Whether the bucket's content is encrypted.</td>
        </tr>
        <tr>
            <td><code>antivirus</code></td>
            <td>boolean</td>
            <td>Whether virus scanning is enabled for the bucket's content.</td>
        </tr>
    </tbody>
</table>

<h3><a href="/docs/command-line-deployment#teams-options" id="teams-options">Teams Options</a></h3>
<table cellspacing="0" cellpadding="0" border="0" class="full margin-bottom-large">
    <thead>
        <tr>
            <th style="width: 150px">Option</th>
            <th>Type</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>$id</code></td>
            <td>string</td>
            <td>Team ID.</td>
        </tr>
        <tr>
            <td><code>name</code></td>
            <td>string</td>
            <td>Team Name.</td>
        </tr>
    </tbody>
</table>
