Greywater use is legal under most plumbing codes these days. Landscape irrigation is by far the most common use for greywater, and it is the only use that both the UPC and the IPC agree on.
Wherever greywater is used to irrigate the grounds of homes or commercial buildings, it is almost invariably because of the demands already imposed on fresh water by a growing society. This is mainly a western state phenomenon, and the majority of those states adopt the UPC as their model code. Therefore, most of this article will refer to the UPC's greywater code, titled Appendix G, and a subsequent improvement, the California Plumbing Code's (CPC) greywater amendment, also titled Appendix G. The IPC and most state codes include provisions for special systems, so if you are in one of those jurisdictions, please keep that in mind as you read.