Howto change default branch for a repository by CLI or API

The projects API endpoint supports the create action and edit action, which can pass the default_branch parameter.