# Help understanding error codes in pre-user-registration and post-login actions

**URL:** <https://community.auth0.com/t/help-understanding-error-codes-in-pre-user-registration-and-post-login-actions/89653>\
**Category:** Get Help\
**Tags:** pre-user-registratio, error, auth0\
**Created:** [August 30, 2022, 5:16am UTC](https://community.auth0.com/t/help-understanding-error-codes-in-pre-user-registration-and-post-login-actions/89653 "2022-08-30T05:16:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris.middleton](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.middleton/32/33549_2.png) [@chris.middleton](https://community.auth0.com/u/chris.middleton)\
**Post date:** [August 30, 2022, 5:16am UTC](https://community.auth0.com/t/help-understanding-error-codes-in-pre-user-registration-and-post-login-actions/89653/1 "2022-08-30T05:16:05Z")

</div>

Hi, we’re using both `pre-user-registration` and `post-login` actions, and seems that error codes and descriptions are not consistent, so we’re trying to find ways to align them.

Sample code of the `pre-user-registration` action:

```auto
exports.onExecutePreUserRegistration = async (event, api) => {
  // ...
  if (someCondition) {
    api.access.deny("USER_ACCOUNT_NOT_ACTIVE");
  }
  // ...
};

```

When triggering this case, via curl, we get a `400` HTTP error, and body:

```auto
{"error":"extensibility_error","error_description":"USER_ACCOUNT_NOT_ACTIVE"}

```

We have a similar code in the `post-login` flow:

```auto
exports.onExecutePostLogin = async (event, api) => {
  // ...
  if (someCondition) {
    api.access.deny("USER_ACCOUNT_NOT_ACTIVE");
  }
  // ...
};

```

But when triggering this case, via curl, we get a `500` HTTP error code and body:

```auto
{"error":"access_denied","error_description":"USER_ACCOUNT_NOT_ACTIVE"} 

```

Got a couple of questions:

1. Can we customize the `error` field (`error_description` matches our code, correctly)? Or it’s always hard-coded to be “extensibility\_error” in pre-user-registration and “access-denied” in post-login?
2. Can we specify the HTTP response code, so in post-login it returns a 40x instead of a 500? Or at least, can we make them match between pre-user-registration and post-login?

We tried passing a second argument to `api.access.deny` (as described in [API object](https://auth0.com/docs/customize/actions/flows-and-triggers/pre-user-registration-flow/api-object)) in the pre-user-registration flow, but we don’t see the extra string show up in the response.

Any thoughts?

Thanks!!  
-Chris

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [August 31, 2022, 6:18pm UTC](https://community.auth0.com/t/help-understanding-error-codes-in-pre-user-registration-and-post-login-actions/89653/3 "2022-08-31T18:18:57Z")

</div>

Hi @chris.middleton,

Welcome to the Auth0 Community!

I understand that you have some questions about customizing the error messages when using Actions.

> [@chris.middleton](#):
>
> 1. Can we customize the `error` field (`error_description` matches our code, correctly)? Or it’s always hard-coded to be “extensibility\_error” in pre-user-registration and “access-denied” in post-login?
> 
> 2. Can we specify the HTTP response code, so in post-login it returns a 40x instead of a 500? Or at least, can we make them match between pre-user-registration and post-login?

Unfortunately, it is not possible to customize the error field. This is fixed and cannot be changed.

Moreover, the HTTP response code cannot be changed either.

> [@chris.middleton](#):
>
> We tried passing a second argument to `api.access.deny` (as described in [API object](https://auth0.com/docs/customize/actions/flows-and-triggers/pre-user-registration-flow/api-object)) in the pre-user-registration flow, but we don’t see the extra string show up in the response.

After my tests, I was able to display both the `reason` and `userMessage` in the response successfully. See below for clarity.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/8/4/84b9d077cbb6e26d11a6f24c6a3bbd7f572fbff5.png)

 ![image](https://global.discourse-cdn.com/auth0/original/3X/7/0/70daea14b95dda6928c88545baf6e64423ae0151.png)

With that, you should be able to pass the `userMessage` parameter as the second argument.

Please let me know how this goes for you.

Thank you.

---

<div class="post-metadata">

**Author:** ![chris.middleton](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.middleton/32/33549_2.png) [@chris.middleton](https://community.auth0.com/u/chris.middleton)\
**Post date:** [August 31, 2022, 10:06pm UTC](https://community.auth0.com/t/help-understanding-error-codes-in-pre-user-registration-and-post-login-actions/89653/4 "2022-08-31T22:06:28Z")

</div>

Thanks for your help!

Thanks for confirming that we cannot edit the `error` field or the HTTP response code. Is that something that’s in the roadmap? Getting an HTTP 500 for auth or bad request is not ideal.

Also, can you give me context on how you got all those fields in the response? When calling the API via curl, I only get “error\_description” and “error”. Is there an extra param or header that will return more info?

Thanks again!

-Chris

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 1, 2022, 10:15pm UTC](https://community.auth0.com/t/help-understanding-error-codes-in-pre-user-registration-and-post-login-actions/89653/5 "2022-09-01T22:15:10Z")

</div>

Hi @chris.middleton,

Thank you for your reply.

Unfortunately, modifying the HTTP response code is not in our roadmap.

If you believe that this is a feature you and many others would benefit from, please submit a [feedback request](https://community.auth0.com/c/feedback/95) asking for support for modifying the response code in Actions.

> [@chris.middleton](#):
>
> Also, can you give me context on how you got all those fields in the response? When calling the API via curl, I only get “error\_description” and “error”. Is there an extra param or header that will return more info?

And for clarification, I was using Postman to register a user using the Authentication API. The response was the one shown in the screenshot.

Please let me know if there’s anything else I can do to help.

Thank you.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 22, 2022, 10:57am UTC](https://community.auth0.com/t/help-understanding-error-codes-in-pre-user-registration-and-post-login-actions/89653/6 "2022-12-22T10:57:16Z")

</div>


