In a small bowl, combine the chopped onions, tomatoes, red chilies, grated coconut, cumin seeds, ginger, garlic, and curry leaves.
Add the red chili powder if using, and season with salt to taste. Mix well. Add a little water if the mixture is too dry to achieve a spreadable consistency.
Heat a non-stick dosa pan or skillet over medium heat and lightly brush it with oil.
Pour a ladleful of dosa batter onto the hot pan and spread it evenly in a circular motion to form a thin dosa. Drizzle a bit of oil around the edges.
Once the dosa begins to cook, spread a portion of the tomato and onion mixture evenly over the dosa.
Cook until the edges begin to lift from the pan and the bottom of the dosa is golden brown.
Fold the dosa in half or roll it up, and remove from the pan.
Serve hot with your favorite chutney or sauce. Repeat with the remaining batter and filling mixture.