API Docs
Workspaces Model
Add Workspace
12min
api endpoint documentation /api/workspaces/add description this endpoint allows you to create a new workspace by sending a post request the request body contains workspace details such as name, workspace type, plan id, and optional logo images endpoint post https //admin \<your site> com/api/workspaces/add headers accept application/json specifies that the request expects a json response authorization bearer \<jwt token> a json web token (jwt) that authenticates the request replace \<jwt token> with a valid token content type multipart/form data; boundary=\<boundary> specifies that the request body is in multipart/form data format, necessary for file uploads request body the request body should be in multipart/form data format, containing the following fields name string the name of the workspace workspace type string the type of workspace (e g , "iframe embed", "jwt full embed") plan id string (optional) the id of the plan to associate with the workspace square logo file (optional) a square logo image file for the workspace must be less than 10mb image logo file (optional) a logo image file for the workspace must be less than 10mb integrations string (optional) a json string containing integration configurations for the workspace example request body { "name" "finance department", "workspace type" "iframe embed", "plan id" "678e56b778bd25203b900e63", "square logo" "\[binary file data]", "image logo" "\[binary file data]", "integrations" "\[]" } note for multipart/form data requests with file uploads, the actual request body will be formatted differently, with binary file content included method post sends a request to create a new workspace with the specified details example request (node js) const fetch = require('node fetch'); const formdata = require('form data'); const fs = require('fs'); const url = 'https //admin \<your site> com/api/workspaces/add'; const form = new formdata(); // add text fields form append('name', 'finance department'); form append('workspace type', 'iframe embed'); form append('plan id', '678e56b778bd25203b900e63'); form append('integrations', '\[]'); // add files if available if (fs existssync(' /finance square logo png')) { form append('square logo', fs createreadstream(' /finance square logo png')); } if (fs existssync(' /finance logo png')) { form append('image logo', fs createreadstream(' /finance logo png')); } const options = { method 'post', headers { 'accept' 'application/json', 'authorization' 'bearer eyjhbgcioijiuzi1niisinr5cci6ikpxvcj9 ', // no need to set content type as form data sets it automatically with boundary }, body form }; fetch(url, options) then(response => response json()) then(data => console log(data)) catch(error => console error('error ', error)); response the api will return a json response indicating the success or failure of the operation success response (200) { "status" 200, "data" { "workspace id" "6812cf45a9b33e12456789ab" }, "message" "workspace successfully added " } error response (400) { "status" 400, "message" "file size must be less than 10mb " } or { "status" 400, "message" "name is required " } authentication this api requires a valid jwt token for authentication and admin privileges ensure that the token is included in the authorization header as bearer \<jwt token> usage notes this endpoint requires admin privileges to use the system automatically generates a unique slug from the workspace name if no plan id is provided, the system assigns a free (no charge) plan logo files must be less than 10mb in size when creating a jwt full embed workspace type, the layout type is automatically set to no navigation for other workspace types, the layout type defaults to left navigation the system automatically creates subscription and transaction records based on the selected plan if integrations are provided, the system will create workspace integration credentials for each integration the system logs workspace creation in the activity log