Background Selective serotonin reuptake inhibitors (SSRIs) are a first-line pharmacological therapy in major depressive disorder (MDD), but treatment response rates are low. Clinical trials lack the power to study the genetic contribution to SSRI response. Real-world evidence from electronic health records provides larger sample sizes, but novel response definitions are needed to accurately define SSRI non-responders. Methods In UK Biobank (UKB) and Generation Scotland, SSRI switching was defined using a ≤ 90-day gap between prescriptions for an SSRI and another antidepressant in primary care. Non-switchers were participants with ≥ 3 consecutive prescriptions for an SSRI. In UKB, clinical, demographic and polygenic score (PGS) associations with switching were determined, and the common-variant heritability was estimated. Results In UKB, 5,133 (13.2 %) SSRI switchers and 33,680 non-switchers were defined. The mean time to switch was 28 days. Switching patterns were consistent across UKB and Generation Scotland (n = 498 switchers). Higher annual income and educational levels (OR [95% CI] for university degree compared to no qualifications: 0.727 [0.666-0.794]) were associated with lower levels of switching. PGS for non-remission, based on clinical studies, were associated with increased risk of switching (OR: 1.07 [1.02-1.12], p = 0.007). MDD PGS and family history of depression were not significantly associated with switching. The heritability (h2) of SSRI switching was approximately 4% on the observed scale. Conclusion This study identified SSRI switching as a proxy of drug non-response, scalable across biobanks, capturing demographic and genetics of treatment non-response, and independent of the genetics of MDD.