N.Y. Penal Law § 260.15
In any prosecution for endangering the welfare of a child, pursuant to section 260.10 of this article, based upon an alleged failure or refusal to provide proper medical care or treatment to an ill child, it is an affirmative defense that the defendant (a) is a parent, guardian or other person legally charged with the care or custody of such child; and