UserId Mapping
UserId Mapping allows you to map existing userIds (from your old auth provider) to the SuperTokens userIds. This prevents you from having to update the existing userIDs in your application's table.
As an example, if after creating the user in SuperTokens, their userId is fa7a0841-b533-4478-95533-0fde890c3483
and the existing userId for that user is customUserId
, then you can map these user IDs by calling the following API:
- Single app setup
- Multi app setup
curl --location --request POST '/recipe/userid/map' \
--header 'api-key: ' \
--header 'Content-Type: application/json; charset=utf-8' \
--data-raw '{
"superTokensUserId": "fa7a0841-b533-4478-95533-0fde890c3483",
"externalUserId": "customUserId"
}'
curl --location --request POST '/recipe/userid/map' \
--header 'api-key: ' \
--header 'Content-Type: application/json; charset=utf-8' \
--data-raw '{
"superTokensUserId": "fa7a0841-b533-4478-95533-0fde890c3483",
"externalUserId": "customUserId"
}'
Now whenever this user signs in, or if you fetch information about this user from SuperTokens, their userID will be customUserId
.
note
The maximum allowed size of the externalUserId
is 128 characters.