# Customising status code returned from hooks

**URL:** <https://community.auth0.com/t/customising-status-code-returned-from-hooks/8132>\
**Category:** Get Help\
**Tags:** client-credentials-f, hooks\
**Created:** [September 8, 2017, 9:12am UTC](https://community.auth0.com/t/customising-status-code-returned-from-hooks/8132 "2017-09-08T09:12:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sshek](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sshek/32/7239_2.png) [@sshek](https://community.auth0.com/u/sshek)\
**Post date:** [September 8, 2017, 9:12am UTC](https://community.auth0.com/t/customising-status-code-returned-from-hooks/8132/1 "2017-09-08T09:12:03Z")

</div>

We’re using client credentials hooks and want to reject authorisation on certain conditions. It appears that we can do this in the hook by simply passing back a string as the first argument to the callback, which appears as the error description when consumers call `/oauth/token` endpoint. However, this returns a status code of 500. In our case a 403 is probably a better choice.

Is there a way to control the returned status code?

It seems passing back an error like `new UnauthorizedError('some error')` like some of the rule examples still returns a 500 status code but a worse error description of `Script generated an unhandled asynchronous exception.`

Also some more examples or documentation around hooks would be awesome.

---

<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:** [September 11, 2017, 11:00am UTC](https://community.auth0.com/t/customising-status-code-returned-from-hooks/8132/2 "2017-09-11T11:00:03Z")

</div>

This is not currently supported in Hooks, however it’s worth noting that Hooks is still a beta feature. In order to categorize your request more efficiently, can you please post your request in the Ideas section of the community:  
[http://community.auth0.com/content/idea/list](http://community.auth0.com/content/idea/list)

As we develop Hooks further towards being, we will also be adding new samples and documentation for you to refer to.

---

<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:56am UTC](https://community.auth0.com/t/customising-status-code-returned-from-hooks/8132/3 "2018-03-02T05:56:24Z")

</div>


