Cook the onion gently with the olive oil and thyme in a saucepan for 5 minutes.
Blanch the courgettes for 5 minutes in a large saucepan of boiling water. Drain, then cut them in two from top to bottom and scoop out the flesh with a small spoon.
Mash the courgette flesh with a fork while mixing it with the onion, ham, garlic, rice, Parmesan, basil leaves and eggs. Season to taste.
Fill the courgette halves with the stuffing. Place them in a gratin dish and cook in a preheated oven, 180°C (350°F), Gas Mark 4, for 25 minutes.