Modify identity provider external ID for a User

In case of a migration, I create users via API. We use Discourse-openid-connect for connecting to our SSO (Keycloak). I want to associate users account via API with ID from Keycloak. How a
i can do this ?

I’ve seen the API /u/by-external/oidc/{ext_id].json to get user info from external ID.
I’ve also seen the API /u/{username}.json for update a User, and a field external_ids. But i don’t know the value to put on…

I have the same question but I haven’t found an answer yet. I too am creating new users via API and they login via OpenID. I can’t set their external_ids when creating the user (it’s ignored) and my attempt to update the user with an external ID doesn’t make any change to the user’s record.

I’ll add though that I decided to use a custom user field (user_fields[1]) to store my external ID and that works.