Add a field in node metadata
There no such thing as "node metadata", there are just fields.

So the easiest thing to do is to create a field (in the UI for example, you can then also export the configuration into your module), field_work_id or something, and in put in there with $node-&gt;set('field_work_id', $work_id).

You can do that in hook_node_presave(), but then you might not have an node ID yet for a node that is just being created and is already published. You could also use hook_node_insert()/hook_node_update(), but then you need resave the node and make sure you don't trigger a loop.

You can also save the work ID in your own table, or you can store the node together with the work ID in a way that allows you to do a lookup with a query.