How to update userId via api (from server side)

I want to explicitly set the user id of specific visitors - who have previously signed up to my site.

I would like to do it from a server, not from the client side.
is there an endpoint I can use to do that?