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

# List a rule's versions



## OpenAPI

````yaml api-reference/doc-tool/ipd-api/protocol-openapi.json get /protocol/workflow/rules/{id}/versions
openapi: 3.1.0
info:
  title: Eka Protocol API
  version: '1.0'
  description: >-
    Hospital workflows for IPD: rules, the tasks they create, and the forms
    filled on an admission.
servers:
  - description: Production
    url: https://api.eka.care
  - description: Stage/Sandbox
    url: https://api.dev.eka.care
security: []
tags:
  - name: Tasks
    description: >-
      Workflow tasks at a hospital. Rules create them; users claim, release,
      complete and cancel them here. Task documents are also readable live from
      Firestore (`protocol/{bid}/tasks`) through `@orbi/protocol-sdk`; every
      change goes through this API.
  - name: Forms
    description: >-
      Forms filled on an entity (today: an admission, the IPD Forms tab) and
      what happened to each.
  - name: Rules
    description: >-
      Hospital workflow rules: events → conditions → tasks. Each save is a new
      version, compiled to a workflow.
  - name: Catalog
    description: The events and fields rules are written against.
  - name: Events
    description: 'Fire an event for a scope: every active rule on it starts a run.'
  - name: SA forms
    description: >-
      The hospital's SA forms (its own and the system ones), with versions and
      archiving.
  - name: SA form drafts
    description: SA forms saved before they are ready. Not offered in IPD until published.
  - name: AI drafts
    description: Draft an SA form from a prompt or a file with AI.
paths:
  /protocol/workflow/rules/{id}/versions:
    get:
      tags:
        - Rules
      summary: List a rule's versions
      operationId: getRulesIdVersions
      parameters:
        - name: auth
          in: header
          required: true
          description: >-
            The access token. The gateway verifies it and passes the user and
            the business on.
          schema:
            type: string
        - name: id
          in: path
          required: true
          schema:
            type: string
            pattern: ^rl_[a-z0-9]+_[a-f0-9]+$
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    const: success
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/RuleVersion'
                required:
                  - status
                  - data
        '401':
          description: No signed-in user, or no business on the session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: The request failed validation; `details` names each invalid path.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    RuleVersion:
      type: object
      properties:
        _id:
          type: string
        bid:
          type: string
        rule_id:
          type: string
        version:
          type: number
        source:
          $ref: '#/components/schemas/RuleSource'
        conductor_json:
          $ref: '#/components/schemas/WorkflowDef'
        changes:
          type: array
          items:
            type: string
        saved_by:
          $ref: '#/components/schemas/Actor'
        created_by:
          type: string
        created_at:
          type: string
          format: date-time
      required:
        - _id
        - bid
        - rule_id
        - version
        - source
        - conductor_json
        - changes
        - saved_by
        - created_by
        - created_at
    Error:
      type: object
      properties:
        status:
          type: string
          const: error
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  path:
                    type: string
                  message:
                    type: string
                required:
                  - path
                  - message
          required:
            - code
            - message
      required:
        - status
        - error
    RuleSource:
      type: object
      properties:
        scope_type:
          type: string
          enum:
            - ADMISSION
            - DISCHARGE
            - APPOINTMENT
            - PRESCRIPTION
            - PATIENT
        events:
          type: array
          items:
            type: string
        name:
          type: string
        description:
          anyOf:
            - type: string
            - type: 'null'
        conditions:
          anyOf:
            - anyOf:
                - $ref: '#/components/schemas/Leaf'
                - type: object
                  properties:
                    all:
                      type: array
                      items:
                        $ref: '#/components/schemas/ConditionNode'
                  required:
                    - all
                - type: object
                  properties:
                    any:
                      type: array
                      items:
                        $ref: '#/components/schemas/ConditionNode'
                  required:
                    - any
            - type: 'null'
        tasks:
          type: array
          items:
            $ref: '#/components/schemas/TaskSpec'
      required:
        - scope_type
        - events
        - name
        - conditions
        - tasks
    WorkflowDef:
      type: object
      properties:
        name:
          type: string
        version:
          type: number
        ownerEmail:
          type: string
        description:
          type: string
        schemaVersion:
          type: number
          const: 2
        restartable:
          type: boolean
        timeoutSeconds:
          type: number
        inputParameters:
          type: array
          items:
            type: string
        tasks:
          type: array
          items:
            $ref: '#/components/schemas/WorkflowTask'
        outputParameters:
          type: object
          properties: {}
          additionalProperties:
            type: string
      required:
        - name
        - version
        - ownerEmail
        - description
        - schemaVersion
        - restartable
        - timeoutSeconds
        - inputParameters
        - tasks
        - outputParameters
    Actor:
      type: object
      properties:
        oid:
          type: string
        name:
          type: string
        ps:
          type: string
          enum:
            - D
            - S
            - AD
            - SYSTEM
        s:
          type: string
      required:
        - oid
        - name
        - ps
        - s
    Leaf:
      type: object
      properties:
        field:
          type: string
        op:
          type: string
          enum:
            - equal
            - notEqual
            - lessThan
            - lessThanInclusive
            - greaterThan
            - greaterThanInclusive
            - in
            - notIn
            - contains
        value:
          $ref: '#/components/schemas/LeafValue'
      required:
        - field
        - op
        - value
    ConditionNode:
      anyOf:
        - $ref: '#/components/schemas/Leaf'
        - type: object
          properties:
            all:
              type: array
              items:
                $ref: '#/components/schemas/ConditionNode'
          required:
            - all
        - type: object
          properties:
            any:
              type: array
              items:
                $ref: '#/components/schemas/ConditionNode'
          required:
            - any
    TaskSpec:
      type: object
      properties:
        task_type:
          type: string
          enum:
            - VITALS
            - DOCTOR_NOTES
            - NURSING_NOTES
            - MEDICAL_HISTORY
            - EMAR_MEDICATION_DOSE
            - FORM
        form_kind:
          type: string
          enum:
            - SA
            - CONSENT
            - MCERT
        sa_id:
          type: string
        template_id:
          type: string
        title:
          type: string
        description:
          type: string
        payload:
          $ref: '#/components/schemas/JsonObject'
        requiredness:
          type: string
          enum:
            - MANDATORY
            - OPTIONAL
        blocking:
          type: boolean
        audience_keys:
          anyOf:
            - type: array
              items:
                type: string
            - type: 'null'
        estimate:
          type: string
        delay:
          type: string
        every:
          type: string
        due_in:
          type: string
        escalation:
          anyOf:
            - $ref: '#/components/schemas/Escalation'
            - type: 'null'
      required:
        - task_type
    WorkflowTask:
      anyOf:
        - $ref: '#/components/schemas/SimpleTask'
        - $ref: '#/components/schemas/WaitTask'
        - $ref: '#/components/schemas/SwitchTask'
        - $ref: '#/components/schemas/ForkJoinTask'
        - $ref: '#/components/schemas/JoinTask'
        - $ref: '#/components/schemas/DoWhileTask'
        - $ref: '#/components/schemas/StartWorkflowTask'
    LeafValue:
      anyOf:
        - anyOf:
            - type: string
            - type: number
            - type: boolean
              const: false
            - type: boolean
              const: true
            - type: array
              items:
                anyOf:
                  - type: string
                  - type: number
        - type: 'null'
    JsonObject:
      type: object
      properties: {}
      additionalProperties:
        $ref: '#/components/schemas/Json'
    Escalation:
      type: object
      properties:
        after:
          type: string
        audience_keys:
          type: array
          items:
            type: string
        title:
          type: string
      required:
        - after
        - audience_keys
    SimpleTask:
      type: object
      properties:
        name:
          type: string
        taskReferenceName:
          type: string
        optional:
          type: boolean
        type:
          type: string
          const: SIMPLE
        inputParameters:
          anyOf:
            - $ref: '#/components/schemas/RunTaskInput'
            - $ref: '#/components/schemas/RunScheduleInput'
            - $ref: '#/components/schemas/TaskRefInput'
            - $ref: '#/components/schemas/ScheduleRefInput'
      required:
        - name
        - taskReferenceName
        - type
        - inputParameters
    WaitTask:
      type: object
      properties:
        name:
          type: string
        taskReferenceName:
          type: string
        optional:
          type: boolean
        type:
          type: string
          const: WAIT
        inputParameters:
          type: object
          properties:
            duration:
              type: string
          required:
            - duration
      required:
        - name
        - taskReferenceName
        - type
        - inputParameters
    SwitchTask:
      type: object
      properties:
        name:
          type: string
        taskReferenceName:
          type: string
        optional:
          type: boolean
        type:
          type: string
          const: SWITCH
        evaluatorType:
          type: string
          enum:
            - javascript
            - value-param
        expression:
          type: string
        inputParameters:
          type: object
          properties: {}
          additionalProperties:
            type: string
        decisionCases:
          type: object
          properties: {}
          additionalProperties:
            type: array
            items:
              $ref: '#/components/schemas/WorkflowTask'
        defaultCase:
          type: array
          items:
            $ref: '#/components/schemas/WorkflowTask'
      required:
        - name
        - taskReferenceName
        - type
        - evaluatorType
        - expression
        - inputParameters
        - decisionCases
        - defaultCase
    ForkJoinTask:
      type: object
      properties:
        name:
          type: string
        taskReferenceName:
          type: string
        optional:
          type: boolean
        type:
          type: string
          const: FORK_JOIN
        forkTasks:
          type: array
          items:
            type: array
            items:
              $ref: '#/components/schemas/WorkflowTask'
      required:
        - name
        - taskReferenceName
        - type
        - forkTasks
    JoinTask:
      type: object
      properties:
        name:
          type: string
        taskReferenceName:
          type: string
        optional:
          type: boolean
        type:
          type: string
          const: JOIN
        joinOn:
          type: array
          items:
            type: string
      required:
        - name
        - taskReferenceName
        - type
        - joinOn
    DoWhileTask:
      type: object
      properties:
        name:
          type: string
        taskReferenceName:
          type: string
        optional:
          type: boolean
        type:
          type: string
          const: DO_WHILE
        inputParameters:
          type: object
          properties: {}
          additionalProperties:
            type: string
        loopCondition:
          type: string
        loopOver:
          type: array
          items:
            $ref: '#/components/schemas/WorkflowTask'
      required:
        - name
        - taskReferenceName
        - type
        - inputParameters
        - loopCondition
        - loopOver
    StartWorkflowTask:
      type: object
      properties:
        name:
          type: string
        taskReferenceName:
          type: string
        optional:
          type: boolean
        type:
          type: string
          const: START_WORKFLOW
        inputParameters:
          type: object
          properties:
            startWorkflow:
              type: object
              properties:
                name:
                  type: string
                version:
                  type: number
                correlationId:
                  type: string
                input:
                  anyOf:
                    - $ref: '#/components/schemas/ScheduleRefInput'
                    - $ref: '#/components/schemas/DeadlineInput'
              required:
                - name
                - version
                - input
          required:
            - startWorkflow
      required:
        - name
        - taskReferenceName
        - type
        - inputParameters
    Json:
      anyOf:
        - anyOf:
            - type: string
            - type: number
            - type: boolean
              const: false
            - type: boolean
              const: true
            - $ref: '#/components/schemas/JsonObject'
            - type: array
              items:
                $ref: '#/components/schemas/Json'
        - type: 'null'
    RunTaskInput:
      type: object
      properties:
        bid:
          type: string
        rule_id:
          type: string
        event:
          type: string
        scope:
          type: string
        facts:
          type: string
        rule_version:
          anyOf:
            - type: string
            - type: number
        kind:
          type: string
        run_id:
          type: string
        index:
          type: number
        task:
          anyOf:
            - type: string
            - type: object
              properties:
                task_type:
                  type: string
                  enum:
                    - VITALS
                    - DOCTOR_NOTES
                    - NURSING_NOTES
                    - MEDICAL_HISTORY
                    - EMAR_MEDICATION_DOSE
                    - FORM
                form_kind:
                  type: string
                  enum:
                    - SA
                    - CONSENT
                    - MCERT
                sa_id:
                  type: string
                template_id:
                  type: string
                title:
                  type: string
                description:
                  type: string
                payload:
                  $ref: '#/components/schemas/JsonObject'
                requiredness:
                  type: string
                  enum:
                    - MANDATORY
                    - OPTIONAL
                blocking:
                  type: boolean
                audience_keys:
                  anyOf:
                    - type: array
                      items:
                        type: string
                    - type: 'null'
                estimate:
                  type: string
                due_in:
                  type: string
                escalation:
                  anyOf:
                    - $ref: '#/components/schemas/Escalation'
                    - type: 'null'
              required:
                - task_type
        delayed:
          type: boolean
        iteration:
          type: string
      required:
        - bid
        - rule_id
        - event
        - scope
        - facts
        - rule_version
        - run_id
        - index
        - task
    RunScheduleInput:
      type: object
      properties:
        bid:
          type: string
        rule_id:
          type: string
        event:
          type: string
        scope:
          type: string
        facts:
          type: string
        rule_version:
          anyOf:
            - type: string
            - type: number
        kind:
          type: string
        run_id:
          type: string
        index:
          type: number
        task:
          anyOf:
            - type: string
            - type: object
              properties:
                task_type:
                  type: string
                  enum:
                    - VITALS
                    - DOCTOR_NOTES
                    - NURSING_NOTES
                    - MEDICAL_HISTORY
                    - EMAR_MEDICATION_DOSE
                    - FORM
                form_kind:
                  type: string
                  enum:
                    - SA
                    - CONSENT
                    - MCERT
                sa_id:
                  type: string
                template_id:
                  type: string
                title:
                  type: string
                description:
                  type: string
                payload:
                  $ref: '#/components/schemas/JsonObject'
                requiredness:
                  type: string
                  enum:
                    - MANDATORY
                    - OPTIONAL
                blocking:
                  type: boolean
                audience_keys:
                  anyOf:
                    - type: array
                      items:
                        type: string
                    - type: 'null'
                estimate:
                  type: string
                due_in:
                  type: string
                escalation:
                  anyOf:
                    - $ref: '#/components/schemas/Escalation'
                    - type: 'null'
              required:
                - task_type
        delayed:
          type: boolean
        iteration:
          type: string
        every:
          type: string
        first:
          type: string
          enum:
            - now
            - after
      required:
        - bid
        - rule_id
        - event
        - scope
        - facts
        - rule_version
        - run_id
        - index
        - task
        - every
        - first
    TaskRefInput:
      type: object
      properties:
        bid:
          type: string
        task_id:
          type: string
      required:
        - bid
        - task_id
    ScheduleRefInput:
      type: object
      properties:
        bid:
          type: string
        run_id:
          type: string
        index:
          anyOf:
            - type: string
            - type: number
      required:
        - bid
        - run_id
        - index
    DeadlineInput:
      type: object
      properties:
        bid:
          type: string
        task_id:
          type: string
        due_in:
          type: string
        grace:
          type: string
      required:
        - bid
        - task_id
        - due_in
        - grace

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.