How to get the URL of an entity being created at hook_entity_insert() stage?
The URL object is there, you're just calling it wrong.

The code for this is a little complicated:

  $path = $entity-&gt;toUrl('canonical', ['absolute' =&gt; TRUE])-&gt;toString();
  $params['message'] = $path;


For more info, see this issue.