In a category $\mathcal C$, let $f: X \rightarrow Y$ and $g: Y \rightarrow X$ such that $g \circ f = id_X$. Is there a general criterion on $\mathcal C$ such that the following holds: there is an object $Z$ such that $Y = X \sqcup Z$ (the coproduct of $X$ and $Z$)?

Thanks for any answer.

(retitled the question as per the comment below)