How to return custom response status

Hi there, this is my first week of learning n8n and honestly is far better than other solutions I am using.

Right now, I setup an if condition if true continue the workflow.

My goal is to setup; if the if condition is false return a 401 response status with a text, like, please enter the name of the user.

How I can return 401 with a text in n8n ?

Thanks in advance

You can respond with a custom text, using the webhook response mode last node.

About changing the HTTP status code dynamically, that is sadly not possible. What you can do is always respond with a JSON that has two properties, code, and message. Then, the client would ignore the HTTP response status code and only use the code in the response body to determine what to do.

A community member created a future request for this feature. Make sure you go there and upvote it.

1 Like

Thank you so much for the quick reply and help. I will surely upvote it.

Thanks again