Proof (Hartogs)

Construct by separation the set $$ \begin{align*} A := \sb{(Z, R)\in \mathcal{P}(X)\times \mathcal{P}(X\times X)}{\text{$R$ is a well-order on $Z$}}. \end{align*} $$

By the representation theorem, every $(Z,R)\in A$ is isomorphic to a unique ordinal. So using replacement, take $$ \begin{align*} C := \sb{α}{\exists (Z,R)\in A: \text{$α$ is an ordinal and $(Z,R)\isom (α,\in)$}}. \end{align*} $$

Any well-order $\mathbf{Y}$ injecting into $X$ is isomorphic to some $(Z,R)\in A$

If $f: Y\hookrightarrow X$ is an injection, then $f: \mathbf{Y} \to (Z,R)$ is an isomorphism where $Z = \op{ran}(f)$ and $R = \sb{(z,z')\in Z\times Z}{f\inv(z) < f\inv(z')}$.

$C$ is the set of all ordinals injecting into $X$

Clearly if $α\in C$, then $(α, \in) \isom (Z,R)$ for some $(Z,R)\in A$ with $Z\subseteq X$ so $α$ injects into $X$.

Conversely if $α$ is an ordinal that injects into $X$, then $(α, \in)$ is isomorphic to some $(Z,R)\in A$ by the above claim, so $α\in C$.

Conclusion

$C$ is then a transitive set, since if $β\in α\in C$, then $β\subseteq α$ is an ordinal that injects into $X$, so $β\in C$.

Hence $C$ is an ordinal. Because $C\not\in C$ (by irreflexivity of $\in$ in $C$), $C$ does not inject into $X$.

Moreover if $γ$ is another ordinal that does not inject into $X$, then $γ\not\in C$ i.e. $γ\not< C$, so $C$ is the smallest ordinal that does not inject into $X$.