Sex

Sex is one's assigned gender at birth (AGAB), and can be male or female; though gender is different and is a spectrum with many positions or 'identities', such as agender, androgyne, demigirl, and much more.

Gender Identity
Gender is a social construct, and can differ from ones biological sex (transgender), and has values typically associated with it such as masculinity, femininity, androgyny, but some people don't express themselves with the attributes generally applied to their gender; for example a trans woman expressing themselves in a masculine manner is a tomboy, and they are valid.

Resources

 * 1) https://apastyle.apa.org/style-grammar-guidelines/bias-free-language/gender