Apologies, initial submission mixed up 'level' and 'number', my mistake!
Updated:
The section index used for an edit action in the Mediawiki API has a flaw, a given section's index will change if a prior section, that was already established, gets a new subsection.
An improvement would be to make available the 'number' value for an edit as well. It will still change if a new section at the same level is added prior to this section, but will not be impacted by new subsections in prior section.
This would also allow an edit request to address a single specific section instead having to account for any possible subsections in an edit.
Example:
Section 1
sub 1
Section 2
Section 2 section index is 3. Adding a sub 2 in Section 1 causes Section 2's index to increase to 4. Being able to use number values instead would help, Section 2's number remains 2.0.
I think it would be best that an edit request for level includes no subsections, so edit level 1.0 only gets the content of Section 1, stopping at sub 1 header.