Herald rule disable/enable

Can we disable/enable a herald rule from a script. Is there and API for that? I need it mostly to lock/unlock a branch

There’s no API for that.

Common ways of allowing occasional pushes to a branch are with either whitelist some trusted users, or by having some comment in the commit message that the rule will check against.

You can also build a custom rule - like PhabricatorLunarPhasePolicyRule.php · phabricator - to allow you to set more customized conditions.