Copy and Rename workspace using API

I am wondering how easy (or if it is even possible) to copy a workspace and rename it using the API.
I know this is available via interface, but want to automate making several copies of the workspace (1 for each of my students)

Any guidance / example would be great.

Answers

  • Ethan_K
    Ethan_K Member, Onshape Employees Posts: 57 image
    Hi Paul,

    Thanks for reaching out! This is indeed supported. Do you want to make new document from the workspace? Then use this API:

    {post} /documents/:did/workspaces/:wid/copy Copy Workspace

    The body could have  the following fields: newName, ownerId, ownerTypeIndex, isPublic. isPublic should be a boolean and ownerTypeIndex is an int with the value: 

    0: user 1: company 2: Team

    All of this is laid out in the API Explorer.

    Hope that helps and let me know if you need any more guidance  :)

    -Ethan