How to programmatically add content to a group in the Group Module?
Given you have the group entity and node entity, you can simply create a GroupContent entity.

$groupEntity = ... The group entity.
$node = ... The node entity.

$type = $type = $groupEntity-&gt;getGroupType()-&gt;id() . '-group_node-' . $node-&gt;getType();

$groupContentEntity = \Drupal\group\Entity\GroupContent::create([
    'gid' =&gt; $groupEntity-&gt;id(),
    'entity_id' =&gt; $node-&gt;id(),
    'type' =&gt; $type,
]);
$groupContentEntity-&gt;save();