Place the Serrano ham on a baking sheet and put it in the oven at 175 degrees Celsius (347 degrees Fahrenheit) for about 10 minutes until crispy.
Put the puff pastry in a greased tart pan and bake it for 10 minutes at 175 degrees Celsius (347 degrees Fahrenheit).
Chop the onions into coarse wedges, finely chop the garlic, and put them in a pot with butter over medium-high heat until they are clear.
Add thyme along with sugar and vinegar, then fry until it turns golden brown. Season to taste with salt and pepper.
Whip together eggs and cream with salt and pepper, add the onions to the tart pan, then pour the egg/cream mixture on top.
Finally, place slices of tomatoes and mozzarella on top.
Bake in the oven for 20-25 minutes at 200 degrees Celsius (392 degrees Fahrenheit) until golden brown and set.
Place fresh basil and pieces of crispy ham on top before serving.