Optimizing a multi-residue analysis when using an automatic SPE (solid phase extraction) system and complex matrices becomes a difficult problem because of the large number of experimental factors that can influence the recovery of the analytes. Furthermore, in most cases, the conditions of the factors that enhance the response of one analyte are in conflict with those suitable for some others.In this work, AQbD (Analytical Quality by Design) is applied to the development of an analytical procedure based on automatic SPE coupled to HPLC-FLD in the determination of nine polycyclic aromatic hydrocarbons (PAHs) in coffee samples.Focussing on the SPE, the elution volume, the dry time, and volume in the wash stage, and the organic solvent (at two, three, three, and four levels, respectively) were considered.The first problem is to handle these four factors (control method parameters, CMPs) at different levels to optimize responses (critical quality attributes, CQAs). This task has been carried out using a D-optimal design that, starting from a full factorial design of four factors with 72 experiments, reduced this number to 19, maintaining the precision of the estimates, saving time and costs in the laboratory.The second problem is related to the choice of CQAs to apply the AQbD methodology. A complex matrix such as coffee contains impurities that interferes with the target analytes and may even coelute in the chromatographic determination. A PARAFAC decomposition allows avoiding this problem and uses the “second order advantage” to unequivocally identify each analyte. Then, the obtained sample loadings were used as responses. Specifically, each CQA is the difference between spiked and blank coffee samples. All these CQAs must be maximized.Once the experimental data were obtained, two alternatives were posed: on the one hand, the classical optimization based on the estimation of the effects of CMPs on the CQAs, and on the other hand, applying the AQbD methodology to construct the design space that allows to increase the knowledge of the automatic SPE system.Because the experimental domain of CMPs is discrete and the SPE system performs differently for each analyte, it is not possible to obtain the maximum of all CQAs at the same factor levels. Therefore, the design space of the CMPs is obtaining through the Pareto front of the non-dominated values of CQAs.The nine PAHs selected were phenanthrene (PHE), anthracene (ANT), fluoranthene (FLN), pyrene (PYR), chrysene (CHR), benzo[a]anthracene (BaA), perylene (PER), benzo[b]fluoranthene (BbF) and benzo[a]pyrene (BaP). European regulations amending foodstuff set maximum levels for BaP and the sum of the content of four compounds (PAH4): BaP, BaA, BbF and CHR.