In this research, a new heterostructure nanocomposite photocatalyst as a Nano-sensor has been synthesized by using graphitic carbon nitride coupled with Fe3O4 and CoWO4. It characteristics were identified with various spectroscopic and microscopic techniques including SEM, TEM, XRD, EDX and FTIR. The interaction of Azathioprine as a hazardous active pharmaceutical ingredient with the mentioned nanocomposite leads to quenching of its fluorescence emission intensity. The gradual addition of Azathioprine concentration causes a regular change in the quenching intensity of the fluorescence emission of the nanocomposite, which has the ability to be used as a fluorescence nanosensor for Azathioprine determination. Optimization of fluorescence emission intensity has been performed by a multivariate approach. So, the Box–Behnken design was applied to optimize the conditions of Azathioprine assay. Under optimal conditions: pH = 7.0 (A), dopant percentage of 30% (B) and buffer solution with concentration of 0.23 M (C), the limit of detection was 0.317 nmol L 1 and the limit of qualification was 1.056 nmol L 1. The quenching chanism of fluorescence emission intensity due to interaction of g-C3N4@Fe3O4@CoWO4 heterostructure nanocomposite with Azathioprine has also been evaluated and discussed