# headerFooters.pageNumbers.set

> Atomically add a section's page numbers or change them: move them between header and footer, realign them, show or hide them on the first page, and set the number style and start. Available on v2-backed sessions only; v1-backed sessions currently return `CAPABILITY_UNAVAILABLE`.



- Member path: `doc.headerFooters.pageNumbers.set(…)`
- Mutates document: yes
- Idempotency: `conditional`
- Supports tracked mode: no
- Supports dry run: yes

## Expected result

Returns the numbered header/footer parts and whether the section uses a distinct first page; PRECONDITION_FAILED with reason page-number-has-content when a moved or hidden number shares its paragraph with other text or fields.

## Input schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "SectionAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "section"
        },
        "sectionId": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "sectionId"
      ]
    }
  },
  "type": "object",
  "properties": {
    "section": {
      "$ref": "#/$defs/SectionAddress"
    },
    "kind": {
      "enum": [
        "header",
        "footer"
      ]
    },
    "alignment": {
      "enum": [
        "left",
        "center",
        "right"
      ]
    },
    "showOnFirstPage": {
      "type": "boolean"
    },
    "format": {
      "enum": [
        "decimal",
        "lowerLetter",
        "upperLetter",
        "lowerRoman",
        "upperRoman",
        "numberInDash",
        "hebrew1",
        "hebrew2"
      ]
    },
    "start": {
      "oneOf": [
        {
          "type": "integer",
          "minimum": 0
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "section",
    "kind"
  ]
}
```

## Output schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "SectionAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "section"
        },
        "sectionId": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "sectionId"
      ]
    }
  },
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "success": {
          "const": true
        },
        "section": {
          "$ref": "#/$defs/SectionAddress"
        },
        "kind": {
          "enum": [
            "header",
            "footer"
          ]
        },
        "parts": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "kind": {
                "const": "headerFooterPart"
              },
              "refId": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "kind",
              "refId"
            ]
          }
        },
        "titlePage": {
          "type": "boolean"
        }
      },
      "additionalProperties": false,
      "required": [
        "success",
        "section",
        "kind",
        "parts",
        "titlePage"
      ]
    },
    {
      "type": "object",
      "properties": {
        "success": {
          "const": false
        },
        "failure": {
          "type": "object",
          "properties": {
            "code": {
              "enum": [
                "TARGET_NOT_FOUND",
                "PRECONDITION_FAILED",
                "CAPABILITY_UNAVAILABLE",
                "INTERNAL_ERROR"
              ]
            },
            "message": {
              "type": "string"
            },
            "details": {}
          },
          "additionalProperties": false,
          "required": [
            "code",
            "message"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "success",
        "failure"
      ]
    }
  ]
}
```

## Pre-apply throws

- `INVALID_INPUT`
- `INVALID_TARGET`
- `CAPABILITY_UNAVAILABLE`
- `INTERNAL_ERROR`

## Non-applied receipt codes

- `TARGET_NOT_FOUND`
- `PRECONDITION_FAILED`
- `CAPABILITY_UNAVAILABLE`
- `INTERNAL_ERROR`

