# Webhook - modify response code based on criteria \[GOT CREATED\]

**URL:** <https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721>\
**Category:** Feature Requests (done)\
**Created:** [January 7, 2021, 7:27am UTC](https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721 "2021-01-07T07:27:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![GaRe](https://avatars.discourse-cdn.com/v4/letter/g/c6cbf5/32.png) [@GaRe](https://community.n8n.io/u/GaRe)\
**Post date:** [January 7, 2021, 7:27am UTC](https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721/1 "2021-01-07T07:27:44Z")

</div>

Would be nice to change the response code of a webhook based on some business logic criteria. For example:

- If an entry with some id already exists, webhook should return http 400
- If an entry with some id does not exist, insert the record into the database and return http 200

Thanks

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [January 7, 2021, 7:42am UTC](https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721/2 "2021-01-07T07:42:35Z")

</div>

Hey @GaRe!

Welcome to the community 🙂

You can send a custom response based on your business logic. To do that select ‘Last Node’ from the _ **Response Mode** _ dropdown. This will send the data that is returned by the last node in the workflow. You can use the [Set](https://docs.n8n.io/nodes/n8n-nodes-base.set/) node to set this response.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![GaRe](https://avatars.discourse-cdn.com/v4/letter/g/c6cbf5/32.png) [@GaRe](https://community.n8n.io/u/GaRe)\
**Post date:** [January 7, 2021, 8:19am UTC](https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721/3 "2021-01-07T08:19:13Z")

</div>

Hey,

First of all, thanks for your reply. I know I can modify the response body (JSON). I would also like to change the “Response code” based on some business logic criteria.  
Response code can’t be changed dynamically and node always returns the value defined in the WenHook node settings (for example 200)

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/4/41465efe3521d6639d10b4f45a35603a6fbcb8ea.png)

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [January 7, 2021, 8:40am UTC](https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721/4 "2021-01-07T08:40:24Z")

</div>

Thanks for the further information. Now I have a clear idea of what exactly you mean. Yes, currently this is not possible. I too believe this can be a helpful feature.

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [September 28, 2021, 3:48am UTC](https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721/5 "2021-09-28T03:48:26Z")

</div>

A PR for a very basic version got created:

> <https://github.com/n8n-io/n8n/pull/2254>
>
> Allows sending a webhook response at any point in the workflow, no matter if in …the beginning, middle or end. Additionally also supports setting response code and headers.
> 
> Still has to get tested properly and the node and its options planned correctly.

Can get tested via this docker command:

```bash
docker run -it --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n:PR-2254-webhook-response-node

```

Is still wip, no work went into the node-design and got also not properly tested yet. If anybody wants to give it a try anyway to see if it would allow all use cases and works properly you are very welcome. So is obviously also feedback and bug reports.

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [October 20, 2021, 12:52am UTC](https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721/6 "2021-10-20T00:52:55Z")

</div>

Considering that this feature request has 15 upvotes and I did not hear back, I assumed it got tested, and everything is working perfectly for everybody and they could not be happier.

So I guess we can then merge and release soon.

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [November 5, 2021, 6:41pm UTC](https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721/7 "2021-11-05T18:41:05Z")

</div>

The Respond to Webhook node got released with n8n@0.148.0

---

<div class="post-metadata">

**Author:** ![Florian\_Guillemard](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/florian_guillemard/32/7842_2.png) [@Florian\_Guillemard](https://community.n8n.io/u/Florian_Guillemard)\
**Post date:** [November 5, 2021, 7:30pm UTC](https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721/8 "2021-11-05T19:30:25Z")

</div>

Just update my installation… and tried it! So nice 😉 Thank you so much !

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [November 6, 2021, 4:52pm UTC](https://community.n8n.io/t/webhook-modify-response-code-based-on-criteria-got-created/3721/9 "2021-11-06T16:52:20Z")

</div>

Welcome to the community @Florian_Guillemard !

Glad to hear that it is helpful. Have fun!
