Well, let's do the calculation. I guess from the context you mean magnetostatic fields. So let ##\vec{j}## be the current density, fulfilling the static continuity equation ##\vec{\nabla} \cdot \vec{j}=0##. Then the Maxwell equations for the magnetic field simplify to Ampere's and Gauss's Laws (in Heaviside-Lorentz units)
$$\vec \nabla \times \vec{B}=\frac{1}{c} \vec{j}, \quad \vec{\nabla} \cdot \vec{B}=0.$$
The latter equation means that you can introduce a vector potential
$$\vec{B}=\vec{\nabla} \times \vec{A},$$
which is (for given ##\vec{B}##) determined only up to a gradient field (gauge invariance), and you can impose a simplifying constraint by fixing the gauge. In magnetostatics Coulomb gauge is most convenient, i.e.,
$$\vec{\nabla} \cdot \vec{A}=0.$$
Then using Cartesian coordinates you have
$$\vec{\nabla} \times \vec{B}=\vec{\nabla} \times (\vec{\nabla} \times \vec{A})=\vec{\nabla} (\vec{\nabla} \cdot \vec{A})-\Delta \vec{A}=-\Delta \vec{A}=\frac{1}{c} \vec{j}.$$
Now from electrostatics you know the Green's function of the Laplace operator, which now can be applied to each Cartesian component separately, so that you get
$$\vec{A}(\vec{x})=\int_{\mathbb{R}^3} \mathrm{d}^3 \vec{x}' \frac{\vec{j}(\vec{x}')}{4 \pi c |\vec{x}-\vec{x}'|}.$$
Now suppose that the entire current distribution is within a sphere of radius ##R## around the origin, and you look at the potential for locations far away, i.e., for ##|\vec{x}|=r \gg R##. Then you can Taylor-expand the Green's function around ##\vec{x}'=0##. Here we take only the first two terms
$$\frac{1}{|\vec{x}-\vec{x}'|}=\frac{1}{r} +\frac{\vec{x}' \cdot \vec{x}}{r^3}+\ldots.$$
What you then get is a potential in powers of ##1/r##. The first terms gives the monopole contribution to the vector potential
$$\vec{A}_0(\vec{x})=\frac{1}{4 \pi r} \int_{K_R} \mathrm{d}^3 \vec{x}' \vec{j}(\vec{x}').$$
Here ##K_R## is the sphere of radius ##R##. Now we show that this vanishes. To this end we note that (Carstesian Einstein summation convention used)
$$\partial_b (x_a j_b)=j_a + x_a \partial_b j_b=j_a,$$
because ##\vec{\nabla} \cdot \vec{j} = \partial_b j_b=0##.
From this we get using Gauss's integral theorem
$$A_a=\frac{1}{4 \pi c r} \int_{K_R} \mathrm{d}^3 \vec{x}' \partial_b' (x_a' j_b)= \frac{1}{4 \pi c r} \int_{\partial K_R} \mathrm{d}^3 \vec{F}_b' x_a' j_b=0,$$
because along the spherical shell ##|\vec{x}'|=R## by assumption ##\vec{j}=0##. Thus, there is no monopole term in the magnetic field, which is quite clear already from Gauss's Law ##\vec{\nabla} \cdot \vec{B}=0## (no magnetic monopoles!).
Thus the leading order in the ##1/r## exansion is from the 2nd term in the expansion of the Green's function, i.e.,
$$\vec{A}_{1a}(\vec{x})=\frac{\vec{x}_b}{4 \pi c r^3} \int_{K_R} \mathrm{d}^3 \vec{x}' j_a(\vec{x}') x_b'. \qquad(*)$$
To make this a bit simpler we can use a similar trick as above and evaluate
$$\partial_{c}'( x_a' x_b' j_c)=x_b' j_a + x_a' j_b.$$
On the other hand we have
$$\epsilon_{abc} \epsilon_{cde} x_d' j_e=(\delta_{ad} \delta_{be}-\delta_{ae} \delta_{bd}) x_d' j_e=x_a' j_b-x_b' j_a.$$
subtracting the last two equations thus gives
$$\partial_{c'}(x_a' x_b' j_c)-\epsilon_{abc} \epsilon_{cde} x_d' j_e=2 x_b' j_a,$$
and we can write (*) as
$$\vec{A}_{1a}(\vec{x})=-\frac{1}{2} \frac{x_b}{4 \pi c r^3} \int_{K_R} \mathrm{d}^3 \vec{x}' \epsilon_{abc} \epsilon_{cde} x_d' j_e$$
or
$$\vec{A}_{1a}(\vec{x})=-\frac{1}{2} \frac{x_b}{4 \pi c r^3} \int_{K_R} \mathrm{d}^3 \vec{x}' \epsilon_{abc} (\vec{x}' \times \vec{j})_c$$
or finally
$$\vec{A}_1(\vec{x})=-\frac{\vec{x}}{8 \pi c r^3} \times \int_{K_R} \mathrm{d}^3 \vec{x}' \vec{x}' \times \vec{j}(\vec{x}')=\frac{\vec{m} \times \vec{x}}{4 \pi r^3}.$$
This leads to
$$\vec{m}=+\frac{1}{2 c} \int_{K_R} \mathrm{d}^3 \vec{x}' \vec{x}' \times \vec{j}(\vec{x}'). \qquad (**)$$
Evaluating the curl of ##\vec{A}_1## indeed leads to a dipole field:
$$\vec{B}_1=\vec{\nabla} \times \vec{A}_1=\frac{3 (\vec{m} \cdot \vec{x}) \vec{x}-r^2 \vec{m}}{4 \pi r^5}.$$
Thus (**) is the magnetic dipole moment for a general current distribution.
For a filament-like current you have to substitute
$$\mathrm{d}^3 \vec{x}' \vec{j} \rightarrow I \mathrm{d} \vec{r}'.$$
Then the dipole moment gets
$$\vec{m}=-\frac{I}{2 c} \int_{\ell} \mathrm{d} \vec{x}' \times \vec{x}' .$$
Now we use Stokes's integral theorem. You can write for an arbitrary field ##\phi## and a constant vector ##\vec{n}##
$$\int_F \mathrm{d} \vec{F} \cdot \vec{\nabla} \times (\vec{n} \phi) = \int_{\partial F} \mathrm{d} \vec{x} \cdot \vec{n} \phi.$$
Now for ##\vec{n}=\vec{e}_a## (##a \in \{1,2,3\}##) we get
$$\int_F \mathrm{d} \vec{F} \cdot \vec{\nabla} \times (\vec{e}_a \phi) = \int_F \mathrm{d} \vec{F} \cdot (\vec{\nabla} \phi \times \vec{e}_a) = \int_F (\mathrm{d} \vec{F} \times \vec{\nabla} \phi)_a=\int_{\partial F} \mathrm{d} x_a \phi.$$
This formula can be used to write (after some manipulations with the Levi-Civita symbols
$$m_a=\frac{I}{c} \int_{F} \mathrm{d} F_a,$$
where ##F## is an arbitrary surface with the boundary given by the current loop.