Disclosed are a benzazepine derivative, a preparation method, a pharmaceutical composition and the use thereof. A compound as shown in formula (I) of the present invention, and an isomer, a prodrug, a stable isotope derivative or a pharmaceutically acceptable salt thereof have the following structure. The benzazepine derivative of the present invention has a good regulation effect on the TLR family and the related signalling pathway, and in particular, has a good regulation effect on TLR8, can effectively treat, relieve and/or prevent various diseases mediated by TLR family and the TLR-related signalling pathway, and in particular, can effectively treat, relieve and/or prevent various diseases mediated by TLR8, such as cancers, autoimmune diseases, infections, inflammations, transplantation rejections, graft-versus-host diseases, etc.