Back

How to create an organization with CLI

  • 0
  • Self Hosted
Tanner Meade
21 Aug, 2023, 16:18

Is it possible to create an organization with the CLI?

TL;DR
To create an organization with the command line interface (CLI): 1. Install the CLI SDK: `npm install appwrite-cli` 2. Write code in your JavaScript project to create the organization. For example: ```js function createOrg(orgName){ let sdk = await sdkForConsole(); response = await teamsCreate({ teamId: 'unique()', name: orgName, sdk, parseOutput: false }) } ``` 3. Call the `createOrg` function with the desired organization name. 4. Run the code with `node index.js`. It is also possible to use the
Tanner Meade
21 Aug, 2023, 16:19

I figure it would have to be with appwrite teams ... but I think that's limited to in-project teams.

Binyamin
21 Aug, 2023, 16:28

You're correct on the main assumption that the teams is used for the in-project teams.

But this is one of the great things in Appwrite it uses the same logic in-project for managing the system-wide project, your console.

For example you can see here that the teamsCreate function is used for creating system-wide organization

The reason it create that team in the system-wide level is because the SDK use for that one is the console one as you can see two lines before

TypeScript
    let sdk = await sdkForConsole();

In conclusion, if you'll use the CLI as JavaScript library you'll be able to create system-wide organization just as in the code above. Otherwise it's not an option.

Tanner Meade
21 Aug, 2023, 16:35

use the CLI as JavaScript library what do you mean by this? By CLI I mean the command line interface https://appwrite.io/docs/command-line-deployment

Binyamin
21 Aug, 2023, 16:38

I mean by creating a JavaScript project For example you create a node js project Then install the cli SDK

TypeScript
npm install appwrite-cli

And in your code you can write something like this

TypeScript
function createOrg(orgName){
  let sdk = await sdkForConsole();

  response = await teamsCreate({
            teamId: 'unique()',
            name: orgName,
            sdk,
            parseOutput: false
        })
}

Then in your index.js

TypeScript
  createOrg('Org1');

And run it

TypeScript
node index.js
Binyamin
21 Aug, 2023, 16:39

Of course this is a rough coding, you'll need to add the async and the error handling

Tanner Meade
21 Aug, 2023, 16:41

So I guess creating an organization is impossible with just using the command line interface?

Binyamin
21 Aug, 2023, 16:42

Otherwise it's not an option. Yes

Drake
21 Aug, 2023, 19:00

best to create a feature request for this

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more