We are building test suite in our CI/CD pipeline, It will automatically create a scratch org and then it will start the test script but metadata deployment is failing due to email template folder not found error,

Something like

sfdx force:email:create:folder --name "Dummy" --description "This is Dummy email folder";

Does anyone know how to create a folder using cmd line or in API without manual creation?

1 Answer 1


You just retrieve the folder from any org like any other type of metadata:

sfdx force:source:retrieve -m EmailFolder:Folder_Name

Which will get you a folder XML file:


If this is a shared folder, you may need to edit the shares manually before deployment (e.g. if it references roles or users that won't otherwise exist).

Once you have this XML file, you can reliably create the folder in any org you want to deploy to (e.g. in a new Scratch Org).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .