# Rule not used when creating a user via the Management API, is there an alternative approach?

**URL:** <https://community.auth0.com/t/rule-not-used-when-creating-a-user-via-the-management-api-is-there-an-alternative-approach/97829>\
**Category:** Get Help\
**Tags:** managment-api-v2, actions, rules\
**Created:** [January 10, 2023, 10:54am UTC](https://community.auth0.com/t/rule-not-used-when-creating-a-user-via-the-management-api-is-there-an-alternative-approach/97829 "2023-01-10T10:54:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![evert](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evert/32/30553_2.png) [@evert](https://community.auth0.com/u/evert)\
**Post date:** [January 10, 2023, 10:54am UTC](https://community.auth0.com/t/rule-not-used-when-creating-a-user-via-the-management-api-is-there-an-alternative-approach/97829/1 "2023-01-10T10:54:06Z")

</div>

Given our following rule:

```auto
function (user, context, callback) {
  var uuid = require("uuid");

  user.app_metadata = user.app_metadata || {};

  var promise = Promise.resolve(1);

  if (!user.app_metadata.uuid) {
    user.app_metadata.uuid = uuid();

    promise = auth0.users.updateAppMetadata(user.user_id, user.app_metadata);
  }

  promise.then(() => {
    if (context.idToken) {
      // Include the uuid in the issued ID token if applicable
      context.idToken["https://www.ourcompany.com/auth0-uuid"] = user.app_metadata.uuid;
    }

    if (context.accessToken) {
      // Include the uuid in the issued access token if applicable
      context.accessToken["https://www.ourcompany.com/uuid"] = user.app_metadata.uuid;
    }
    
    callback(null, user, context);
  }).catch(callback);
}

```

This rule is only executed when logging in via our Angular application. I like to be able to use this rule when I create a new user via the Management API. Now I understood from the documentation this is not possible because the rule is not called. I can confirm this because after having created some users, none of them have the required UUID.

The reason is I like to automatically create users for webload testing. Suppose I create 50 users, I need to manually log in every time to initialize the UUID in the claims. Of course this would be a 1 time operation, but I rather like to automate this.

Is there a solution to my problem? I read about converting rules to actions, but it is not clear if this is a solution.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [January 11, 2023, 12:30am UTC](https://community.auth0.com/t/rule-not-used-when-creating-a-user-via-the-management-api-is-there-an-alternative-approach/97829/3 "2023-01-11T00:30:49Z")

</div>

Hey there @evert !

> [@evert](#):
>
> Is there a solution to my problem? I read about converting rules to actions, but it is not clear if this is a solution.

I believe creating a post registration Action mirroring the logic of the rule shared should do the trick. A post registration Action will be triggered regardless of if the user is created using the Auth0 Dashboard, Management API, or registering on the sign-up page.

> **[Post User Registration Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/post-user-registration-flow)**
>
> Learn about the Post User Registration Flow and post-user-registration Action trigger, which runs after a user has been created for a Database or Passwordless connection.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![evert](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/evert/32/30553_2.png) [@evert](https://community.auth0.com/u/evert)\
**Post date:** [January 17, 2023, 8:49am UTC](https://community.auth0.com/t/rule-not-used-when-creating-a-user-via-the-management-api-is-there-an-alternative-approach/97829/4 "2023-01-17T08:49:05Z")

</div>

Thank you for replying to this issue!

I will try this.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [January 17, 2023, 4:29pm UTC](https://community.auth0.com/t/rule-not-used-when-creating-a-user-via-the-management-api-is-there-an-alternative-approach/97829/5 "2023-01-17T16:29:21Z")

</div>

No problem, happy to help!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 9, 2023, 12:42am UTC](https://community.auth0.com/t/rule-not-used-when-creating-a-user-via-the-management-api-is-there-an-alternative-approach/97829/6 "2023-03-09T00:42:25Z")

</div>

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