The Recommended Daily Allowance (RDA) of magnesium for females and males is 310-to-320 and 400-to-420 mg, respectively, though you shouldn’t get[1] more than 350 mg per day from magnesium supplements. Taking more than this may produce[2] gastrointestinal upset but probably isn’t dangerous, provided you consume less than 5,000 mg per day.
1 https://ods.od.nih.gov/factsheets/Magnesium-HealthProfessional/
2 https://nap.nationalacademies.org/read/5776/chapter/8#202