While Francois' answer is fine, as far as it goes, I think that it is important to bear in mind the history of this problem.

The original problem of 'flatness' or integrability (and more generally, equivalence) of what are now called $G$-structures was formulated by Élie Cartan in his fundamental paper *Les sous-groupes des groupes continus de transformations*, Annales scientifiques de l'École Normale Supérieure, Sér. 3, 25 (1908), p. 57-194.

Moreover, the flatness problem was essentially solved by him in this paper, in the sense that he provided an explicit algorithm for deciding when a given $G$-structure was 'flat' (i.e., locally equivalent to the natural 'constant' $G$-structure on $\mathbb{R}^n$) by describing how to compute a sequence of obstructions to flatness for any given subgroup $G\subset\mathrm{GL}(n,\mathbb{R})$. (These obstructions would nowadays be formulated as 'torsion' and/or 'curvature' tensors of various orders of the $G$-structure. Cartan simply called them 'invariants' of the given $G$-structure.)

The 'essentially' refers to two weaknesses: First, Cartan did not provide (nor did he have) a proof that the sequence terminated in a finite number of steps, although it did in all the cases that he (and others) computed (which included symplectic, (pseudo-)Riemannian, conformal, and projective geometries, for example). Second, his conditions (in case the sequence terminated), which were clearly necessary, were mostly known to be sufficient only in the case that the original $G$-structure was real-analytic or 'finite type'. (This was because his main PDE existence theorem was Cartan-Kähler, which only applies in the real-analytic category, or the (ODE) Frobenius theorem, which applies, even for smooth structures, in the 'finite type' case, which includes pseudo-Riemannian geometry, conformal geometry in dimension $n>2$, and projective geometry, as well as many other examples nowadays called 'parabolic geometries'. Symplectic geometry, i.e., Darboux' Theorem is not finite type, but it turns out that one can prove the existence theorem using only ODE techniques anyway, so real-analyticity is not needed in this case. As another example, if $G\subset\mathrm{GL}(n,\mathbb{R})$ is compact, Cartan's algorithm yields that a $G$-structure is flat if and only if its canonical connection is torsion-free and has vanishing curvature. In particular, this covers the Kähler case, in which $G=\mathrm{U}(\tfrac12n)$.)

The first weakness was remedied in M. Kuranishi, *On É. Cartan's prolongation theorem of exterior differential systems*, Amer. J. Math., vol. 79, 1957, p. 1–47,
in which Kuranishi re-formulated Cartan's constructions in terms of cohomology groups and proved a finiteness theorem based on Hilbert's theorem about finite generation of modules over polynomial rings. This established that, at least for the 'flatness' or 'integrability' problem, Cartan's algorithm always terminates in a finite number of steps (and hence furnishes sufficient conditions in the real-analytic case and the finite type cases).

The second weakness took longer to resolve. For example, for almost-complex structures, Cartan's algorithm states that, for real-analytic almost-complex structures, the vanishing of the Nijnhuis tensor is the necessary and sufficient condition for flatness, but, since this is not a finite type case, for smooth (or even weaker regularity) almost-complex structures, this necessary condition was not known to be sufficient until the work of Newlander and Nirenberg in 1957. The 'flatness' problem for smooth $G$-structures not of finite type was only finally solved in complete generality considerably later, by combined work of Guillemin, Spencer, Goldschimdt, Malgrange and a number of other people. An account of this story can be found in the final chapters of our book "Exterior Differential Systems" (Bryant-Chern-Gardner-Goldschmidt-Griffiths, 1991).

**Remark 1:** 'Flatness' and 'integrability' have not always been synonymous. For example, see Shiing-Shen Chern, *Pseudo-groupes continus infinis*, Géométrie différentielle., Colloques Internationaux du Centre National de la Recherche Scientifique, Strasbourg, vol. 1953, Centre National de la Recherche Scientifique, Paris, 1953, pp. 119–136. In this paper, a notion of 'integrability' is defined that is more general than 'flatness'. It includes, for example, the Pfaff-Darboux Theorem for contact structures, which are not 'flat' as $G$-structures (i.e., they cannot be expressed as constant coefficient tensors in any coordinate system) but are still 'integrable' in the (original) wider sense.

**Remark 2:** Since Cartan's time, there have been notable improvements in the implementation of Cartan's algorithm. Cartan himself, in his later work on differential geometry in the 1920s and 1930s, noted that, in certain cases of $G$-structures of finite type, the algorithm could be structured in the form of what is now called the construction of a canonical 'Cartan connection' associated to a given $G$-structure, and the necessary and sufficient condition for flatness could be expressed as the vanishing of curvature of that connection. In the 1950s and 1960s, his work was reformulated in a more modern 'global' language by several mathematicians, among them Guillemin, Kobayashi, Spencer, Singer, and Sternberg. In the 1970s, Tanaka found a general construction of a canonical Cartan connection for a wide range of geometries of finite type and greatly clarified the process and the interpretation of the curvature, and this work has had numerous applications, particularly in the study of so-called 'parabolic geometries'. (Still, it should be remarked that it is not *always* possible to introduce a canonical connection in the finite-type case. It is possible that Cartan himself was aware of this problem, as the first such 'wild' examples already occur in dimension $n=3$, but there is no evidence of this in his published works.)