The anomalous X-ray pulsars (AXPs) and soft γ-repeaters (SGRs) are peculiar high-energy sources believed to host a magnetar, an ultramagnetized neutron star with surface magnetic field in the petagauss range. Their persistent, soft X-ray emission exhibits a two component spectrum, usually modelled by the superposition of a blackbody and a power-law tail. It has been suggested that the ∼1–10 keV spectrum of AXPs/SGRs forms as the thermal photons emitted by the cooling star surface traverse the magnetosphere. Magnetar magnetospheres are, in fact, likely different from those of ordinary radio pulsars, since the external magnetic field may acquire a toroidal component as a consequence of the deformation of the star crust induced by the superstrong interior field. In a twisted magnetosphere, the supporting currents can provide a large optical depth to resonant cyclotron scattering. The thermal spectrum emitted by the star surface will be then distorted because primary photons gain energy in the repeated scatterings with the flowing charges, and this may provide a natural explanation for the observed spectra. In this paper we present 3D Monte Carlo simulations of photon propagation in a twisted magnetosphere. Our model is based on a simplified treatment of the charge carrier velocity distribution which however accounts for the particle collective motion, in addition to the thermal one. The present treatment is restricted to conservative (Thomson) scattering in the electron rest frame. The code, none the less, is completely general and inclusion of the relativistic quantum electrodynamical resonant cross-section, which is required in the modelling of the hard (∼20–200 keV) spectral tails observed in the magnetar candidates, is under way. The properties of emerging spectra have been assessed under different conditions, by exploring the model parameter space, including effects arising from the viewing geometry. Monte Carlo runs have been collected into a spectral archive which has then been implemented in the X-ray fitting package xspec. Two tabulated xspec spectral models, with and without viewing angles, have been produced and applied to the 0.1–10 keV XMM–Newton EPIC-pn spectrum of the AXP CXOU J1647−4552.