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

# Finalize a cloud report

> State becomes `complete` only after ownership, digest, and schema all check out, and the upload must already be in the `received` state. `schemaVersion` must be exactly `1.0.0`.

The sync unit is spent here rather than at creation, so a report whose upload leg failed never charged the user. A finished report is kept even when the reservation was already reaped and there is no room to re-take it.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/reports/{id}/finalize
openapi: 3.1.0
info:
  title: Myrqen API
  version: 1.0.0
  description: >-
    The JSON API served by `apps/web` under `/api/v1`. Derived from the route
    handlers in `apps/web/app/api/v1` and the shared types in
    `packages/contracts`.


    This reference documents the surface a developer and the Myrqen CLI actually
    use. Platform-administration and billing endpoints exist in the application
    but are operator-only and are deliberately not published here.


    The hosted service at `https://api.myrqen.cc` is not deployed yet. Run your
    own deployment and use its origin.
  license:
    name: Myrqen Source-Available Licence 1.0
    url: https://github.com/stijnswapped/Myrqen/blob/main/LICENSE
servers:
  - url: http://localhost:3000
    description: >-
      A deployment you run yourself. Use this while the hosted service is
      unavailable.
  - url: https://api.myrqen.cc
    description: >-
      The hosted API. This is the CLI's shipped default, but the hosted service
      is NOT deployed yet, so requests to it do not resolve today.
security: []
tags:
  - name: Health
    description: >-
      Liveness and readiness probes. Unauthenticated, and answered on any
      hostname.
  - name: Authentication
    description: Browser sessions. Password plus recovery codes; no email is ever sent.
  - name: Device linking
    description: Binding a machine's CLI to an account, via browser approval.
  - name: Workspaces and projects
    description: Where a scanned repository belongs.
  - name: Sync and quota
    description: Creating, feeding, and finalizing a cloud report.
  - name: Reports
    description: Reading and exporting a synced report.
  - name: Sharing
    description: Share links and the server-side projections they resolve to.
  - name: Analytics
    description: Allowlisted product-event ingest.
  - name: Updates
    description: The signed release manifest.
paths:
  /api/v1/reports/{id}/finalize:
    post:
      tags:
        - Sync and quota
      summary: Finalize a cloud report
      description: >-
        State becomes `complete` only after ownership, digest, and schema all
        check out, and the upload must already be in the `received` state.
        `schemaVersion` must be exactly `1.0.0`.


        The sync unit is spent here rather than at creation, so a report whose
        upload leg failed never charged the user. A finished report is kept even
        when the reservation was already reaped and there is no room to re-take
        it.
      operationId: finalizeReport
      parameters:
        - $ref: '#/components/parameters/ReportId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FinalizeReportRequest'
      responses:
        '200':
          description: Finalized.
          content:
            application/json:
              schema:
                type: object
                required:
                  - reportId
                  - state
                  - reportUrl
                  - expiresAt
                properties:
                  reportId:
                    type: string
                  state:
                    type: string
                    const: complete
                  reportUrl:
                    type: string
                    format: uri
                  expiresAt:
                    type: string
                    format: date-time
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          description: '`REPORT_SCHEMA_UNSUPPORTED` — unsupported `schemaVersion`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
      security:
        - deviceToken: []
components:
  parameters:
    ReportId:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: The cloud report id.
  schemas:
    FinalizeReportRequest:
      type: object
      required:
        - uploadId
        - sha256
        - schemaVersion
        - summary
        - durationMs
        - tokenUsage
        - effortResolved
      properties:
        uploadId:
          type: string
        sha256:
          type: string
          pattern: ^[a-f0-9]{64}$
        schemaVersion:
          type: string
          const: 1.0.0
        summary:
          $ref: '#/components/schemas/ReportSummary'
        durationMs:
          type: integer
        tokenUsage:
          $ref: '#/components/schemas/TokenUsage'
        effortResolved:
          $ref: '#/components/schemas/EffortResolved'
        agent:
          allOf:
            - $ref: '#/components/schemas/AgentMetadata'
          description: >-
            The host agent and model are often only known after the scan starts,
            so the final values replace whatever the shell was created with.
    ApiError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - requestId
          properties:
            code:
              $ref: '#/components/schemas/ApiErrorCode'
            message:
              type: string
              description: Human-readable. May change; branch on `code`.
            requestId:
              type: string
              description: A fresh UUID per response, for correlating with server logs.
            details:
              type: object
              additionalProperties: true
      example:
        error:
          code: SYNC_WEEKLY_LIMIT_REACHED
          message: Cloud report limit reached. This scan stays local.
          requestId: 8f14e45f-ceea-467a-9f8b-2b6b2b6a1f2c
          details:
            weekly:
              used: 15
              limit: 15
              resetsAt: '2026-08-24T06:00:00.000Z'
    ReportSummary:
      type: object
      required:
        - findingCount
        - severityCounts
        - verificationCounts
      properties:
        findingCount:
          type: integer
        severityCounts:
          type: object
          required:
            - critical
            - high
            - medium
            - low
            - info
          properties:
            critical:
              type: integer
            high:
              type: integer
            medium:
              type: integer
            low:
              type: integer
            info:
              type: integer
        verificationCounts:
          type: object
          required:
            - verified
            - strong_evidence
            - needs_review
          properties:
            verified:
              type: integer
            strong_evidence:
              type: integer
            needs_review:
              type: integer
        candidateCount:
          type: integer
        duplicateCount:
          type: integer
        fixedCount:
          type: integer
    TokenUsage:
      type: object
      required:
        - source
      description: Provenance is mandatory. An exact count is never fabricated.
      properties:
        source:
          type: string
          enum:
            - exact
            - estimated
            - unavailable
        count:
          type: integer
        estimator:
          type: string
          description: Estimator name and version, for `estimated`.
    EffortResolved:
      type: string
      enum:
        - low
        - high
        - xhigh
        - ultra
    AgentMetadata:
      type: object
      required:
        - name
      properties:
        name:
          type: string
        version:
          type: string
        model:
          type: string
    ApiErrorCode:
      type: string
      enum:
        - BAD_REQUEST
        - VALIDATION_FAILED
        - UNAUTHENTICATED
        - FORBIDDEN
        - NOT_FOUND
        - CONFLICT
        - RATE_LIMITED
        - INTERNAL
        - DEVICE_LINK_EXPIRED
        - DEVICE_LINK_ALREADY_CONSUMED
        - DEVICE_LINK_NOT_APPROVED
        - DEVICE_REVOKED
        - SYNC_DAILY_LIMIT_REACHED
        - SYNC_WEEKLY_LIMIT_REACHED
        - REPORT_EXPIRED
        - REPORT_SCHEMA_UNSUPPORTED
        - UNSAFE_PAYLOAD_REJECTED
        - SHARE_PASSWORD_REQUIRED
        - SHARE_NOT_AVAILABLE
        - CLIENT_VERSION_REVOKED
        - CLIENT_VERSION_TOO_OLD
        - SUPPORT_GRANT_REQUIRED
  responses:
    BadRequest:
      description: >-
        `BAD_REQUEST`. Also returned with HTTP 413 when a body exceeds the
        endpoint's byte limit.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    Unauthenticated:
      description: >-
        `UNAUTHENTICATED` — no credential, a malformed credential, or one that
        did not match. `DEVICE_REVOKED` also uses 401.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    NotFound:
      description: >-
        `NOT_FOUND` — the resource does not exist, or exists and you may not
        know that.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  securitySchemes:
    deviceToken:
      type: http
      scheme: bearer
      description: >-
        The CLI's device credential, obtained once from the device-link exchange
        and stored in the OS keystore. Sent as `Authorization: Bearer
        myrq_dev_…`. The server never trusts a CLI-supplied user id — identity
        comes from the credential row.

````