Programmatically create a workspace before its creation
Currently, Twenty CRM does not provide a public API to programmatically create a workspace before its creation. Workspace creation is typically initiated through the user interface during the sign-up process.
Did anyone here wrote a script / db queries to automate the sign-up process and the workspace creation without the user interface?
THank you for your time!
Ron
19 Replies
Maybe something like this?
Hello
create a workspace before its création
sorry unsure to understand this part
Also unless I'm mistaken you can still create a workspace by hitting the signup with an already existing user that will result in creating a new workspace for this user ( this is handled in the endpoint directly)Thank you @prastoin , maybe I should rephrase it to "Signup and create workspace programmatically for self-hosted env".
The idea is that we want to automate the signup of a self-hosted setup and create the workspace programmatically once setup is done.
I think what you're looking for is the
SignUpInNewWorkspace
mutationGreat, so if I want to write a script automating this operation (without calling the graphql) I can directly call the
signInUpService.signUpOnNewWorkspace
command.
Did someone here develop a script to do it from the command line? Do you think that it will be a good contribution to the community?I'm not sure to understand when you would like to create a workspace exactly
Why not hitting the api directly ? across your script rather than calling the service method ?
The endpoint already exists so I don't think a command would be necessary
If you don't want to hit the grapql API you can search for an existing endpoint on the REST one does not exist
Got it, that's why I thought a script for self-hosted use casewhere people want to configure the first workspace unattended. Not sure if someone else has this use case? maybe someone in the past and could share their script :20:
Twenty's images contains a default workspace
You can create a new workspace from the UI

Hoping this anwers your question ! In case let me know !
Yep, the idea is not to use the UI, I am trying to automate it upon deployment - unattended, programmatically through a script that will take the workspace name, image, email, pass etc. and do the work without anyone clicking buttons 🐒
Each time you deploy you wanna create a new workspace ? Are you looking for tests seeders ?
Sorry I am not familiar with the term "tests seeder" but I am pretty sure I am not looking for it. I am looking to automate the creation of new crm env in my company with predefined goal / users / settings and this is an essential part of it
From my understanding each time you will deploy your application you expect your workspace to get reset completely by a new one ?
Yes, in my use case, after deploying the crm - my application will automatically create a new workspace without human intervention - unattended, with specific input that I give it - workspace name, users, etc
Also instead of test seeders, it would be nice if you could provide the emails and passwords to create in advance (per workspace)
Unless I'm mistaken official we planned Twenty SDK/ infra as code for around Q4
From now on I would recommended creating a script hitting your twenty api directly
Or you can build your own Twenty image and ship your custom commands with it
Just curious if someone has a list of the mutations that are called when user onboards the system:
1. signUp
2. activateWorkspace
3. updateOneWorkspaceMember
You can find all available mutation in the graphql docs here https://twenty.com/developers/graphql/core
I think what you're looking for are mutations:
- signUpInNewWorkspace
- activateWorkspace
- updateWorkspaceMember
Let me know if I can help !