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

# Attach Moment Criterion

> Adds a criterion attachment and backfills existing members. The attach response charges nothing (cost header 0); per-file runs charge as they execute, and a matching prior run satisfies a pair at no extra execution.



## OpenAPI

````yaml POST /collections/{collection_id}/moment-criteria
openapi: 3.0.0
info:
  title: Cloudglue API
  description: API for Cloudglue
  license:
    name: Apache License 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 0.7.23
servers:
  - url: https://api.cloudglue.dev/v1
security:
  - bearerAuth: []
paths:
  /collections/{collection_id}/moment-criteria:
    post:
      tags:
        - Collections
      summary: Attach a criterion to a moments collection
      description: >-
        Adds a criterion attachment and backfills existing members. The attach
        response charges nothing (cost header 0); per-file runs charge as they
        execute, and a matching prior run satisfies a pair at no extra
        execution.
      operationId: createCollectionMomentCriterion
      parameters:
        - name: collection_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewMomentCriterionAttachment'
      responses:
        '201':
          description: The attachment, backfill pending.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MomentCriterionAttachment'
        '400':
          description: Invalid criterion, or not a moments collection
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: Balance cannot cover the backfill precheck
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Collection not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    NewMomentCriterionAttachment:
      type: object
      properties:
        criterion:
          $ref: '#/components/schemas/MomentCriterion'
        signals_required:
          type: array
          minItems: 1
          default:
            - speech
          items:
            type: string
            enum:
              - speech
              - visual_scene_description
              - scene_text
              - audio_description
        boundary_policy:
          type: string
          enum:
            - sentence
            - tight
            - loose
          default: sentence
        speaker_filter:
          type: object
          properties:
            include:
              type: array
              items:
                type: string
            exclude:
              type: array
              items:
                type: string
            match:
              type: string
              enum:
                - any
                - all
        min_duration_seconds:
          type: number
          minimum: 0
          exclusiveMinimum: true
          default: 5
        max_duration_seconds:
          type: number
          minimum: 0
          exclusiveMinimum: true
          default: 300
      required:
        - criterion
      additionalProperties: false
    MomentCriterionAttachment:
      type: object
      properties:
        attachment_id:
          type: string
          format: uuid
        criterion_name:
          type: string
        criterion_hash:
          type: string
        criterion:
          type: object
        options:
          type: object
        backfill_status:
          type: string
          enum:
            - pending
            - processing
            - completed
            - completed_with_failures
        files_total:
          type: integer
        files_completed:
          type: integer
        files_failed:
          type: integer
        created_at:
          type: integer
          description: Unix timestamp in milliseconds
      required:
        - attachment_id
        - criterion_name
        - criterion_hash
        - backfill_status
    Error:
      required:
        - error
      type: object
      properties:
        error:
          type: string
    MomentCriterion:
      type: object
      description: >-
        An inline criterion: rubric instructions plus typed output declarations.
        Snapshotted and hashed onto the run.
      properties:
        name:
          type: string
          pattern: ^[a-z][a-z0-9_]*$
          maxLength: 64
        instructions:
          type: string
          minLength: 1
          description: The complete rubric, including any seed lists and worked examples.
        moment_schema:
          $ref: '#/components/schemas/MomentSchemaDefinition'
        finding_schema:
          $ref: '#/components/schemas/MomentSchemaDefinition'
        anchors:
          type: object
          description: >-
            Named intra-moment timestamps. A non-required anchor that does not
            exist is omitted from the moment - never null.
          additionalProperties:
            type: object
            properties:
              required:
                type: boolean
              description:
                type: string
        scoring:
          type: object
          description: >-
            The rubric's single canonical score: what rank-ordered reads sort by
            and what min_score filters on. Exactly one scoring key per
            criterion.
          properties:
            key:
              type: string
            min:
              type: number
            max:
              type: number
            higher_is_better:
              type: boolean
            description:
              type: string
          required:
            - key
            - min
            - max
      required:
        - name
        - instructions
    MomentSchemaDefinition:
      type: object
      description: >-
        A validated JSON Schema subset (the moment schema dialect): a root
        object of string/number/integer/boolean/array-of-those fields, optional
        enums, one nesting level, per-field descriptions. Rejected shapes get a
        field-addressable 400 with a stable code.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````