> ## Documentation Index
> Fetch the complete documentation index at: https://developers.scrunch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apply Page Optimization

> Record that a page's optimization was **acted on off-platform** — for when the change was made outside Scrunch (e.g. in Sitecore), so no Scrunch review is needed.

Send exactly one of: `approve_all: true` to accept every changed block, or a `reviews` list with per-block verdicts by chunk `id` (`approved` keeps our version, `rejected` keeps the original). A `reviews` list can be **partial** — un-verdicted blocks keep the run pending, so blocks can be resolved across several calls. The page is **acknowledged automatically once every changed block has a verdict**, matching the in-app flow that can't close a page with an unresolved block.

Applies to the page's latest run. Returns the run (same shape as the optimization endpoint) — `acknowledged` once complete, otherwise still `pending`. Returns 422 when neither or both actions are given, 404 when the page has no run, and 409 for an edge-delivery (AXP-active) page — those go through the edge staging workflow.



## OpenAPI

````yaml /api-reference/openapi.json post /{brand_id}/site-diagnostics/optimization/apply
openapi: 3.1.0
info:
  title: Scrunch Data API
  version: 0.1.0
servers:
  - url: https://api.scrunchai.com/v1
security: []
paths:
  /{brand_id}/site-diagnostics/optimization/apply:
    post:
      tags:
        - site-diagnostics
      summary: Apply Page Optimization
      description: >-
        Record that a page's optimization was **acted on off-platform** — for
        when the change was made outside Scrunch (e.g. in Sitecore), so no
        Scrunch review is needed.


        Send exactly one of: `approve_all: true` to accept every changed block,
        or a `reviews` list with per-block verdicts by chunk `id` (`approved`
        keeps our version, `rejected` keeps the original). A `reviews` list can
        be **partial** — un-verdicted blocks keep the run pending, so blocks can
        be resolved across several calls. The page is **acknowledged
        automatically once every changed block has a verdict**, matching the
        in-app flow that can't close a page with an unresolved block.


        Applies to the page's latest run. Returns the run (same shape as the
        optimization endpoint) — `acknowledged` once complete, otherwise still
        `pending`. Returns 422 when neither or both actions are given, 404 when
        the page has no run, and 409 for an edge-delivery (AXP-active) page —
        those go through the edge staging workflow.
      operationId: applySiteDiagnosticsOptimization
      parameters:
        - name: brand_id
          in: path
          required: true
          schema:
            type: integer
            title: Brand Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApplyOptimizationRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PathOptimization'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer:
            - optimize
components:
  schemas:
    ApplyOptimizationRequest:
      properties:
        path:
          type: string
          minLength: 1
          title: Path
          description: The page path, e.g. `/about`.
        approve_all:
          type: boolean
          title: Approve All
          description: Accept every changed block. Mutually exclusive with `reviews`.
          default: false
        reviews:
          anyOf:
            - items:
                $ref: '#/components/schemas/OptimizationReview'
              type: array
            - type: 'null'
          title: Reviews
          description: >-
            Per-block verdicts, keyed by chunk `id` — a verdict for every
            changed block (`approved` keeps our version, `rejected` keeps the
            original). Mutually exclusive with `approve_all`.
      type: object
      required:
        - path
      title: ApplyOptimizationRequest
      description: >-
        Body for acknowledging a page's optimization as acted on off-platform.


        Exactly one of ``approve_all`` or ``reviews`` — closing a page is a
        declared action, so there's

        no implicit "accept everything" default.
    PathOptimization:
      properties:
        path:
          type: string
          title: Path
        status:
          type: string
          enum:
            - pending
            - completed
            - staged
            - deployed
            - retired
            - outdated
            - acknowledged
          title: Status
        summary:
          $ref: '#/components/schemas/OptimizationSummary'
        chunks:
          items:
            $ref: '#/components/schemas/OptimizationChunk'
          type: array
          title: Chunks
          default: []
      type: object
      required:
        - path
        - status
        - summary
      title: PathOptimization
      description: >-
        Endpoint 2 response: a page's latest optimization run with before/after
        chunks.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    OptimizationReview:
      properties:
        id:
          type: string
          title: Id
        status:
          type: string
          enum:
            - approved
            - rejected
          title: Status
      type: object
      required:
        - id
        - status
      title: OptimizationReview
      description: >-
        A per-block verdict for the apply body: `approved` keeps our optimized
        block, `rejected`

        keeps the page's original.
    OptimizationSummary:
      properties:
        transformed:
          type: integer
          title: Transformed
        enriched:
          type: integer
          title: Enriched
        removed:
          type: integer
          title: Removed
        tokens_after:
          type: integer
          title: Tokens After
      type: object
      required:
        - transformed
        - enriched
        - removed
        - tokens_after
      title: OptimizationSummary
      description: Per-category chunk counts and the optimized token total for a run.
    OptimizationChunk:
      properties:
        id:
          type: string
          title: Id
        order:
          type: integer
          title: Order
        category:
          anyOf:
            - type: string
              enum:
                - enriched
                - transformed
                - removed
            - type: 'null'
          title: Category
        status:
          anyOf:
            - type: string
              enum:
                - pending
                - approved
                - rejected
            - type: 'null'
          title: Status
        before:
          items:
            $ref: '#/components/schemas/ContentNode'
          type: array
          title: Before
          default: []
        after:
          items:
            $ref: '#/components/schemas/ContentNode'
          type: array
          title: After
          default: []
      type: object
      required:
        - id
        - order
      title: OptimizationChunk
      description: >-
        One content block's before/after. `category` is null for an unchanged
        block; `status` is the

        reviewer's verdict (`approved`/`rejected`) or `pending` when the run
        isn't reviewed — a rejected

        block's `after` was NOT accepted, so it must be distinguishable from an
        approved one.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ContentNode:
      properties:
        type:
          type: string
          const: html
          title: Type
          default: html
        text:
          type: string
          title: Text
      type: object
      required:
        - text
      title: ContentNode
      description: >-
        A single renderable unit of content. Only `html` is supported (per the
        RFC).
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````

## Related topics

- [Site Diagnostics API: Per-page findings and optimization runs](/api-reference/site-diagnostics/overview.md)
- [Get Page Optimization Detail](/api-reference/site-diagnostics/get-page-optimization-detail.md)
- [AXP Unpublish API: Take Optimized Pages Off the Edge](/api-reference/axp/unpublish.md)
