you have 180 days to apply after you get your final marksheet. To apply your study permit must have been valid during those 180 days of your application. If you are in canada and let your student permit expire then you have to apply to restore your status as a student and then apply for a PGWP.
To be eligible to the Post-Graduation Work Permit (PGWP), you need to:
be at least 18 years old,
have been a full-time student on a continuous basis,
have finished an 8-month or longer program of study,
be in possession of an official school document confirming you finished your study program,
present your application maximum 180 days after you officially finished your program, and
have graduated from a PGWP-eligible school program.
A student should have studied full-time each academic session excluding scheduled breaks with two exceptions: you studied part-time in your final academic session only. You took an authorized gap in studies for less than 150 days.