Field over which CM endomorphism is defined 
Let $E$ be an elliptic curve with coefficients over some number field
$K$. Is it true that if $E$ has complex  multiplication by
$\mathbb{Q}[\sqrt{-D}]$, then any endomorphism $\phi: E \rightarrow E$
equals a rational function with coefficients in $K[\sqrt{-D}]$?

This has been true of the handful of examples I've seen of curves with complex multiplication. For instance $y^2 = x^3-x$ has complex multiplication by $\mathbb{Z}[i]$, and the endomorphism corresponding to $i$ is $(x,y) \mapsto (-x, iy)$, which happens to have coefficients on $\mathbb{Q}[i]$. But it is not clear to me if it had to be so - if we could have some endomorphism with $\phi^2 = -1$ with coefficients over some field other than $\mathbb{Q}[i]$. Or even if we need $i$ and couldn't define it just over $\mathbb{Q}$.
This seems like a basic question but I have not found anything about this on the texts I am reading and I don't know what to search so settle this. Thanks in advance for any helpful sources!
 A: Yes. Let $E/K:y^2=x^3+ax+b$ such that $End(E)$ is isomorphic to an order $O$ in $\Bbb{Q}(\sqrt{-D})$.

*

*For any $\alpha\in O$ let $\phi\in End(E)$  be the "multiplication by $\alpha$" endomorphism.

$\phi$ is given by two rational functions in $x,y$, with coefficients in a finite extension of $K$.

*

*$\phi$ sends $\frac{dx}y$ to $\alpha\frac{dx}y$.
For any $\sigma\in Gal(\overline{K}/K)$ you can apply it to the coefficients of each $\phi\in End(E)$ to get $\phi^\sigma$ which is still an endomorphism.
Morover $\phi \to \phi^\sigma$ is an automorphism of the ring $End(E)$.
$\phi^\sigma$ sends $\frac{dx}y$ to $\sigma(\alpha)\frac{dx}y$, so $\phi^\sigma$ is the multiplication by $\sigma(\alpha)$ endomorphism,
where $\sigma(\alpha)$ is either $\alpha$ or its complex conjugate.

The $Gal(\overline{K}/K)$-action on $\phi$ is given by the $Gal(\overline{K}/K)$-action on $\alpha$.

If the $Gal(\overline{K}/K)$-orbit of $\alpha$ is trivial then the $Gal(\overline{K}/K)$ orbit of $\phi$ is trivial, so $\phi$ is defined over $K$.
If the $Gal(\overline{K}/K)$-orbit of $\alpha$ is non-trivial then
$\phi$ is defined over $K(\alpha)=K(\sqrt{-D})$.
