Workspace export and import

Structurizr provides a way to export and import workspace content, allowing you to archive, backup and reuse a workspace when it is no longer needed. The JSON export contains everything in your workspace - the model, views (including the layout information), documentation, and decision records. Exporting and importing workspaces can be done using the Structurizr CLI, one of the client libraries, or via the workspace summary page.

1. Structurizr CLI

You can use the Structurizr CLI to export a workspace as a JSON document, and save it to a file. For example:

./structurizr.sh pull -id 1234 -key API_KEY -secret API_SECRET

This JSON file can then be imported at a later date as follows:

./structurizr.sh push -id 1234 -key API_KEY -secret API_SECRET -workspace workspace.json

2. Web API and client libraries

You can use the web API via one of the client libraries to export a workspace as a JSON document, and save it to a file. For example, with the Java client library:

public class ExportWorkspace {

    private static final long WORKSPACE_ID = 1234;
    private static final String API_KEY = "key";
    private static final String API_SECRET = "secret";

    public static void main(String[] args) throws Exception {
        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        WorkspaceUtils.saveWorkspaceToJson(structurizrClient.getWorkspace(WORKSPACE_ID), new File("workspace.json"));
    }

}

This JSON file can then be imported at a later date as follows:

public class ImportWorkspace {

    private static final long WORKSPACE_ID = 1234;
    private static final String API_KEY = "key";
    private static final String API_SECRET = "secret";

    public static void main(String[] args) throws Exception {
        StructurizrClient structurizrClient = new StructurizrClient(API_KEY, API_SECRET);
        structurizrClient.setMergeFromRemote(false);
        structurizrClient.putWorkspace(WORKSPACE_ID, WorkspaceUtils.loadWorkspaceFromJson(new File("workspace.json")));
    }

}

3. Workspace summary page

The workspace summary page has a pair of export and import links that can be used instead of the web API. Please note that you can only import a workspace when it is unlocked.