Unable to update user's email

Given a user that looks like this JSON

{
    "created_at": "2023-09-07T09:08:01.738Z",
    "identities": [
        {
            "user_id": "64f992e0506de5e35c294e64",
            "provider": "sms",
            "connection": "sms",
            "isSocial": false
        }
    ],
    "name": "+336XXXXXXXX",
    "nickname": "+336XXXXXXXX",
    "phone_number": "+336XXXXXXXX",
    "phone_verified": true,
    "picture": "https://cdn.auth0.com/avatars/3.png",
    "updated_at": "2023-09-07T09:12:57.778Z",
    "user_id": "sms|64f992e0506de5e35c294e64",
    "user_metadata": {},
    "app_metadata": {},
    "last_ip": "ab87:2121:56c5:b512:1154:66d9:11a4:18fc",
    "last_login": "2023-09-07T09:12:55.951Z",
    "logins_count": 2
}

When I try to update the email address with this kind of request :

curl --location --request PATCH 'https://AUTH0_DOMAIN/api/v2/users/sms|64f992e0506de5e35c294e64' \
--header 'Content-Type: application/json' \
--data-raw '{
  "email": "some.valid.email.address@example.org"
}'

I get this error :

{
    "statusCode": 400,
    "error": "Bad Request",
    "message": "Cannot update email for this user",
    "errorCode": "operation_not_supported"
}

I understand why updating an email address for a social connection is not ok, but an SMS account should allow it, right?

We need to link some email and SMS accounts (by linking the email account into the SMS one) and we are not able to do it because we cannot keep the email address.

I know that we can put the email address in the metadata, but we’d like to have something that makes sense.

Hi @clement.poissonnier,

Welcome to the Auth0 Community!

It looks like the user’s profile is a Passwordless SMS user.

In this case, you will not be able to update the user’s email address, as it is not part of their profile.

One workaround to this would be to include it in the user’s metadata. This way, you can still set a user_metadata.email for the user.

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.