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

# Create Loop



## OpenAPI

````yaml /openapi.json post /api/v1/teams/{team_id}/cycle/loops
openapi: 3.1.0
info:
  title: AITasker
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/teams/{team_id}/cycle/loops:
    post:
      tags:
        - LoopOps
      summary: Create Loop
      operationId: create_loop_api_v1_teams__team_id__cycle_loops_post
      parameters:
        - name: team_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Team Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateLoopRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkLoopResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    CreateLoopRequest:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
        agent_member_id:
          type: string
          format: uuid
          title: Agent Member Id
        phase:
          anyOf:
            - type: string
            - type: 'null'
          title: Phase
        parent_loop_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Parent Loop Id
        schedule_type:
          type: string
          enum:
            - cadence
            - specific_days
            - signal_triggered
          title: Schedule Type
          default: cadence
        cadence:
          $ref: '#/components/schemas/LoopCadence'
        task_type:
          type: string
          minLength: 1
          title: Task Type
        task_template:
          additionalProperties: true
          type: object
          title: Task Template
        priority:
          type: string
          enum:
            - critical
            - high
            - medium
            - low
          title: Priority
          default: medium
        sort_order:
          type: integer
          title: Sort Order
          default: 0
        content_source:
          anyOf:
            - $ref: '#/components/schemas/ContentSourceConfig'
            - type: 'null'
      type: object
      required:
        - name
        - agent_member_id
        - task_type
      title: CreateLoopRequest
    WorkLoopResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        cycle_id:
          type: string
          format: uuid
          title: Cycle Id
        parent_loop_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Parent Loop Id
        name:
          type: string
          title: Name
        agent_member_id:
          type: string
          format: uuid
          title: Agent Member Id
        phase:
          anyOf:
            - type: string
            - type: 'null'
          title: Phase
        schedule_type:
          type: string
          title: Schedule Type
        cadence:
          additionalProperties: true
          type: object
          title: Cadence
        task_type:
          type: string
          title: Task Type
        task_template:
          additionalProperties: true
          type: object
          title: Task Template
        priority:
          type: string
          title: Priority
        sort_order:
          type: integer
          title: Sort Order
        is_active:
          type: boolean
          title: Is Active
        content_source:
          anyOf:
            - $ref: '#/components/schemas/ContentSourceConfig'
            - type: 'null'
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - id
        - cycle_id
        - parent_loop_id
        - name
        - agent_member_id
        - phase
        - schedule_type
        - cadence
        - task_type
        - task_template
        - priority
        - sort_order
        - is_active
        - created_at
        - updated_at
      title: WorkLoopResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    LoopCadence:
      properties:
        every_n_days:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Every N Days
          description: Repeat every N days
        days:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Days
          description: Specific days within cycle (1-indexed)
        time:
          type: string
          pattern: ^\d{2}:\d{2}$
          title: Time
          description: HH:MM in cycle timezone
          default: '09:00'
      type: object
      title: LoopCadence
    ContentSourceConfig:
      properties:
        source_url:
          type: string
          maxLength: 2048
          minLength: 1
          title: Source Url
        source_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Type
        include_tags:
          items:
            type: string
          type: array
          title: Include Tags
        exclude_tags:
          items:
            type: string
          type: array
          title: Exclude Tags
        max_age_days:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Max Age Days
      type: object
      required:
        - source_url
      title: ContentSourceConfig
      description: >-
        Per-loop content-driven source config (SMMT content-driven
        distribution).


        Typed (not a raw dict) so malformed payloads are rejected at the API

        boundary with a 422 rather than persisting silently and never
        dispatching:

        ``cycle_scheduler._loop_content_source()`` only treats a loop as

        content-driven when ``content_source`` is a dict carrying a non-blank

        ``source_url``, so an invalid value would look "saved" but quietly stop

        distribution. ``source_type`` is auto-detected at scan time; tag/recency

        rules are consumed by ``content_source_scanner.pick_next_item``.
    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
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````