We changed our privacy policy. Read more.

When trying to figure out how to do something the core does programmatically, a good place to start is the core itself. In particular, you want to look at Craft's controllers which handle all interactions with the UI and Craft's services which provide a lot of methods for common tasks. In this case, you're looking for craft\controllers\SectionsController::...

Only top voted, non community-wiki answers of a minimum length are eligible