Programmatically creating new Workspaces
2025/04/25 4:28 PM
Hi, is there an API to create workspaces?
I can see there is a method to get a workspace root IContentFolderManager.GetRoot(workspaceName)
This throws an exception if the workspace does not exist.
However, I can't see an equivalent CreateRoot()
, a suitable overload of IContentFolderManager.Create
, or properties of CreateContentFolderParameters
that would facilitate this.
Thanks.
Environment
- Xperience by Kentico version: 30.3.0
- .NET version: [8]
- Execution environment: local
- https://docs.kentico.com/api/content-management/content-hub-folders#content-hub-folder-management
Answers
I think you can use WorkspaceInfo directly - a workspace is just a logical container that a content item, smart folder, or content folder is associated with.
public class MyService(IInfoProvider<WorkspaceInfo> provider)
{
private reasonly IInfoProvider<WorkspaceInfo> provider = provider;
public Task CreateWorkspace(...)
{
var newWorkspace = new WorkspaceInfo()
{
WorkspaceName = "...",
DisplayName = "..."
};
await provider.SetAsync(newWorkspace);
}
}
Yes, that works perfectly thanks.
To answer this question, you have to login first.