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

# Create a questionnaire (protocol run)

> Schedules a new questionnaire within an existing enrollment. Requires role admin or coordinator.




## OpenAPI

````yaml /openapi/openapi-olivia-en.yaml post /v1/protocol-runs
openapi: 3.1.0
info:
  title: OlivIA API
  version: 0.1.0
  description: >
    OlivIA external API — Omniloy's clinical voice follow-up platform. It lets
    an external system (EHR/HIS, CRM, or your own backend):

    - Follow-up (outbound calls): enroll patients in a protocol so OlivIA calls
    them to complete a questionnaire.

    - Triage (inbound calls): results of triage calls are read through these
    same read endpoints.

    - Read results: questionnaires (protocol runs), answers, score, calls,
    transcript, and recording.

    Authentication uses a personal API key as a bearer token (`Authorization:
    Bearer oc_sk_...`). All routes are under the `/v1` prefix and responses wrap
    the payload in `data`.
servers:
  - url: https://{your-prod-endpoint}
    description: Production
    variables:
      your-prod-endpoint:
        default: your-prod-endpoint
        description: Replace this value with the real host before trying a request.
  - url: https://{your-dev-endpoint}
    description: Staging
    variables:
      your-dev-endpoint:
        default: your-dev-endpoint
        description: Replace this value with your staging host.
security:
  - bearerAuth: []
tags:
  - name: Protocols
    description: Read and archive protocols.
  - name: Enrollments
    description: Enroll patients and read enrollments (outbound follow-up).
  - name: Protocol Runs
    description: Protocol runs (questionnaire executions) and their results.
  - name: Calls
    description: Call detail, transcript, and recording.
paths:
  /v1/protocol-runs:
    post:
      tags:
        - Protocol Runs
      summary: Create a questionnaire (protocol run)
      description: >
        Schedules a new questionnaire within an existing enrollment. Requires
        role admin or coordinator.
      operationId: create-protocol-run
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateProtocolRunRequest'
      responses:
        '201':
          description: Questionnaire created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProtocolRunResponse'
        '400':
          $ref: '#/components/responses/ValidationError'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    CreateProtocolRunRequest:
      type: object
      required:
        - enrollment_id
        - scheduled_at
      properties:
        enrollment_id:
          type: string
          format: uuid
        scheduled_at:
          type: string
          format: date-time
        language:
          type: string
        custom_variable_values:
          type: object
          additionalProperties: true
    ProtocolRunResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/ProtocolRun'
    ProtocolRun:
      type: object
      properties:
        id:
          type: string
          format: uuid
        org_id:
          type: string
          format: uuid
        enrollment_id:
          type: string
          format: uuid
        protocol_version_id:
          type: string
          format: uuid
        sequence_number:
          type: integer
        scheduled_at:
          type: string
          format: date-time
          nullable: true
        started_at:
          type: string
          format: date-time
          nullable: true
        ended_at:
          type: string
          format: date-time
          nullable: true
        questionnaire_status:
          type: string
          enum:
            - pending
            - in_progress
            - completed
            - rejected
            - call_failed
            - wrong_number
            - no_answer
            - unresolved
            - cancelled
        language:
          type: string
        reviewed_at:
          type: string
          format: date-time
          nullable: true
        review_note:
          type: string
          nullable: true
        score:
          type: number
          nullable: true
        score_class:
          type: string
          nullable: true
        origin:
          type: string
          enum:
            - dispatcher_scheduled
            - manual
            - voice_initiated
            - external_api
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            details: {}
  responses:
    ValidationError:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The key lacks the required role
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: oc_sk_ API key

````