Directus SDK registerUser returning `null` with already existing email

Hi, I’m allowing users to register from my website and using directus sdk.
While doing

    const result = await client.request(
      registerUser(email, password, { first_name: firstName, last_name: lastName, verification_url: verificationUrl })
    );

result is null even when email is already used by an existing user.

I tried with a CURL to users/register and it just returns a 204. No verification email is sent for existing users, while it works flawlessly for non-existing users.

I haven’t changed anything in the directus_users default fields, if not adding one that’s a relationship.

What could be causing this? I want to implement error handling and this is not letting me :confused:

When using registerUser() with an email that already exists, Directus returns null (204 No Content) by design — it doesn’t tell you if the user exists for security reasons.

If you want to check if the email is already in use before registering, you can do this:

const existing = await directus.items('users').readByQuery({
  filter: { email: { _eq: email } }
});

if (existing.data?.length) {
  console.log('User already exists');
} else {
  await directus.request(registerUser(email, password));
}

This way you check first, then call registerUser() only if the email isn’t taken.