I solve it using partial import endpoint. This is a sample using python keycloak.
new_users = keycloak_admin.partial_import_realm(
"realm_name",
{
"ifResourceExists": "FAIL",
"users": [
{
"id": "cbe0c97f-4552-4ef4-8b25-358060737016",
"username": "[email protected]",
"email": "[email protected]",
"enabled": True,
"firstName": "Example",
"lastName": "User",
"emailVerified": True,
"attributes": {"userRole": ["patient"]},
"credentials": [
{
"type": "password",
"value": "StrongP@ssword123",
"temporary": False,
}
],
}
],
},
)