# Pre-Registration hook not working with API Call

**URL:** <https://community.auth0.com/t/pre-registration-hook-not-working-with-api-call/6820>\
**Category:** Get Help\
**Tags:** api-authorization, hooks\
**Created:** [June 1, 2017, 12:25am UTC](https://community.auth0.com/t/pre-registration-hook-not-working-with-api-call/6820 "2017-06-01T00:25:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![e.alic](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@e.alic](https://community.auth0.com/u/e.alic)\
**Post date:** [June 1, 2017, 12:25am UTC](https://community.auth0.com/t/pre-registration-hook-not-working-with-api-call/6820/1 "2017-06-01T00:25:19Z")

</div>

I created a pre-registration hook, was able to test in the sandbox without errors. However when I try to register a user from my actual application it fails with a generic message:

```
{
  "name": "InternalExtensibilityError",
  "statusCode": 500,
  "code": "server_error",
  "message": "Internal server error",
  "fromSandbox": true
}

```

Hook code:

```
var response = {};
  if (user.user_metadata.cmsName && user.user_metadata.cmsPw) {
     var ownerId = 1;
     var oemName = "Test";
     response.user = {
      user_metadata: { facilitycode: user.user_metadata.facilitycode, ownerId: ownerId, oemName: oemName}
    };
  } else {
    return cb('Invalid Signup');
  }
  response.user = user;
  cb(null, response);

```

---

<div class="post-metadata">

**Author:** ![prashantT](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/prashantt/32/6002_2.png) [@prashantT](https://community.auth0.com/u/prashantT)\
**Post date:** [June 1, 2017, 6:14am UTC](https://community.auth0.com/t/pre-registration-hook-not-working-with-api-call/6820/2 "2017-06-01T06:14:08Z")

</div>

Can you clarify where you see that error, e.g. In the Webtask editor logs? If so, a bug was recently fixed where the hook would still run fine, however the error would show up in the editor. You can try copying the Hook code, deleting the Hook from the dashboard, re-creating a new Hook, and paste the code.

---

<div class="post-metadata">

**Author:** ![e.alic](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@e.alic](https://community.auth0.com/u/e.alic)\
**Post date:** [June 3, 2017, 1:40am UTC](https://community.auth0.com/t/pre-registration-hook-not-working-with-api-call/6820/3 "2017-06-03T01:40:39Z")

</div>

This was fixed after the bad mac error was fixed

---

<div class="post-metadata">

**Author:** ![macep23](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@macep23](https://community.auth0.com/u/macep23)\
**Post date:** [September 21, 2017, 3:08pm UTC](https://community.auth0.com/t/pre-registration-hook-not-working-with-api-call/6820/4 "2017-09-21T15:08:10Z")

</div>

@ e.alic I am facing the same issue but I don’t understand form your reply what was the fix. Could you please give a hand? Many thanks

---

<div class="post-metadata">

**Author:** ![macep23](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@macep23](https://community.auth0.com/u/macep23)\
**Post date:** [September 21, 2017, 3:08pm UTC](https://community.auth0.com/t/pre-registration-hook-not-working-with-api-call/6820/5 "2017-09-21T15:08:10Z")

</div>

@ e.alic I am facing the same issue but I don’t understand form your reply what was the fix. Could you please give a hand? Many thanks

---

<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 2, 2018, 5:54am UTC](https://community.auth0.com/t/pre-registration-hook-not-working-with-api-call/6820/6 "2018-03-02T05:54:14Z")

</div>


