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

# Edit Draft

> Direct draft edit (frontend editGoal/editRule/editSchema/
toggleCheckBlocking — S2): applies immediately, appends a user
``artifact_edit`` event, and ticks the brain. It NEVER consumes the
pending question/diff card — direct edits and card decisions are
independent.



## OpenAPI

````yaml https://www.datalab.to/openapi.json post /api/v1/agent-studio/sessions/{session_id}/draft
openapi: 3.1.0
info:
  title: Datalab API
  version: 0.0.1
servers:
  - url: https://www.datalab.to
    description: Datalab API
security: []
paths:
  /api/v1/agent-studio/sessions/{session_id}/draft:
    post:
      tags:
        - agent-studio
      summary: Edit Draft
      description: |-
        Direct draft edit (frontend editGoal/editRule/editSchema/
        toggleCheckBlocking — S2): applies immediately, appends a user
        ``artifact_edit`` event, and ticks the brain. It NEVER consumes the
        pending question/diff card — direct edits and card decisions are
        independent.
      operationId: edit_draft_api_v1_agent_studio_sessions__session_id__draft_post
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: integer
            title: Session Id
        - name: wos-session
          in: cookie
          required: false
          schema:
            type: string
            title: Wos-Session
        - name: datalab_active_team
          in: cookie
          required: false
          schema:
            type: string
            title: Datalab Active Team
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DraftEditRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DraftEditResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    DraftEditRequest:
      properties:
        op:
          type: string
          enum:
            - goal
            - rule
            - schema
            - check_blocking
          title: Op
        text:
          anyOf:
            - type: string
              maxLength: 100000
            - type: 'null'
          title: Text
          description: >-
            New goal text (op=goal), rule text (op=rule), or schema source text
            (op=schema).
        rule_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Rule Id
          description: Required for op=rule.
        check_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Check Id
          description: Required for op=check_blocking.
      type: object
      required:
        - op
      title: DraftEditRequest
      description: |-
        One direct draft edit (frontend SessionEngineApi: editGoal / editRule /
        editSchema / toggleCheckBlocking). S2 semantics: the edit applies
        immediately, appends a user ``artifact_edit`` event, and ticks the brain
        — it never consumes the pending question/diff card.
    DraftEditResponse:
      properties:
        event:
          $ref: '#/components/schemas/SessionEventResponse'
        draft_contract:
          $ref: '#/components/schemas/ContractModel'
        draft_checks:
          items:
            $ref: '#/components/schemas/CheckSpecModel'
          type: array
          title: Draft Checks
      type: object
      required:
        - event
        - draft_contract
      title: DraftEditResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SessionEventResponse:
      properties:
        id:
          type: integer
          title: Id
        seq:
          type: integer
          title: Seq
        ts:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Ts
        kind:
          type: string
          title: Kind
        actor:
          type: string
          enum:
            - user
            - agent
            - system
          title: Actor
        text:
          anyOf:
            - type: string
            - type: 'null'
          title: Text
          description: Convenience copy of payload.text when present.
        payload:
          additionalProperties: true
          type: object
          title: Payload
        refs:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Refs
      type: object
      required:
        - id
        - seq
        - kind
        - actor
      title: SessionEventResponse
    ContractModel:
      properties:
        goal:
          type: string
          title: Goal
        output_shape:
          type: string
          enum:
            - parse
            - json
            - jats
            - wcag
            - segment
          title: Output Shape
        output_schema:
          anyOf:
            - type: string
            - type: 'null'
          title: Output Schema
        rules:
          items:
            $ref: '#/components/schemas/RuleFragmentModel'
          type: array
          title: Rules
        parse_params:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Parse Params
        knobs:
          anyOf:
            - $ref: '#/components/schemas/KnobsModel'
            - type: 'null'
      type: object
      required:
        - goal
        - output_shape
      title: ContractModel
      description: The freezable record a version snapshots (contract JSONB).
    CheckSpecModel:
      properties:
        id:
          type: string
          title: Id
        label:
          type: string
          title: Label
        description:
          type: string
          title: Description
          default: ''
        kind:
          type: string
          enum:
            - code
            - judge
          title: Kind
        blocking:
          type: boolean
          title: Blocking
          default: false
        source:
          type: string
          enum:
            - base
            - catalog
            - user
          title: Source
          default: base
        modified_from_base:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Modified From Base
      type: object
      required:
        - id
        - label
        - kind
      title: CheckSpecModel
      description: One verifier in the contract (frontend CheckSpec, snake_case).
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    RuleFragmentModel:
      properties:
        id:
          type: string
          title: Id
        text:
          type: string
          title: Text
        source:
          type: string
          enum:
            - base
            - agent
            - user
          title: Source
          default: user
      type: object
      required:
        - id
        - text
      title: RuleFragmentModel
    KnobsModel:
      properties:
        max_turns:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Max Turns
        timeout_s:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Timeout S
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
      type: object
      title: KnobsModel
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key

````