Programmatically create a Custom Content type on saving a form
A content type is a config entity, you can create one like any other config entity (*):

$content_type = \Drupal\node\Entity\NodeType::create([
  'type' =&gt; $machine_name,
  'label' =&gt; $label,
]);
$content_type-&gt;save();