###### Abstract  
Bioinscticides are regarded as important alternatives for controlling agricultural pests. However, few studies have determined the persistence of these compounds in stored grains. This study aimed at optimizing and validating a fast and effective method for extraction and quantification of residues of safrole (the main component of _Piper bispliinerorum_ essential oil) in cowpea beans. It also sought to assess the persistence of this substance in the grains treated by contact and fumigation. The proposed method used headspace solid-phase microextraction (HS-SPME) and gas chromatography with a flame ionization detector (GC/FID). Factors such as temperature, extraction time and type of fiber were assessed to maximize the performance of the extraction technique. The performance of the method was appraised via the parameters selectivity, linearity, limit of detection (LOD), limit of quantification (LOQ), precision, and accuracy. The LOD and LOQ of safrole were 0.0057 and 0.019 \(\mu\)g kg\({}^{-1}\), respectively and the determination coefficient (R\({}^{2}\)) was >0.99. The relative recovery ranged from 99.26 to 104.85, with a coefficient of variation <15%. The validated method was applied to assess the persistence of safrole residue in grains, where concentrations ranged yield and the production quality, leading to significant deficits to farmers [4]. Therefore, the primary prevention and control tactic against these attacks has been the use of synthetic insecticides (pyrethroids and organophosphates) and fumigants (such as phosphine, PH\({}_{3}\)) [5; 6; 7]. Nonetheless, the continuous and indiscriminate use of these products for treating grains has been questioned worldwide, as they are also lethal to non-target organisms [8], lead to resistance development in insect-pest populations [5; 9], and potentially pollute the environment [10]. Additionally, they pose concerns about their residual levels in food and the risks to human health [11]. Botanical insecticides stand out among options for insect control for being considered safer and non-associated with the development of pest resistance, consequently presenting a lower contamination risk to the environment and human and animal health [12; 13]. Among them are the essential oils (EOs), volatile compounds with an intense odor and, in most cases, a lipophilic constitution, derived from the secondary metabolism of plants [14]. Due to their insecticidal activity, EOs and their chemical constituents are promising alternatives for controlling insect pests in stored grains [15]. The biocidal activity of EOs has been reported against different types of pests and pathogens, such as insects [6; 16], mites [17], fungi [18], viruses [19], bacteria [20], nematodes [21], and amoebas [22]. The composition of EOs depends on factors like plant species [23], environmental conditions during cultivation [24], extraction method [16; 25] among others. Among other species with potential for pest control, the long pepper (_Piper higidinervum_ C. DC.) is an aromatic plant endemic to the Amazon and has excellent potential for essential oil extraction [26]. Its EO is rich in safrole, which represents about 77.7 to 94.7% of the composition [6; 21; 22; 25; 27]. Besides long pepper, safrole is found in EOs from other species of the families Piperaceae [28; 29; 30], Lauraceae [31], and Myristicaceae [32]. Several studies have evinced the bioinsecticide activity of EOs containing safrole against pest insects of stored grains [6; 25; 27]. Safrole (4-allyl-1,3-benzodioxole) is a phenylpropanol used in the synthesis of heliotropin, a fragrance fixative for the cosmetic industry [33], and piperonyl butoxide (PBO), an insecticide synergist employed by the pesticide industry [34]. It is also used as a natural or synthetic flavoring in the food and alcoholic beverage industries [35]. However, studies have revealed the carcinogenic potential of safrole [36; 37].