Let $F$ be a totally real number field, and let $K$ be a quadratic extension of $F$ which cannot be embedded into $\mathbb{R}$. Then $K$ is a so called CM field. For instance, take $F = \mathbb{Q}(\sqrt2)$, and $K = \mathbb{Q}(\zeta_8) = F(i)$ where $\zeta_8$ is a primitive complex $8$-th root of unity. Denote by $\mathcal{O}_K$ the ring of integers of $K$. My question is:
How to construct a number field $L$ and an abelian variety $A/L$ such that $\mathrm{End}(A) \cong \mathcal{O}_K ?$
For an example with elliptic curves, take $F = \mathbb{Q}$, and $K = \mathbb{Q}(\sqrt{-14})$ so that $\mathcal{O}_K = \mathbb{Z}[\sqrt{-14}]$. Evidently, $\mathcal{O}_K$ is a lattice in $\mathbb{C}$ so $E_0 = \mathbb{C}/\mathcal{O}_K$ is an elliptic curve with $\mathcal{O}_K \subseteq \mathrm{End}(E_0)$. Since $\mathrm{End}(E_0)$ is an order in an imaginary quadratic number field, we have $\mathrm{End}(E_0) \cong \mathcal{O}_K$ as $\mathcal{O}_K$ is the maximal order. Furthermore, $j(E_0)$ is an algebraic number (in fact, an algebraic integer) which generates a field isomorphic to $L = \mathbb{Q}(\sqrt{2\sqrt{2}-1})$ over $\mathbb{Q}$. It follows that we can define an elliptic curve $E_1/L$ such that $j(E_1) = j(E_0)$ so that $E_1 \cong_{\mathbb{C}} E_0$ and in particular $\mathrm{End}(E_1) \cong \mathrm{End}(E_0) \cong \mathcal{O}_K$ as required.
Can I tell a similar story (with abelian vaieties instead of elliptic curves) for any CM field?
It is only clear to me that the answer is positive for imaginary quadratic number fields.