Pihole APi to Set up Rules via CLI?

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: