If you feel that the children are in any danger what so ever you need to seek help from an attorney to modify the agreement that you entered in to on line and to seek custody of the children "in their best interests."  That is the key to how the courts will evaluate the situation and the key to their placement of the children for custody determinations.  They look at many factors and endangering the children by being on drugs, etc., is definitely a factor that they will look at.  Threatening you is just your ex wife's way of dealing with YOU, not the kids.  She is obviously angry and trying to manipulate you using the kids.  Seek legal help here please.  And bring the documents with you. Good luck.