# Pihole APi to Set up Rules via CLI?

**URL:** <https://discourse.pi-hole.net/t/pihole-api-to-set-up-rules-via-cli/72679>\
**Category:** Help\
**Created:** [September 29, 2024, 7:01pm UTC](https://discourse.pi-hole.net/t/pihole-api-to-set-up-rules-via-cli/72679 "2024-09-29T19:01:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vorname\_Nachname](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/vorname_nachname/32/29033_2.png) [@Vorname\_Nachname](https://discourse.pi-hole.net/u/Vorname_Nachname)\
**Post date:** [September 29, 2024, 7:01pm UTC](https://discourse.pi-hole.net/t/pihole-api-to-set-up-rules-via-cli/72679/1 "2024-09-29T19:01:53Z")

</div>

Hey There, is it possible to set up some settings about CLI ?

Goal:  
Im using a "block all" regex and i want set up this rule to some clients between 21:00 and 06:00.  
Is that Possible ?

---

<div class="post-metadata">

**Author:** ![rdwebdesign](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/rdwebdesign/32/51363_2.png) [@rdwebdesign](https://discourse.pi-hole.net/u/rdwebdesign)\
**Post date:** [September 29, 2024, 7:17pm UTC](https://discourse.pi-hole.net/t/pihole-api-to-set-up-rules-via-cli/72679/2 "2024-09-29T19:17:20Z")

</div>

You can create a Pi-hole Group, add the desired devices to this group and also add the regex.

Then you can enable or disable the group to block/allow the devices.

You can use a cron job to enable/disable the group, using SQL. You also need to run `pihole restartdns reload-lists` after the SQL command.

Something like this:

> [@Activate group with cron](https://discourse.pi-hole.net/t/activate-group-with-cron/32660):
>
> Hello, I'm looking for a way to activate a group from 9 a.m. to 6 p.m. and have it deactivated from 6:01 p.m. to 8:59 a.m. with school at home I want to block social media during school hours. Thank you in advance for your help.

---

<div class="post-metadata">

**Author:** ![system](https://discourse.pi-hole.net/uploads/default/original/3X/7/c/7c8792f649eeb921c5d2b4c41564ffa873d9a2b8.png) [@system](https://discourse.pi-hole.net/u/system)\
**Post date:** [October 20, 2024, 7:17pm UTC](https://discourse.pi-hole.net/t/pihole-api-to-set-up-rules-via-cli/72679/3 "2024-10-20T19:17:31Z")

</div>

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
