All visa-exempt foreign nationals travelling to or transiting through Canada by air must apply for an eTA through the electronic system before entering Canada. This requirement does not apply to foreign nationals travelling to or transiting through Canada by land, sea or rail.
An eTA is valid for 5 years or until the applicant’s passport expires, whichever occurs sooner. After which, you will need to apply for a new one before travelling to or transiting through Canada by air.
U.S. lawful permanent residents require an eTA when flying to or transiting through a Canadian airport. They must present their passport at the time of travel, along with proof of their valid lawful permanent resident status in the U.S. (such as a valid green card or a valid I-551 [ADIT] stamp in their passport) in order to board their flight.
Applying for an eTA is a simple online process. Most applicants get their eTA approval (via an email) within minutes. However, some requests can take several days to process if you're asked to submit supporting documents. It is best to get an eTA before you book your flight to Canada.