Quick answer
Can I fast if I am spotting?
If the spotting is ḥayḍ, fasting is not permitted and the day is made up later. If the spotting is istiḥāḍah or light discharge that is not ḥayḍ, the fast is valid and continues normally.
The answer depends on whether the spotting is ḥayḍ. If the spotting is part of your menstrual bleeding, fasting is not permitted, and the day must be made up (qaḍāʾ) after Ramadan. This is the consensus of the four madhhabs.
If the spotting is istiḥāḍah — irregular bleeding that is not ḥayḍ — your fast is valid and you continue fasting normally. Istiḥāḍah does not break the fast. The same applies to light brown or yellow discharge that appears after the signs of purity, which is not counted as ḥayḍ.
If clear menstrual flow begins during a fasting day — even moments before maghrib — that day's fast is invalidated and is made up later. Conversely, if your period ends and you become pure during the day, you do not start fasting mid-day; you fast the next day and make up the missed day.
When you are genuinely unsure whether brief spotting is the start of ḥayḍ, the cautious practice is to continue the fast until clear flow establishes the cycle, then make up the day if it turns out to have been ḥayḍ.
This summary draws on the established positions of the four Sunni madhhabs. For your specific situation, consult a qualified scholar.
Go deeper
Making up missed fasts in Ramadan