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

# Create a label version

> Compiles `text` (single-label DSL) and publishes an immutable version under the label. There is no current/live version: evaluation always uses an explicit version ID. There is no PATCH or DELETE for versions.



## OpenAPI

````yaml /openapi.json post /v1/labels/{labelId}/versions
openapi: 3.0.0
info:
  title: Clavata Public API v1
  description: Endpoints for creating and managing jobs via the Clavata Public API.
  version: 1.0.0
  contact:
    name: Clavata.ai
    url: https://clavata.ai
    email: support@clavata.ai
servers:
  - url: https://gateway.app.clavata.ai:8443
security:
  - Bearer_Token: []
tags:
  - name: Public API
    description: Endpoints for creating and managing jobs via the Clavata Public API.
paths:
  /v1/labels/{labelId}/versions:
    post:
      tags:
        - Labels
      summary: Create a label version
      description: >-
        Compiles `text` (single-label DSL) and publishes an immutable version
        under the label. There is no current/live version: evaluation always
        uses an explicit version ID. There is no PATCH or DELETE for versions.
      operationId: LabelsService_CreateLabelVersion
      parameters:
        - name: labelId
          description: The label ID this version belongs to
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LabelsServiceCreateLabelVersionBody'
        required: true
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1CreateLabelVersionResponse'
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/rpcStatus'
components:
  schemas:
    LabelsServiceCreateLabelVersionBody:
      type: object
      properties:
        text:
          type: string
          title: 'Required: single-label DSL text'
        description:
          type: string
          description: Optional description for this version.
        parentLabelVersionId:
          type: string
          description: Optional explicit parent/source version for lineage tracking.
        labelEvalOptions:
          $ref: '#/components/schemas/v1LabelEvalOptions'
        globalContext:
          type: string
          description: Optional global context to store on the created label version.
        confirmDuplicate:
          type: boolean
          description: |-
            If true, bypass the duplicate-content check. Used by clients to
            re-submit after the user has acknowledged a `duplicate_of` response.
    v1CreateLabelVersionResponse:
      type: object
      properties:
        valid:
          type: boolean
          title: Whether compilation succeeded
        error:
          $ref: '#/components/schemas/v1CompilationError'
        labelVersion:
          $ref: '#/components/schemas/v1LabelVersion'
        duplicateOf:
          $ref: '#/components/schemas/v1LabelVersion'
    rpcStatus:
      type: object
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/protobufAny'
    v1LabelEvalOptions:
      type: object
      properties:
        bypassCache:
          type: boolean
          title: Whether to bypass the query cache during evaluation
        expedited:
          type: boolean
          title: Whether to use expedited evaluation (prioritizing speed over cost)
        bundleSize:
          type: integer
          format: int64
          title: The bundle size to use for query batching in Hermes
        threshold:
          type: number
          format: double
          title: The threshold to use for determining truthiness
        stack:
          type: string
          title: >-
            The stack name to use for evaluation (overrides default stack in
            Hermes)
        imageDetailLevel:
          $ref: '#/components/schemas/v1ImageDetailLevel'
      description: >-
        LabelEvalOptions are options that can be set per-label to control
        evaluation behavior.

        Field numbers/types intentionally mirror PolicyEvalOptions for parity.
    v1CompilationError:
      type: object
      properties:
        message:
          type: string
          title: The error message
        line:
          type: integer
          format: int32
          title: The line number of the error
        column:
          type: integer
          format: int32
          title: The column number of the error
    v1LabelVersion:
      type: object
      properties:
        labelVersionId:
          type: string
          title: The label version ID as set in the database
        labelId:
          type: string
          title: The label ID this version belongs to
        text:
          type: string
          title: The single-label DSL text for this version
        blob:
          type: string
          format: byte
          title: >-
            Optional compiled representation blob (typically omitted from
            customer-facing responses)
        description:
          type: string
          title: Optional description for this version
        signalCount:
          type: integer
          format: int64
          title: Number of signals in this version (complexity metric)
        totalSignalTokens:
          type: integer
          format: int64
          title: Total signal tokens in this version (complexity metric)
        created:
          type: string
          format: date-time
          title: Time the version was created
        expunged:
          type: boolean
          title: If the version is soft-deleted, this is set to true
        createdById:
          type: string
          title: The user ID who created this version
        sequentialVersion:
          type: integer
          format: int32
          title: Sequential version number (v1=1, v2=2, etc.) based on creation order
        parentLabelVersionId:
          type: string
          title: >-
            The parent version this was created from/based on (nil for first
            version or when lineage is unknown)
        complexityScore:
          type: number
          format: float
          title: Complexity score of the label version
        labelEvalOptions:
          $ref: '#/components/schemas/v1LabelEvalOptions'
        globalContext:
          type: string
          description: >-
            Optional global context to inject into LLM context window during
            evaluation.

            This provides additional context about the nature of content being
            evaluated.
        tokenCountsV2:
          $ref: '#/components/schemas/v1TokenCountsV2'
      description: >-
        LabelVersion is an immutable snapshot of a label's DSL + compiled
        representation.
    protobufAny:
      type: object
      properties:
        '@type':
          type: string
      additionalProperties: {}
    v1ImageDetailLevel:
      type: string
      enum:
        - IMAGE_DETAIL_LEVEL_UNSPECIFIED
        - IMAGE_DETAIL_LEVEL_VERY_LOW
        - IMAGE_DETAIL_LEVEL_LOW
        - IMAGE_DETAIL_LEVEL_MEDIUM
        - IMAGE_DETAIL_LEVEL_HIGH
        - IMAGE_DETAIL_LEVEL_VERY_HIGH
      default: IMAGE_DETAIL_LEVEL_UNSPECIFIED
      description: >-
        ImageDetailLevel selects how much image detail is preserved when images
        are

        evaluated. Levels are semantic; the selected extractor's vision encoder
        maps

        each level to a model-specific token budget. Unspecified preserves the

        extractor's configured default.
    v1TokenCountsV2:
      type: object
      properties:
        dslTokenCount:
          type: integer
          format: int64
          description: V2 DSL-only token count for display.
        globalContextTokens:
          type: integer
          format: int64
          description: V2 token count for the saved global context.
        signalTokens:
          type: integer
          format: int64
          description: V2 token count for formatted DSL signals.
        signalSpecialTokens:
          type: integer
          format: int64
          description: V2 token count for DSL prompt special/structural tokens.
        contentSpecialTokens:
          type: integer
          format: int64
          description: V2 token count for content prompt special/structural tokens.
      description: >-
        TokenCountsV2 groups the static V2 token counts saved alongside a policy
        version,

        label version, or user label draft. The counts are calculated together,
        so message

        presence signals that V2 accounting is available for the saved DSL.
  securitySchemes:
    Bearer_Token:
      type: http
      scheme: bearer
      bearerFormat: JWT

````