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

# Finalize Detection Session

> Transition a detection session into `finalizing`.



## OpenAPI

````yaml /generated/api.openapi.json post /api/detection/sessions/{session_id}/finalize
openapi: 3.1.0
info:
  title: Kynasmith Public API
  version: 0.1.0
servers: []
security: []
paths:
  /api/detection/sessions/{session_id}/finalize:
    post:
      tags:
        - detection
      summary: Finalize Detection Session
      description: Transition a detection session into `finalizing`.
      operationId: >-
        finalize_detection_session_api_detection_sessions__session_id__finalize_post
      parameters:
        - in: path
          name: session_id
          required: true
          schema:
            format: uuid
            title: Session Id
            type: string
        - in: header
          name: Idempotency-Key
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Idempotency-Key
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DetectionSessionResource'
          description: Successful Response
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicErrorEnvelope'
          description: The request payload or query parameters are invalid.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicErrorEnvelope'
          description: Authentication failed.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicErrorEnvelope'
          description: Caller is not authorized for this action.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicErrorEnvelope'
          description: Referenced resource does not exist.
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicErrorEnvelope'
          description: Request conflicts with current resource state.
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicErrorEnvelope'
          description: Request validation failed for the targeted resource state.
      security:
        - BearerAccessToken: []
        - BearerAccessToken: []
components:
  schemas:
    DetectionSessionResource:
      description: Persisted customer detection-session resource.
      properties:
        accepted_frames_total:
          description: Total number of accepted frames for the session.
          title: Accepted Frames Total
          type: integer
        ended_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          description: Timestamp when the session became terminal.
          title: Ended At
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          description: Top-level terminal error code when present.
          title: Error Code
        error_message:
          anyOf:
            - type: string
            - type: 'null'
          description: Top-level terminal error message when present.
          title: Error Message
        mode:
          description: Runtime mode for the session.
          enum:
            - live
            - replay
          title: Mode
          type: string
        organization_id:
          description: Owning organization identifier.
          format: uuid
          title: Organization Id
          type: string
        project_id:
          description: Owning project identifier.
          format: uuid
          title: Project Id
          type: string
        resolved_movespec_version_id:
          description: Resolved immutable MoveSpec version for customer runtime.
          format: uuid
          title: Resolved Movespec Version Id
          type: string
        session_id:
          description: Detection session identifier.
          format: uuid
          title: Session Id
          type: string
        started_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          description: Timestamp when streaming began.
          title: Started At
        status:
          description: Current session lifecycle state.
          enum:
            - created
            - streaming
            - finalizing
            - completed
            - failed
            - cancelled
          title: Status
          type: string
        terminal_outcome:
          anyOf:
            - type: string
            - type: 'null'
          description: Terminal outcome summary when the session ends.
          title: Terminal Outcome
      required:
        - session_id
        - organization_id
        - project_id
        - mode
        - status
        - resolved_movespec_version_id
        - accepted_frames_total
      title: DetectionSessionResource
      type: object
    PublicErrorEnvelope:
      description: Stable public error envelope shared across transports.
      properties:
        error:
          $ref: '#/components/schemas/PublicErrorDetail'
          description: Structured error payload.
      required:
        - error
      title: PublicErrorEnvelope
      type: object
    PublicErrorDetail:
      description: Stable public error payload shared across transports.
      properties:
        code:
          description: Machine-readable error code.
          title: Code
          type: string
        details:
          additionalProperties:
            anyOf:
              - type: string
              - type: integer
              - type: number
              - type: boolean
              - type: 'null'
          description: Bounded structured error details.
          title: Details
          type: object
        message:
          description: Human-readable error message.
          title: Message
          type: string
        retryable:
          description: Whether the caller can retry safely.
          title: Retryable
          type: boolean
      required:
        - code
        - message
        - retryable
      title: PublicErrorDetail
      type: object
  securitySchemes:
    BearerAccessToken:
      description: Backend-issued machine access token for project-scoped API access.
      scheme: bearer
      type: http

````