# createGuardianEnrollmentTicket results in undefined

**URL:** <https://community.auth0.com/t/createguardianenrollmentticket-results-in-undefined/80382>\
**Category:** Get Help\
**Tags:** enrollment, guardian, management-api, mfa\
**Created:** [March 23, 2022, 3:40am UTC](https://community.auth0.com/t/createguardianenrollmentticket-results-in-undefined/80382 "2022-03-23T03:40:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![akberiqbal](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/akberiqbal/32/35545_2.png) [@akberiqbal](https://community.auth0.com/u/akberiqbal)\
**Post date:** [March 23, 2022, 3:40am UTC](https://community.auth0.com/t/createguardianenrollmentticket-results-in-undefined/80382/1 "2022-03-23T03:40:45Z")

</div>

I want to trigger MFA enrollment email programmatically.

**working** able to do it using the [API](https://auth0.com/docs/api/management/v2#!/Guardian/post_ticket)  
**not working** : unable to do it using Auth0 package as per [ManagementClient - Documentation](https://auth0.github.io/node-auth0/ManagementClient.html#createGuardianEnrollmentTicket)

Please note that the issue is with `createGuardianEnrollmentTicket` only… looked at this [hint](https://github.com/auth0/node-auth0/issues/470) but that didn’t work either

I am able to trigger other actions via Management API (both API & Auth0 package) like `getGuardianEnrollments` or `sendEmailVerification` etc.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 25, 2022, 5:07pm UTC](https://community.auth0.com/t/createguardianenrollmentticket-results-in-undefined/80382/3 "2022-03-25T17:07:31Z")

</div>

Hi @akberiqbal,

Can you please share a code snippet of the call you are trying to make?

---

<div class="post-metadata">

**Author:** ![akberiqbal](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/akberiqbal/32/35545_2.png) [@akberiqbal](https://community.auth0.com/u/akberiqbal)\
**Post date:** [March 28, 2022, 5:12am UTC](https://community.auth0.com/t/createguardianenrollmentticket-results-in-undefined/80382/4 "2022-03-28T05:12:09Z")

</div>

After a lot of permutation/combinations, found a working solution…

```auto
const createGuardianEnrollmentTicketForUser = async (userId) => {
    const ManagementClient = require('auth0@2.27.0').ManagementClient;

    const managementClient = new ManagementClient({
      domain: 'MY_DOMAIN',
      clientId: "MY_CLIENT_ID",
      clientSecret: "MY_CLIENT_ID",
      scope: 'read:users update:users create:guardian_enrollment_tickets'
    });

    return new Promise(async (resolve, reject) => {
      if (managementClient && userId) {
        try {
          await managementClient.createGuardianEnrollmentTicket(
            {
              "user_id": userId,
              "send_mail": true
            },
            function (err, ticket) {
              if (err) {
                reject(err);
              }
              resolve(ticket);
            }
          );
        } catch (exp) {
          console.log('createGuardianEnrollmentTicketForUser exp:', exp);
          resolve([]);
        }
      } else {
        resolve([]);
      }
    });
  };

```

Hope the Auth0 people can update the [official documentation](https://auth0.github.io/node-auth0/ManagementClient.html#createGuardianEnrollmentTicket) with the following items:

- body is required for this function, e.g. `{ "user_id": userId, "send_mail": true }`
- auth0@2.27.0 works

Thanks

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 30, 2022, 1:10pm UTC](https://community.auth0.com/t/createguardianenrollmentticket-results-in-undefined/80382/5 "2022-03-30T13:10:34Z")

</div>

Thanks for sharing your solution.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 21, 2022, 11:58pm UTC](https://community.auth0.com/t/createguardianenrollmentticket-results-in-undefined/80382/6 "2022-04-21T23:58:21Z")

</div>


