Anyone who performs labor or supplies materials for the improvement of real property has the right to a mechanics lien. That includes contractors, subtrades, laborers, materials and equipment suppliers, landscapers and nurseries.
If you're not the general contractor, then you need to file your lien before the owner pays the general contractor because New York law provides that your mechanics lien will only attach to any outstanding amount that the owner still owes the general contractor on the date you file your lien. You must serve it on all the relevant parties within 5 days before filing it, or 30 days after filing a notice of lien.