Thinly slice the red onions using a sharp knife or mandoline.
In a medium saucepan, combine apple cider vinegar, water, sugar, and salt.
Heat the mixture over medium heat until the sugar and salt dissolve.
Add the peppercorns, red pepper flakes, and garlic if using.
Bring the mixture to a simmer and then remove it from heat.
Place the sliced onions in a clean jar or container.
Pour the warm vinegar mixture over the onions, ensuring they are fully submerged.
Let the mixture cool to room temperature.
Seal the jar and refrigerate for at least 1 hour before serving.
For best results, allow the onions to pickle overnight.