openapi: 3.0.0
info:
  version: '0.0'
  title: Qomon
  description: |-
    This is Qomon's API definition.

    To get an authorization go to [Qomon's setting page](https://qomon.app/settings/extensions/connect) and create an API key.
servers:
  - description: Qomon production
    url: https://qomon.app/api
  - description: Qomon integration
    url: https://test.quorumapps.com/api
  - description: Qomon local
    url: http://localhost:8080

tags:
  - name: Forms settings
    description: Setup all kind of forms
  - name: Survey

paths:
  /form:
    post:
      tags:
        - Forms settings
      summary: Create a new form
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    form:
                      $ref: '#/components/schemas/Form'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      form:
                        $ref: '#/components/schemas/Form'
  /forms/name/{name}:
    get:
      tags:
        - Forms settings
      summary: Get form names
      parameters:
        - name: name
          in: path
          required: true
          description: Form name
          schema:
            type: string
            enum:
              - STATIC
              - ACTION
              - STATUS
              - FORM
              - CONSENT
              - BRIEF
              - ISSUE
              - CUSTOM
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      forms:
                        type: array
                        items:
                          $ref: '#/components/schemas/Form'
  /forms/names/{name}:
    patch:
      tags:
        - Forms settings
      summary: Update form name
      parameters:
        - name: name
          in: path
          required: true
          description: Form name
          schema:
            type: string
            enum:
              - STATIC
              - ACTION
              - STATUS
              - FORM
              - CONSENT
              - BRIEF
              - ISSUE
              - CUSTOM
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    forms:
                      type: array
                      items:
                        $ref: '#/components/schemas/Form'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      forms:
                        type: array
                        items:
                          $ref: '#/components/schemas/Form'
  /forms/type/{type}:
    get:
      tags:
        - Forms settings
      summary: Get form types
      parameters:
        - name: type
          in: path
          required: true
          description: Form type
          schema:
            type: string
            enum:
              - radio
              - checkbox
              - date
              - report
              - meet
              - text
              - signature
              - photos
              - numeric
              - range
              - other
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      forms:
                        type: array
                        items:
                          $ref: '#/components/schemas/Form'
  /forms/type/{type}/name/{name}:
    get:
      tags:
        - Forms settings
      summary: Get by type and name
      parameters:
        - name: type
          in: path
          required: true
          description: Form type
          schema:
            type: string
            enum:
              - radio
              - checkbox
              - date
              - report
              - meet
              - text
              - signature
              - photos
              - numeric
              - range
              - other
        - name: name
          in: path
          required: true
          description: Form name
          schema:
            type: string
            enum:
              - STATIC
              - ACTION
              - STATUS
              - FORM
              - CONSENT
              - BRIEF
              - ISSUE
              - CUSTOM
              - name_presence
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      forms:
                        type: array
                        items:
                          $ref: '#/components/schemas/Form'
  /forms/name/CUSTOM/candelete:
    get:
      tags:
        - Forms settings
      summary: Verify if a custom form can be deleted
      parameters:
        - name: id
          in: path
          required: true
          description: Form id
          schema:
            type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      status:
                        type: string
                        example: ok
  /forms:
    get:
      tags:
        - Forms settings
      summary: Get all forms
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      forms:
                        type: array
                        items:
                          $ref: '#/components/schemas/Form'
    patch:
      tags:
        - Forms settings
      summary: Update all forms
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
    post:
      tags:
        - Forms settings
      summary: Save all forms
      requestBody:
        content:
          application/json:
            schema:
              type: object
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
  /forms/{formId}:
    get:
      tags:
        - Forms settings
      summary: Get form by id
      parameters:
        - name: formId
          in: path
          required: true
          description: Form id
          schema:
            type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: 'success'
                  data:
                    type: object
                    properties:
                      form:
                        $ref: '#/components/schemas/Form'
    patch:
      tags:
        - Forms settings
      summary: Update form by id
      parameters:
        - name: formId
          in: path
          required: true
          description: Form id
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    form:
                      $ref: '#/components/schemas/Form'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: 'success'
                  data:
                    type: object
                    properties:
                      form:
                        $ref: '#/components/schemas/Form'
    delete:
      tags:
        - Forms settings
      summary: Delete form by id
      parameters:
        - name: formId
          in: path
          required: true
          description: Form id
          schema:
            type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: 'success'
  /forms/{formId}/refvalues:
    get:
      tags:
        - Forms settings
      summary: Get refvalues by form id
      parameters:
        - name: formId
          in: path
          required: true
          description: Form id
          schema:
            type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: 'success'
                  data:
                    type: object
                    properties:
                      refvalues:
                        type: array
                        items:
                          $ref: '#/components/schemas/RefValue'
    post:
      tags:
        - Forms settings
      summary: Create refvalue in specific form
      parameters:
        - name: formId
          in: path
          required: true
          description: Form id
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    refvalue:
                      $ref: '#/components/schemas/RefValue'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: 'success'
                  data:
                    type: object
                    properties:
                      refvalue:
                        $ref: '#/components/schemas/RefValue'
  /forms/{formId}/refvalues/{refvalueId}:
    get:
      tags:
        - Forms settings
      summary: Get refvalue by id
      parameters:
        - name: formId
          in: path
          required: true
          description: Form id
          schema:
            type: integer
        - name: refvalueId
          in: path
          required: true
          description: Refvalue id
          schema:
            type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      refvalue:
                        $ref: '#/components/schemas/RefValue'
    patch:
      tags:
        - Forms settings
      summary: Update refvalue by id
      parameters:
        - name: formId
          in: path
          required: true
          description: Form id
          schema:
            type: integer
        - name: refvalueId
          in: path
          required: true
          description: Refvalue id
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    refvalue:
                      $ref: '#/components/schemas/RefValue'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  data:
                    type: object
                    properties:
                      refvalue:
                        $ref: '#/components/schemas/RefValue'
    delete:
      tags:
        - Forms settings
      summary: Delete refvalue by id
      parameters:
        - name: formId
          in: path
          required: true
          description: Form id
          schema:
            type: integer
        - name: refvalueId
          in: path
          required: true
          description: Refvalue id
          schema:
            type: integer
      responses:
        '204':
          description: Successfully deleted

  /forms/survey:
    get:
      tags:
        - Forms settings
      summary: Get all forms available for survey configuration
      description: |-
        Retrieves all forms that can be used in surveys.
        This is typically used when configuring which forms to include in a survey.
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: 'success'
                  data:
                    type: object
                    properties:
                      forms:
                        type: array
                        items:
                          $ref: '#/components/schemas/Form'

  /surveys:
    get:
      tags:
        - Survey
      summary: Get surveys by type
      parameters:
        - $ref: '#/components/parameters/surveyType'
        - $ref: '#/components/parameters/surveyState'
        - $ref: '#/components/parameters/showOverrideDetails'
      # - $ref: '#/components/parameters/actionId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  data:
                    type: object
                    properties:
                      surveys:
                        type: array
                        items:
                          oneOf:
                            - $ref: '#/components/schemas/Survey'
                            - $ref: '#/components/schemas/SurveyWithOverrides'
              examples:
                show_override_details true:
                  $ref: '#/components/examples/listSurveyWithDetails'
                show_override_details false:
                  $ref: '#/components/examples/listSurveyWithoutDetails'
  /surveys/usage:
    get:
      tags:
        - Survey
      summary: Get survey usage statistics
      description: |-
        Returns usage statistics for surveys including the number of ongoing actions
        and the total number of contacts reached for each survey.
      parameters:
        - $ref: '#/components/parameters/surveyType'
        - $ref: '#/components/parameters/surveyState'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  data:
                    type: object
                    properties:
                      surveys:
                        type: array
                        items:
                          $ref: '#/components/schemas/SurveyUsage'
              example:
                status: success
                data:
                  surveys:
                    - id: 58
                      usage:
                        ongoing_action_count: 4
                        contact_reach_total: 56
                    - id: 59
                      usage:
                        ongoing_action_count: 0
                        contact_reach_total: 125             
  /survey:
    get:
      tags:
        - Survey
      summary: Get default survey for the group
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  data:
                    type: object
                    properties:
                      survey:
                        $ref: '#/components/schemas/Survey'
    post:
      tags:
        - Survey
      summary: Create survey
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    survey:
                      $ref: '#/components/schemas/SurveyWithOverrides'
                  example:
                    survey:
                      name: 'Online survey'
                      forms_survey:
                        - form:
                            id: 1245
                          form_override:
                            - field: 'label'
                              value: 'Do you like this survey?'
                          refvalue_override:
                            - id: 23577
                              field: 'label'
                              value: 'Yes I do'
                            - id: 5498
                              field: 'label'
                              value: 'No I don''t'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    example: success
                    type: string
                  data:
                    type: object
                    properties:
                      survey:
                        $ref: '#/components/schemas/SurveyWithOverrides'           
  /survey/{surveyId}:
    get:
      tags:
        - Survey
      summary: Get survey
      parameters:
        - $ref: '#/components/parameters/surveyId'
        - $ref: '#/components/parameters/showOverrideDetails'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    example: success
                    type: string
                  data:
                    type: object
                    properties:
                      survey:
                        oneOf:
                          - $ref: '#/components/schemas/Survey'
                          - $ref: '#/components/schemas/SurveyWithOverrides'
              examples:
                show_override_details true:
                  $ref: '#/components/examples/surveyWithDetails'
                show_override_details false:
                  $ref: '#/components/examples/surveyWithoutDetails'
    patch:
      tags:
        - Survey
      summary: Update survey
      parameters:
        - $ref: '#/components/parameters/surveyId'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  properties:
                    survey:
                      $ref: '#/components/schemas/SurveyWithOverrides'
      responses:
        '200':
          description: Updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    example: success
                    type: string
                  data:
                    type: object
                    properties:
                      survey:
                        $ref: '#/components/schemas/SurveyWithOverrides'
    delete:
      tags:
        - Survey
      summary: Delete survey
      parameters:
        - $ref: '#/components/parameters/surveyId'
      responses:
        '204':
          description: Successfully deleted
  /survey/{surveyID}/form/{formId}:
    post:
      tags:
        - Survey
      summary: Set list of forms (and linked overrides) of a survey
      description: |-
        Update existing forms.
        Insert new forms.
        Delete forms not in the list.
      parameters:
        - $ref: '#/components/parameters/surveyId'
        - $ref: '#/components/parameters/formId'
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data: 
                  type: object
                  properties: 
                    form_survey: 
                      $ref: '#/components/schemas/FormSurvey'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    example: success
                    type: string
                  data:
                    type: object
                    properties:
                      survey:
                        $ref: '#/components/schemas/SurveyWithOverrides'
    delete:
      tags:
        - Survey
      summary: Remove form in survey
      parameters:
        - $ref: '#/components/parameters/surveyId'
        - $ref: '#/components/parameters/formId'
      responses:
        '204':
          description: Successfully deleted

components:
  parameters:
    surveyId:
      name: surveyId
      in: path
      required: true
      description: Survey id
      schema:
        type: integer
    surveyType:
      name: type
      in: query
      description: Survey type
      schema:
        type: string
        enum:
          - DEFAULT
    surveyState:
      name: state
      in: query
      description: Survey state filter
      schema:
        type: string
        enum:
          - draft
          - active
          - archived
    formId:
      name: formId
      in: path
      required: true
      description: Form id
      schema:
        type: integer
    name:
      name: name
      in: path
      required: true
      description: Form field name
      schema:
        type: string
    refvalueId:
      name: refvalueId
      in: path
      required: true
      description: Refvalue id
      schema:
        type: integer
    showOverrideDetails:
      name: show_override_details
      in: query
      description: Show override fields
      schema:
        type: boolean
  examples:
    surveyWithDetails:
      value:
        status: success
        data:
          survey:
            id: 14
            group_id: 381
            user:
              id: 12345
              firstname: "John"
              surname: "Doe"
            name: "Canvassing survey"
            state: "active"
            forms_survey:
              - form_id: 7688
                form:
                  id: 7688
                  CreatedAt: 0001-01-01T00:00:00Z
                  UpdatedAt: 2025-07-03T09:24:58.436077Z
                  name: STATIC
                  type: firstname
                  order: 1
                  label: firstname
                form_override:
                  - field: Label
                    value: What is your first name?
                  - field: Order
                    value: 1
              - form_id: 7689
                form:
                  id: 7689
                  CreatedAt: 0001-01-01T00:00:00Z
                  UpdatedAt: 2025-07-03T09:24:58.436077Z
                  name: STATIC
                  type: surname
                  order: 2
                  label: surname
                form_override:
                  - field: Label
                    value: What is your last name?
                  - field: Order
                    value: 3
              - form_id: 1234
                form:
                  id: 1234
                  name: CUSTOM
                  type: text
                  section: identity
                  order: 3
                  label: Pronouns
                  refvalues:
                    - id: 18140
                      CreatedAt: 2024-02-20T09:19:55.603479Z
                      UpdatedAt: 2025-07-03T09:24:58.629878Z
                      form_id: 1234
                      min: 0
                      order: 1
                form_override: 
                  - field: Label
                    value: What are your pronouns?
                  - field: Order
                    value: 2
              - form_id: 1236
                form:
                  id: 1236
                  CreatedAt: 0001-01-01T00:00:00Z
                  UpdatedAt: 2025-07-03T09:24:58.436077Z
                  name: CUSTOM
                  type: text
                  section: identity
                  order: 4
                  label: Job title
                  refvalues:
                    - id: 18141
                      CreatedAt: 2024-02-20T09:19:55.603479Z
                      UpdatedAt: 2025-07-03T09:24:58.629878Z
                      form_id: 1236
                      min: 0
                      order: 1
                form_override: 
                  - field: Label
                    value: What is your job title?
                  - field: Order
                    value: 4
              - form_id: 11376
                form:
                  id: 11376
                  CreatedAt: 2024-02-20T09:12:38.032682Z
                  UpdatedAt: 2025-10-06T11:57:17.702699Z
                  name: FORM
                  type: checkbox
                  section: The city and me
                  order: 5
                  label: What are the strong points of the city for you?
                  refvalues:
                    - id: 18126
                      CreatedAt: 2024-02-20T09:12:38.033661Z
                      UpdatedAt: 2025-10-06T11:57:17.703509Z
                      form_id: 11376
                      label: Public infrastructure
                      value: public_infrastructure
                      min: 0
                      order: 1
                    - id: 18127
                      CreatedAt: 2024-02-20T09:12:38.033661Z
                      UpdatedAt: 2025-10-06T11:57:17.703509Z
                      form_id: 11376
                      label: Education
                      value: education
                      min: 0
                      order: 2
                form_override:
                  - field: Order
                    value: 5
              - form_id: 11377
                form:
                  id: 11377
                  CreatedAt: 2024-02-20T09:12:38.017557Z
                  UpdatedAt: 2025-10-06T11:57:17.691264Z
                  name: FORM
                  type: range
                  section: The city and me
                  order: 1
                  label: On a scale from 1 to 10, how would you rate your satisfaction with the municipality?
                  refvalues:
                    - id: 18125
                      CreatedAt: 2024-02-20T09:12:38.020096Z
                      UpdatedAt: 2025-10-06T11:57:17.693075Z
                      form_id: 11377
                      min: 0
                      max: 10
                      step: 2
                      order: 1
                form_override:
                  - field: Order
                    value: 6
                refvalue_override:
                  - id: 18125
                    field: Max
                    value: 20
                  - id: 18125
                    field: Step
                    value: 1
    surveyWithoutDetails:
      value:
        status: success
        data:
          survey:
            id: 14
            group_id: 381
            user:
              id: 12345
              firstname: "John"
              surname: "Doe"
            name: "Canvassing survey"
            state: "active"
            forms:
              static:
                - id: 7688
                  CreatedAt: 0001-01-01T00:00:00Z
                  UpdatedAt: 2025-07-03T09:24:58.436077Z
                  name: STATIC
                  type: firstname
                  order: 1
                  label: What is your first name?
                - id: 7689
                  CreatedAt: 0001-01-01T00:00:00Z
                  UpdatedAt: 2025-07-03T09:24:58.436077Z
                  name: STATIC
                  type: surname
                  order: 3
                  label: What is your last name?
              custom:
                - id: 1234
                  name: CUSTOM
                  type: text
                  section: identity
                  order: 2
                  label: What are your pronouns?
                  refvalues:
                    - id: 18140
                      CreatedAt: 2024-02-20T09:19:55.603479Z
                      UpdatedAt: 2025-07-03T09:24:58.629878Z
                      form_id: 1234
                      min: 0
                      order: 1
                - id: 1236
                  CreatedAt: 0001-01-01T00:00:00Z
                  UpdatedAt: 2025-07-03T09:24:58.436077Z
                  name: CUSTOM
                  type: text
                  section: identity
                  order: 4
                  label: What is your job?
                  refvalues:
                    - id: 18141
                      CreatedAt: 2024-02-20T09:19:55.603479Z
                      UpdatedAt: 2025-07-03T09:24:58.629878Z
                      form_id: 1236
                      min: 0
                      order: 1
              form:
                - id: 11376
                  CreatedAt: 2024-02-20T09:12:38.032682Z
                  UpdatedAt: 2025-10-06T11:57:17.702699Z
                  name: FORM
                  type: checkbox
                  section: The city and me
                  order: 5
                  label: What are the strong points of the city for you?
                  refvalues:
                    - id: 18126
                      CreatedAt: 2024-02-20T09:12:38.033661Z
                      UpdatedAt: 2025-10-06T11:57:17.703509Z
                      form_id: 11376
                      label: Public infrastructure
                      value: public_infrastructure
                      min: 0
                      order: 1
                    - id: 18127
                      CreatedAt: 2024-02-20T09:12:38.033661Z
                      UpdatedAt: 2025-10-06T11:57:17.703509Z
                      form_id: 11376
                      label: Education
                      value: education
                      min: 0
                      order: 2
                - id: 11377
                  CreatedAt: 2024-02-20T09:12:38.017557Z
                  UpdatedAt: 2025-10-06T11:57:17.691264Z
                  name: FORM
                  type: range
                  section: The city and me
                  order: 1
                  label: On a scale from 1 to 10, how would you rate your satisfaction with the municipality?
                  refvalues:
                    - id: 18125
                      CreatedAt: 2024-02-20T09:12:38.020096Z
                      UpdatedAt: 2025-10-06T11:57:17.693075Z
                      form_id: 11377
                      min: 0
                      max: 20
                      step: 1
                      order: 1
    
    listSurveyWithDetails:
      value:
        status: success
        data:
          surveys:
            - id: 14
              group_id: 381
              user:
                id: 12345
                firstname: "John"
                surname: "Doe"
              name: "Canvassing survey"
              state: "active"
              forms_survey:
                - form_id: 7688
                  form:
                    id: 7688
                    CreatedAt: 0001-01-01T00:00:00Z
                    UpdatedAt: 2025-07-03T09:24:58.436077Z
                    name: STATIC
                    type: firstname
                    order: 1
                    label: firstname
                  form_override:
                    - field: Label
                      value: What is your first name?
                    - field: Order
                      value: 1
                - form_id: 7689
                  form:
                    id: 7689
                    CreatedAt: 0001-01-01T00:00:00Z
                    UpdatedAt: 2025-07-03T09:24:58.436077Z
                    name: STATIC
                    type: surname
                    order: 2
                    label: surname
                  form_override:
                    - field: Label
                      value: What is your last name?
                    - field: Order
                      value: 3
                - form_id: 1234
                  form:
                    id: 1234
                    name: CUSTOM
                    type: text
                    section: identity
                    order: 3
                    label: Pronouns
                    refvalues:
                      - id: 18140
                        CreatedAt: 2024-02-20T09:19:55.603479Z
                        UpdatedAt: 2025-07-03T09:24:58.629878Z
                        form_id: 1234
                        min: 0
                        order: 1
                  form_override: 
                    - field: Label
                      value: What are your pronouns?
                    - field: Order
                      value: 2
                - form_id: 1236
                  form:
                    id: 1236
                    CreatedAt: 0001-01-01T00:00:00Z
                    UpdatedAt: 2025-07-03T09:24:58.436077Z
                    name: CUSTOM
                    type: text
                    section: identity
                    order: 4
                    label: Job title
                    refvalues:
                      - id: 18141
                        CreatedAt: 2024-02-20T09:19:55.603479Z
                        UpdatedAt: 2025-07-03T09:24:58.629878Z
                        form_id: 1236
                        min: 0
                        order: 1
                  form_override: 
                    - field: Label
                      value: What is your job title?
                    - field: Order
                      value: 4
                - form_id: 11376
                  form:
                    id: 11376
                    CreatedAt: 2024-02-20T09:12:38.032682Z
                    UpdatedAt: 2025-10-06T11:57:17.702699Z
                    name: FORM
                    type: checkbox
                    section: The city and me
                    order: 5
                    label: What are the strong points of the city for you?
                    refvalues:
                      - id: 18126
                        CreatedAt: 2024-02-20T09:12:38.033661Z
                        UpdatedAt: 2025-10-06T11:57:17.703509Z
                        form_id: 11376
                        label: Public infrastructure
                        value: public_infrastructure
                        min: 0
                        order: 1
                      - id: 18127
                        CreatedAt: 2024-02-20T09:12:38.033661Z
                        UpdatedAt: 2025-10-06T11:57:17.703509Z
                        form_id: 11376
                        label: Education
                        value: education
                        min: 0
                        order: 2
                  form_override:
                    - field: Order
                      value: 5
                - form_id: 11377
                  form:
                    id: 11377
                    CreatedAt: 2024-02-20T09:12:38.017557Z
                    UpdatedAt: 2025-10-06T11:57:17.691264Z
                    name: FORM
                    type: range
                    section: The city and me
                    order: 1
                    label: On a scale from 1 to 10, how would you rate your satisfaction with the municipality?
                    refvalues:
                      - id: 18125
                        CreatedAt: 2024-02-20T09:12:38.020096Z
                        UpdatedAt: 2025-10-06T11:57:17.693075Z
                        form_id: 11377
                        min: 0
                        max: 10
                        step: 2
                        order: 1
                  form_override:
                    - field: Order
                      value: 6
                  refvalue_override:
                    - id: 18125
                      field: Max
                      value: 20
                    - id: 18125
                      field: Step
                      value: 1
    listSurveyWithoutDetails:
      value:
        status: success
        data:
          surveys:
            - id: 14
              group_id: 381
              user:
                id: 12345
                firstname: "John"
                surname: "Doe"
              name: "Canvassing survey"
              state: "active"
              forms:
                static:
                  - id: 7688
                    CreatedAt: 0001-01-01T00:00:00Z
                    UpdatedAt: 2025-07-03T09:24:58.436077Z
                    name: STATIC
                    type: firstname
                    order: 1
                    label: What is your first name?
                  - id: 7689
                    CreatedAt: 0001-01-01T00:00:00Z
                    UpdatedAt: 2025-07-03T09:24:58.436077Z
                    name: STATIC
                    type: surname
                    order: 3
                    label: What is your last name?
                custom:
                  - id: 1234
                    name: CUSTOM
                    type: text
                    section: identity
                    order: 2
                    label: What are your pronouns?
                    refvalues:
                      - id: 18140
                        CreatedAt: 2024-02-20T09:19:55.603479Z
                        UpdatedAt: 2025-07-03T09:24:58.629878Z
                        form_id: 1234
                        min: 0
                        order: 1
                  - id: 1236
                    CreatedAt: 0001-01-01T00:00:00Z
                    UpdatedAt: 2025-07-03T09:24:58.436077Z
                    name: CUSTOM
                    type: text
                    section: identity
                    order: 4
                    label: What is your job?
                    refvalues:
                      - id: 18141
                        CreatedAt: 2024-02-20T09:19:55.603479Z
                        UpdatedAt: 2025-07-03T09:24:58.629878Z
                        form_id: 1236
                        min: 0
                        order: 1
                form:
                  - id: 11376
                    CreatedAt: 2024-02-20T09:12:38.032682Z
                    UpdatedAt: 2025-10-06T11:57:17.702699Z
                    name: FORM
                    type: checkbox
                    section: The city and me
                    order: 5
                    label: What are the strong points of the city for you?
                    refvalues:
                      - id: 18126
                        CreatedAt: 2024-02-20T09:12:38.033661Z
                        UpdatedAt: 2025-10-06T11:57:17.703509Z
                        form_id: 11376
                        label: Public infrastructure
                        value: public_infrastructure
                        min: 0
                        order: 1
                      - id: 18127
                        CreatedAt: 2024-02-20T09:12:38.033661Z
                        UpdatedAt: 2025-10-06T11:57:17.703509Z
                        form_id: 11376
                        label: Education
                        value: education
                        min: 0
                        order: 2
                  - id: 11377
                    CreatedAt: 2024-02-20T09:12:38.017557Z
                    UpdatedAt: 2025-10-06T11:57:17.691264Z
                    name: FORM
                    type: range
                    section: The city and me
                    order: 1
                    label: On a scale from 1 to 10, how would you rate your satisfaction with the municipality?
                    refvalues:
                      - id: 18125
                        CreatedAt: 2024-02-20T09:12:38.020096Z
                        UpdatedAt: 2025-10-06T11:57:17.693075Z
                        form_id: 11377
                        min: 0
                        max: 20
                        step: 1
                        order: 1

  schemas:
    Form:
      type: object
      description: |-
        Represents a form field with its type (`numeric`, `radio`, ...) and
        its possible values and/or constraints on it (`refvalues`).
        <br>A form object belongs to a main category (`name`).
        <br>A form is used to describe a contact via formdata.
      properties:
        id:
          type: integer
        CreatedAt:
          type: string
        UpdatedAt:
          type: string
        name:
          type: string
          description: |-
            The name of the main form this form belongs to.
            <br>It can be one of the following values:
            - `CONSENT`: form related to the data collection and usage consent
            - `BRIEF`: list all talking points of a space
            - `FORM`: the space's survey
            - `ACTION`: define tasks channels after an action
            - `ISSUE`:
            - `STATUS`: define levels of supports
            - `STATIC`: define fields used to describe a contact
            - `CUSTOM`: define custom fields used to describe a contact
            - name_presence: define if the contact was present
          enum:
            - CONSENT
            - BRIEF
            - FORM
            - ACTION
            - ISSUE
            - STATUS
            - STATIC
            - CUSTOM
            - name_presence
        group_id:
          type: array
          items:
            type: integer
        type:
          type: string
          enum:
            - radio
            - checkbox
            - date
            - report
            - meet
            - text
            - signature
            - photos
            - numeric
            - range
            - other
        section:
          type: string
        activate:
          type: string
        order:
          type: integer
        activate_auto_send:
          type: string
          description: |-
            With name = `FORM` only and type is a free-field type.
            <br>When a contact answer to this form a mail and/or a sms
            is automatically sent, see autmatic emails for more details.
        label:
          type: string
        filterbyidrefvalue:
          type: integer
          description: |-
            Hide the form if the refvalue is not selected the contact.
            <br>i.e. if the contact don't answer with a specific value to the
            previous question, this form will not be displayed.
        index_refvalue_filterbyidrefvalue:
          type: integer
        refvalues:
          type: array
          items:
            $ref: '#/components/schemas/RefValue'
        tag_for_nb:
          type: boolean
        mandatory:
          type: boolean

    RefValue:
      type: object
      properties:
        id:
          type: integer
        CreatedAt:
          type: string
        UpdatedAt:
          type: string
        form_id:
          type: integer
        label:
          type: string
        value:
          type: string
        min:
          type: integer
        max:
          type: integer
        step:
          type: integer
        auto_send:
          type: string
          description: |-
            With name = `FORM` only.
            <br>When a contact answer to this form a mail and/or a sms
            is automatically sent, see autmatic emails for more details.
        auto_send_sms:
          type: string
        filterbyidrefvalue:
          type: integer
        index_form_filterbyidrefvalue:
          type: integer
        index_refvalue_filterbyidrefvalue:
          type: integer
        type:
          type: string
        followed:
          type: boolean
        color:
          type: string

    surveyBase:
      type: object
      properties:
        id:
          type: integer
        group_id:
          type: integer
        user:
          type: object
          description: The user who created the survey
          properties:
            id:
              type: integer
            firstname:
              type: string
            surname:
              type: string
            mail:
              type: string
        name:
          type: string
        type:
          type: string
          enum:
            - DEFAULT
        state:
          type: string
          description: The current state of the survey
          enum:
            - draft
            - active
            - archived

    Survey:
      allOf:
        - $ref: '#/components/schemas/surveyBase'
        - type: object
          properties:
            forms:
              type: object
              properties:
                static:
                  type: array
                  items:
                    $ref: '#/components/schemas/Form'

                custom:
                  type: array
                  items:
                    $ref: '#/components/schemas/Form'
                forms:
                  type: array
                  items:
                    $ref: '#/components/schemas/Form'
                consent:
                  type: array
                  items:
                    $ref: '#/components/schemas/Form'
                brief:
                  type: array
                  items:
                    $ref: '#/components/schemas/Form'
                issue:
                  type: array
                  items:
                    $ref: '#/components/schemas/Form'
                action:
                  type: array
                  items:
                    $ref: '#/components/schemas/Form'
                status:
                  type: array
                  items:
                    $ref: '#/components/schemas/Form'
                name_presence:
                  type: array
                  items:
                    $ref: '#/components/schemas/Form'
    
    SurveyWithOverrides:
      allOf:
        - $ref: '#/components/schemas/surveyBase'
        - type: object
          properties:
            forms_survey:
              type: array
              items:
                type: object
                properties:
                  form:
                    $ref: '#/components/schemas/Form'
                  form_override:
                    type: array
                    items:
                      $ref: '#/components/schemas/FormFieldOverride'
                  refvalue_override:
                    type: array
                    items:
                      $ref: '#/components/schemas/RefvalueOverride'
                    
    FormFieldOverride:
      type: object
      properties:
        field:
          type: string
        value:
          type: string

    RefvalueOverride:
      type: object
      properties:
        id:
          type: integer
        field:
          type: string
        value:
          type: string

    FormSurvey:
      type: object
      properties: 
        form_id: 
          type: integer
          example: 4563
        form_override: 
          type: array
          items: 
            type: object
            properties: 
              field: 
                type: string
                example: Order
              value: 
                type: integer
                example: 2
        refvalue_override:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                example: 12543
              field:
                type: string
                example: Label
              value:
                type: integer
                example: New label

    SurveyUsage:
      type: object
      description: Survey usage statistics
      properties:
        id:
          type: integer
          description: Survey ID
        usage:
          type: object
          properties:
            ongoing_action_count:
              type: integer
              description: Number of ongoing actions associated with this survey
            contact_reach_total:
              type: integer
              description: Total number of contacts reached by this survey
