How can I create an entity bundle programmatically?
Bundles are configuration.

You define a config entity with the name of the bundle of the custom entity:

class FooType extends ConfigEntityBundleBase


Then you can create a new bundle:

$bundle = FooType::create([
  'id' =&gt; 'newbundle',
  'label' =&gt; 'New Bundle',
  'revision' =&gt; FALSE,
]);
$bundle-&gt;save();


Bundles usually are not created programmatically. Most times modules put bundles in /config/install as yml files.