We perform the calibration of the X-ray luminosity--mass scaling relation on a sample of 344 CODEX clusters with z<0.66 using the dynamics of their member galaxies. Spectroscopic follow-up measurements have been obtained from the SPIDERS survey, leading to a sample of 6,658 red member galaxies. We use the Jeans equation to calculate halo masses, assuming an NFW mass profile and analyzing a broad range of anisotropy profiles. With a scaling relation of the form LX∝AXM200cBXE(z)2(1+z)γX, we find best fit parameters AX=5.7−0.5+0.4(±0.6)×1043ergs−1, BX=2.5±0.2(±0.07), γX=−2.6−1.2+1.1(±0.74), where we include systematic uncertainties in parentheses and for a pivot mass and redshift of 3×1014M⊙ and 0.16, respectively. We compare our constraints with previous results, and we combine our sample with the SPT SZE--selected cluster subsample observed with \XMM\, extending the validity of our results to a wider range of redshifts and cluster masses.