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

# Verify the replacement PUT landed and finalize it

> Requires files:["write"]. Same per-class file-access resolution as POST .../replace, no body. Storage usage adjusts by the DELTA. The public URL and fileId never change.



## OpenAPI

````yaml /api/openapi.json post /files/{fileId}/replace/confirm
openapi: 3.1.0
info:
  title: PixGlory Machine API
  version: 1.0.0
  description: >-
    The versioned /api/v1/* machine API — bearer-key authenticated, for the
    WordPress plugin and future integrations. Hand-written and maintained
    alongside apps/start/src/routes/api/v1/*; see machine-api-v1.md for the
    human-readable walkthrough. THIS FILE IS THE SOURCE OF TRUTH where the two
    disagree.
servers:
  - url: https://pixglory.com/api/v1
security:
  - bearerKey: []
paths:
  /files/{fileId}/replace/confirm:
    post:
      summary: Verify the replacement PUT landed and finalize it
      description: >-
        Requires files:["write"]. Same per-class file-access resolution as POST
        .../replace, no body. Storage usage adjusts by the DELTA. The public URL
        and fileId never change.
      operationId: confirmReplace
      parameters:
        - name: fileId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReplaceConfirmResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/QuotaExceeded'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  schemas:
    ReplaceConfirmResponse:
      type: object
      required:
        - id
        - projectId
        - sizeBytes
        - previousSizeBytes
        - deltaBytes
      properties:
        id:
          type: string
        projectId:
          type: string
        sizeBytes:
          type: integer
        previousSizeBytes:
          type: integer
        deltaBytes:
          type: integer
          description: Signed — positive means the file grew, negative means it shrank.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - code
          properties:
            message:
              type: string
            code:
              type: string
            details: {}
  responses:
    BadRequest:
      description: >-
        Validation failure, an operation that can't succeed yet (e.g. a PUT that
        never landed), a wordpress key with no bound project, or an api-class
        key that omitted a required projectId.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            notBound:
              value:
                error:
                  message: >-
                    This key isn't bound to a CDN project. Create a new key with
                    a project selected.
                  code: KEY_NOT_BOUND_TO_PROJECT
            missingProjectId:
              value:
                error:
                  message: >-
                    This key has no bound project. Pass "projectId" in the
                    request body.
                  code: MISSING_PROJECT_ID
    Unauthorized:
      description: Missing, malformed, unknown, expired, or disabled key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missing:
              value:
                error:
                  message: 'Missing API key. Send it as `Authorization: Bearer <key>`.'
                  code: MISSING_API_KEY
            invalid:
              value:
                error:
                  message: Invalid or expired API key.
                  code: INVALID_API_KEY
    QuotaExceeded:
      description: The org's CDN storage or file-count quota would be exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            storage:
              value:
                error:
                  message: >-
                    Storage quota exceeded: 490000000/500000000 bytes used on
                    the free tier
                  code: CDN_STORAGE_QUOTA_EXCEEDED
                  details:
                    service: cdn
                    tier: free
                    metric: cdnStorage
                    limit: 500000000
                    used: 490000000
    Forbidden:
      description: >-
        The key is valid but either lacks a required permission, or is a real
        key of a class this endpoint doesn't accept.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            insufficient:
              value:
                error:
                  message: This key does not have the required permissions.
                  code: INSUFFICIENT_PERMISSIONS
            wrongClass:
              value:
                error:
                  message: >-
                    This endpoint requires a wordpress-class key; the presented
                    key is class "api".
                  code: WRONG_KEY_CLASS
    NotFound:
      description: >-
        The resource doesn't exist, or belongs to a project other than the one
        the key is bound to (identical response either way).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            notFound:
              value:
                error:
                  message: Not found
                  code: NOT_FOUND
    TooManyRequests:
      description: >-
        Rate limited — ours or the underlying key plugin's own. Honour
        Retry-After.
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds until the window resets.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            rateLimited:
              value:
                error:
                  message: Too many requests, please try again shortly.
                  code: RATE_LIMIT
  securitySchemes:
    bearerKey:
      type: http
      scheme: bearer
      bearerFormat: pxg_... or pxg_wp_...
      description: >-
        An API key minted from the dashboard (POST /api/api-keys), of either
        class: `api` (prefix `pxg_`) or `wordpress` (prefix `pxg_wp_`). Which
        class a given route accepts is documented per-endpoint below; presenting
        a real key of a class the route doesn't accept is `403 WRONG_KEY_CLASS`,
        never folded into `401 INVALID_API_KEY`. No cookie fallback exists.

````