API - Folder Creation, Move Document Functionality

I may just be missing it in the Glassworks API explorer, but does anyone know how to create folders via API, and move documents to different folder locations via API?

Cheers,

-Dirk

Answers

  • Caden_Armstrong
    Caden_Armstrong Member Posts: 472 PRO

    If you look at /api/documents/{did}
    the document's parentId is the folder id.
    To move to another folder, modify the parentId to a different folder's ID.

    To make a folder, its an undocumented API endpoint, so proceed with caution, use at your own risk, I'm not an Onshape person, etc etc..

    POST /api/folders
    Body:
    {"name":"My new folder","ownerId":"yourCompanyId","ownerType":1,"parentId":"insertparentfolderIdhere"}

    www.smartbenchsoftware.com --- Renaissance --- Kestrel -- SmartLink
    Experts in Onshape Automation - Custom Features and Integrated Applications
  • MichaelPascoe
    MichaelPascoe Member Posts: 2,965 PRO
    edited April 2025

    This is an old post, but for clarification for future users:
    To actually move that document to the new folder, you will need to use another undocumented endpoint:

    POST : /api/globaltreenodes/folder/{:fid}

    BODY:

    {  
    "itemsToMove" : [ { "resourceType" : "document", "id" : <docid> } ] }

     


    RENDERCAD - Photorealistic product rendering.
    CADSharp - Professional CAD + software consulting.

    ▚▞▚▞▚▞▚▞▚