moved api functions to separate file
api file
auths at beginning, sends mails