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. Exporting and importing workspaces can be done using one of the client libraries, or via the browser-based UI.

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("filename.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("filename.json")));
    }

}

Browser-based UI

The workspace summary page has a pair of export and import buttons that can be used instead of the web API.

Workspace export and import buttons