# Ban IPs via API?

**URL:** https://discourse.crowdsec.net/t/ban-ips-via-api/1679
**Category:** crowdsec
**Created:** [February 29, 2024, 4:19pm UTC](https://discourse.crowdsec.net/t/ban-ips-via-api/1679 "2024-02-29T16:19:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ayucel](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@ayucel](https://discourse.crowdsec.net/u/ayucel)
#### Post date: [February 29, 2024, 4:19pm UTC](https://discourse.crowdsec.net/t/ban-ips-via-api/1679/1 "2024-02-29T16:19:28Z")

</div>

Hello there, I’d like to build a mechanism that will allow users to ban specific IPs through internal admin console. I was looking at [Swagger UI](https://crowdsecurity.github.io/api_doc/lapi/#/) docs, but I did not see a method to POST a decision. Are there any other ways that anybody has came up with?

Thank you.

---

<div class="post-metadata">

### Author: ![iiAmLoz](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/iiamloz/32/386_2.png) [@iiAmLoz](https://discourse.crowdsec.net/u/iiAmLoz)
#### Post date: [February 29, 2024, 9:05pm UTC](https://discourse.crowdsec.net/t/ban-ips-via-api/1679/2 "2024-02-29T21:05:22Z")

</div>

You dont add decisions without an alert, so you would create an alert and embed the decision within the alert.

[https://crowdsecurity.github.io/api\_doc/lapi/#/watchers/pushAlerts](https://crowdsecurity.github.io/api_doc/lapi/#/watchers/pushAlerts)

---

<div class="post-metadata">

### Author: ![iiAmLoz](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/iiamloz/32/386_2.png) [@iiAmLoz](https://discourse.crowdsec.net/u/iiAmLoz)
#### Post date: [February 29, 2024, 9:24pm UTC](https://discourse.crowdsec.net/t/ban-ips-via-api/1679/3 "2024-02-29T21:24:21Z")

</div>

Also forgot to mention that you need to authenticate the request to the push alerts endpoint via the watchers login, you can either create a JWT per request or handle the caching of JWT on the server side up to you. the per request is easier

---

<div class="post-metadata">

### Author: ![ayucel](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@ayucel](https://discourse.crowdsec.net/u/ayucel)
#### Post date: [February 29, 2024, 9:25pm UTC](https://discourse.crowdsec.net/t/ban-ips-via-api/1679/4 "2024-02-29T21:25:12Z")

</div>

Hmm, makes sense, then it seems like there’s no need to add an additional scenario to manage that ban category? As the API is able to ban the IP address at the first place, or is recommended to facilitate that scenario in order to have a better setup?

---

<div class="post-metadata">

### Author: ![iiAmLoz](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/iiamloz/32/386_2.png) [@iiAmLoz](https://discourse.crowdsec.net/u/iiAmLoz)
#### Post date: [February 29, 2024, 9:26pm UTC](https://discourse.crowdsec.net/t/ban-ips-via-api/1679/5 "2024-02-29T21:26:40Z")

</div>

You wouldnt need to have a scenario, but if you was banning something others than IP addresses then you would need to add a custom profile as each alert is evaluated agaisnt the profiles. However, if there is an decision already within the alert then the local profiles are not evaluated.
