Lightly crush the juniper berries, allspice berries, mustard seeds and cloves in a mortar and pestle to release their flavour.
Heat the oil in a heavy pan, then add the onion, leek and garlic and cook until softened and fragrant.
Add the chopped tomatoes, vinegar, sugar, salt, the crushed spices, bay leaf, cinnamon stick and thyme. Bring to a gentle boil, then reduce to a slow simmer.
Simmer uncovered for 45–60 minutes, stirring occasionally, until the tomatoes break down and the mixture thickens.
Remove the bay leaf, cinnamon stick and thyme. Blend the sauce until smooth with a stick blender or jug blender.
Pass the ketchup through a fine sieve, pressing it through with the back of a ladle or spoon to remove skins and seeds.
Return the strained ketchup to the pan and simmer for 20–30 minutes until glossy and thick. Taste and adjust with more vinegar, sugar or salt as needed.
Pour the hot ketchup into sterilised jars or bottles, seal, and allow to cool. Store in the fridge and use within 3–4 weeks.