Create a custom block programmatically and specify region and pages on which created block must shown on For create block programmatically I use

$block = BlockContent::create([
  'info' =&gt; 'block 3',
  'type' =&gt; 'basic',
  'langcode' =&gt; 'en',
  'body' =&gt; [
    'value' =&gt; '&lt;h1&gt;Block's body&lt;/h1&gt;',
    'format' =&gt; 'full_html',
  ],
]);
$block-&gt;save();


It works good enough but is it possible also to specify region and then on which pages created block must shown on?
You have to create a block config entity to place a block:

use Drupal\block\Entity\Block;

  $placed_block = Block::create([
    'id' =&gt; 'block_machine_name',
    'theme' =&gt; 'classy',
    'weight' =&gt; 0,
    'status' =&gt; TRUE,
    'region' =&gt; 'footer',
    'plugin' =&gt; 'block_content:' . $block-&gt;uuid(),
    'settings' =&gt; [],
    'visibility' =&gt; [
      'request_path' =&gt; [
        'id' =&gt; 'request_path',
        'negate' =&gt; FALSE,
        'pages' =&gt; '/path',
      ],
    ],
  ]);
  $placed_block-&gt;save();