How Anki implements automatic addition of red flags when answering multiple-choice questions incorrectly

Can the Anki desktop app expose the flagging API? I’d like to implement the feature of automatically adding red flags for incorrect multiple-choice answers.