Manual User Creation Does Not Trigger Rule

Hello, I am currently using Auth0 for authorization for my react app where I am also using Hasura. I have created this rule that is suppose to insert an auth0 user into a table within my Hasura.

function syncUserToHasura (user, context, callback) {
  const query = `
    mutation($userId: String!, $email: String, $name: String, $avatar: String) {
      insert_organizations(
        objects: [{
            auth0_id: $userId
            email: $email
	    name: $name
	    profile_picture: $avatar
        }],
        on_conflict: {
            constraint: organizations_auth0_id_key,
            update_columns: [updated_at]
        }) {
            affected_rows
      }
    }
  `;

  const variables = {
    userId: user.user_id,
    email: user.email,
    name: user.name,
    avatar: user.picture,
  };

  const payload = {
    headers: {
      "content-type": "application/json",
      "x-hasura-admin-secret": configuration.ACCESS_KEY
    },
    url: `Redacted`,
    body: JSON.stringify({ query, variables }),
  };

  request.post(payload, (error, response, body) => callback(error, user, context));
}

When I manually create a user from my Auth0 dashboard, this rule seems to not get triggered. It is only until the user tries to login does it seem to trigger as a new row is added into my table. I am new to this so it is very possible I overlooked something; however, I was wondering if this is possible. If so, what am I missing?

Hello @jfletcher , Welcome to the Auth0 Community!

Manually creating a user via Dashboard will not trigger rules.
Rules are part of the login flow only and do not trigger for Management API and Dashboard operations.

More information here:

Please let me know if this helps.

Regards,
Sid

2 Likes

Thanks for the quick response! I am unsure how I missed that, thank you!

1 Like

No worries! We’re here for you!

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