In reality, not a lot. I've had 11 years of twattery from the ex, here's what I've done
Never forget contact isn't for him, it's for the kids.
It's also not for you, but them. Of course in an ideal world, your ex would grasp that it's still his job to help and support his children's mother, but there's no changing stupid.
Keep every text and email polite, respectful, and measured. Nothing pisses off angry vengeful dickheads like failure to spread their rage to others. By all means write that excoriating response and save it for posterity, I have some absolute zingers hidden away on my PC, but don't send them, they only fuel the fire.
Don't lie to your children but don't slag him off either, and don't tell them things they don't need to know. I am proud of the fact that at 12 years old, ny son still loves his dad, but is growing in the knowledge that whilst his dad is great for hugs and endless computer time, I am the rock he is built on. It has cost many tears of rage and frustration, but ultimately I have grown stronger, I have a happy, loving and confident child, and I know my tit of an ex knows that in his stupid binary zero sum game world, I have utterly whipped his sorry arse.
I'm sorry I couldn't change him into a sane cooperatve dad, but you can't change other people.