Search code examples
google-apps-scriptgoogle-drive-apigoogle-workspace

How do I create a Shared Drive with Apps Script?


How do I create a Shared Drive with Google Apps Script?


Solution

  • This is possible with the Advanced Drive service

    • Keep in mind that Apps Script uses the Drive API version v2
    • The process to create a new shared drive with Drive API v2 is described here
    • Incorporating this into Apps Script, the corresponding method would be Drive.Drives.insert(resource, requestId);
    • requestId is an Id you choose to assign to the drive
    • resource is the body of the request, it should contain the drive name

    Sample:

    Drive.Drives.insert({"name": "mySharedDrive"}, 12345);