{
  "openapi": "3.0.0",
  "info": {
    "title": "VisitReport Event Analytics API",
    "version": "1",
    "description": "Measure event activity and analyze responses to questionnaire questions."
  },
  "servers": [
    {
      "url": "https://backend.snapaddy.com/analytics"
    }
  ],
  "paths": {
    "/questionnaire/{questionnaireId}/reports/stats": {
      "post": {
        "operationId": "AnalyticsController_getReportStats",
        "summary": "Get a report and contact summary",
        "description": "Returns statistics of captured reports for the specified questionnaire.",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Event totals for reports, participants, active days, and report creators under the requested filters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportStatsResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReportStatsRequestDto"
              },
              "example": {
                "timezone": "Europe/Berlin",
                "completionStatus": "completed"
              }
            }
          }
        }
      }
    },
    "/questionnaire/{questionnaireId}/reports/time-range": {
      "get": {
        "operationId": "AnalyticsController_getReportsTimeRange",
        "summary": "Get the captured report time range",
        "description": "Returns the time range (i.e. timestamp of the oldest and most recent captured report) of all reports of the specified questionnaire.",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          },
          {
            "name": "timezone",
            "required": false,
            "in": "query",
            "description": "Timezone the creation timestamps of reports should be converted to.",
            "schema": {
              "default": "UTC",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the time range (i.e. timestamp of the oldest and most recent captured report) of all reports of the specified questionnaire.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimeRangeResponseDto"
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          },
          "404": {
            "description": "In case there are no captured reports for the specified questionnaire."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      }
    },
    "/questionnaire/{questionnaireId}/reports/creators": {
      "get": {
        "operationId": "AnalyticsController_getReportCreators",
        "summary": "List report creators",
        "description": "Returns an array holding the usernames of the creators of reports for the specified questionnaire.",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns an array holding the usernames of the creators of reports for the specified questionnaire.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/GetReportCreatorsResponseDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          },
          "404": {
            "description": "In case there are no captured reports for the specified questionnaire."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      }
    },
    "/questionnaire/{questionnaireId}/reports/count-by-day": {
      "post": {
        "operationId": "AnalyticsController_getReportsCountByDay",
        "summary": "Count reports by day",
        "description": "Returns an array holding the related number of reports by day of the specified questionnaire.",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "An array of day labels and counts for completed reports, grouped in the selected time zone.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DataItemResponseDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalyticsRequestDto"
              },
              "example": {
                "timezone": "Europe/Berlin"
              }
            }
          }
        }
      }
    },
    "/questionnaire/{questionnaireId}/reports/count-by-hour": {
      "post": {
        "operationId": "AnalyticsController_getReportsCountByHour",
        "summary": "Count reports by hour",
        "description": "Returns an array holding the number of reports by hour of the specified questionnaire.",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "An array holding the number of reports by hour.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DataItemResponseDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReportsCountByHourRequestDto"
              },
              "example": {
                "timezone": "Europe/Berlin"
              }
            }
          }
        }
      }
    },
    "/questionnaire/{questionnaireId}/reports/count-by-user": {
      "post": {
        "operationId": "AnalyticsController_getReportsCountByUser",
        "summary": "Count reports by user",
        "description": "Returns an array holding the number of reports by user of the specified questionnaire.",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "An array holding the number of reports by user.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DataItemResponseDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalyticsRequestDto"
              },
              "example": {
                "timezone": "Europe/Berlin"
              }
            }
          }
        }
      }
    },
    "/questionnaire/{questionnaireId}/reports/contacts/count-by-day": {
      "post": {
        "operationId": "AnalyticsController_getContactsCountByDay",
        "summary": "Count contacts by day",
        "description": "Returns an array holding the related number of contacts by day of the specified questionnaire.",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "An array holding the related number of contacts by day.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DataItemResponseDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalyticsRequestDto"
              },
              "example": {
                "timezone": "Europe/Berlin"
              }
            }
          }
        }
      }
    },
    "/questionnaire/{questionnaireId}/reports/contacts/count-by-country": {
      "post": {
        "operationId": "AnalyticsController_getContactsCountByCountry",
        "summary": "Count contacts by country",
        "description": "Returns an array holding the number of captured contacts by country of the specified questionnaire.",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "An array holding the number of contacts by country.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DataItemResponseDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalyticsRequestDto"
              },
              "example": {
                "timezone": "Europe/Berlin"
              }
            }
          }
        }
      }
    },
    "/questionnaire/{questionnaireId}/reports/contacts/count-by-source": {
      "post": {
        "operationId": "AnalyticsController_getContactsCountBySource",
        "summary": "Count contacts by capture source",
        "description": "Returns an array holding the number of captured contacts by their source of the specified questionnaire.",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "An array holding the number of contacts by their source.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NullableDataItemResponseDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalyticsRequestDto"
              },
              "example": {
                "timezone": "Europe/Berlin"
              }
            }
          }
        }
      }
    },
    "/questionnaire/{questionnaireId}/group/{questionGroupId}/question/{questionId}/options": {
      "get": {
        "operationId": "AnalyticsController_getQuestionOptions",
        "summary": "List options for a question",
        "description": "Returns question options IDs and titles of the question options in all available languages for the specified question of the specified question group of the specified questionnaire.",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          },
          {
            "name": "questionGroupId",
            "required": true,
            "in": "path",
            "description": "Question group ID from the event configuration.",
            "schema": {
              "type": "string",
              "example": "ExampleGroup0001"
            }
          },
          {
            "name": "questionId",
            "required": true,
            "in": "path",
            "description": "Question ID from the event’s questionnaire.",
            "schema": {
              "type": "string",
              "example": "ExampleQuestion1"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns question options IDs and titles of the question options in all available languages for the specified question of the specified question group of the specified questionnaire.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MetadataResponseDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          },
          "404": {
            "description": "In case there are no question options for the specified question of the specified question group of the specified questionnaire."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ]
      }
    },
    "/questionnaire/{questionnaireId}/group/{questionGroupId}/question/{questionId}/answer-counts": {
      "post": {
        "operationId": "AnalyticsController_getAnswersCount",
        "summary": "Count selected answers",
        "description": "Returns an array holding the number of answers for the specified question (of a question group of a questionnaire).",
        "parameters": [
          {
            "name": "questionnaireId",
            "required": true,
            "in": "path",
            "description": "VisitReport event ID returned by Find events.",
            "schema": {
              "type": "string",
              "example": "ExampleEvent0001"
            }
          },
          {
            "name": "questionGroupId",
            "required": true,
            "in": "path",
            "description": "Question group ID from the event configuration.",
            "schema": {
              "type": "string",
              "example": "ExampleGroup0001"
            }
          },
          {
            "name": "questionId",
            "required": true,
            "in": "path",
            "description": "Question ID from the event’s questionnaire.",
            "schema": {
              "type": "string",
              "example": "ExampleQuestion1"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "An array holding the number of answers for the question.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MultilingualDataItemResponseDto"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing or invalid."
          },
          "403": {
            "description": "Your account lacks access to this operation."
          }
        },
        "security": [
          {
            "x-api-key": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalyticsRequestDto"
              },
              "example": {
                "timezone": "Europe/Berlin"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ReportStatsResponseDto": {
        "type": "object",
        "properties": {
          "numberOfReports": {
            "type": "number",
            "description": "Number of captured reports."
          },
          "numberOfContacts": {
            "type": "number",
            "description": "Number of captured contacts in the selected reports. A report can contain more than one contact."
          },
          "numberOfDays": {
            "type": "number",
            "description": "Distinct days with report activity in the selected time zone."
          },
          "numberOfUsers": {
            "type": "number",
            "description": "Number of different users who captured reports in this selection."
          }
        },
        "required": [
          "numberOfReports",
          "numberOfContacts",
          "numberOfDays",
          "numberOfUsers"
        ],
        "title": "Report Stats Response"
      },
      "ReportStatsRequestDto": {
        "type": "object",
        "properties": {
          "staticFilters": {
            "description": "Set of static filters to be applied.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StaticFilterRequestDto"
            }
          },
          "questionFilters": {
            "description": "Set of question filters to be applied.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuestionFilterRequestDto"
            }
          },
          "timezone": {
            "type": "string",
            "description": "Time zone used when grouping report activity into calendar days. The default is UTC.",
            "default": "UTC"
          },
          "completionStatus": {
            "type": "string",
            "description": "Choose completed, in-progress, or all reports for the event summary. The default is completed.",
            "enum": [
              "all",
              "completed",
              "in-progress"
            ],
            "default": "completed"
          }
        },
        "title": "Report Stats Request"
      },
      "StaticFilterRequestDto": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string",
            "description": "Field to which the filter applies.",
            "enum": [
              "REPORT_CREATED_AT",
              "REPORT_CREATED_BY",
              "REPORT_IS_QUICK_SCAN",
              "CONTACT_GENDER",
              "CONTACT_TITLE",
              "CONTACT_FIRST_NAME",
              "CONTACT_LAST_NAME",
              "CONTACT_POSITION",
              "CONTACT_ORGANIZATION",
              "CONTACT_EMAIL",
              "CONTACT_PHONE",
              "CONTACT_MOBILE",
              "CONTACT_FAX",
              "CONTACT_WEBSITE",
              "CONTACT_VAT",
              "CONTACT_STREET",
              "CONTACT_CITY",
              "CONTACT_ZIP",
              "CONTACT_STATE",
              "CONTACT_COUNTRY",
              "CONTACT_INDUSTRY",
              "CONTACT_COMPANY_SIZE",
              "CONTACT_SOURCE"
            ]
          },
          "operator": {
            "type": "string",
            "description": "Comparison operator.",
            "enum": [
              "IS",
              "IS_NOT",
              "CONTAINS",
              "STARTS_WITH",
              "ENDS_WITH",
              "DOES_NOT_CONTAIN",
              "IS_LESS_THAN",
              "IS_GREATER_THAN",
              "IS_LESS_THAN_OR_EQUAL",
              "IS_GREATER_THAN_OR_EQUAL",
              "IS_EMPTY",
              "IS_NOT_EMPTY",
              "HAS_ANY_OF",
              "HAS_ALL_OF",
              "HAS_NONE_OF",
              "IS_BETWEEN",
              "IS_DATE"
            ]
          },
          "values": {
            "description": "Value or set of values to be compared.",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "field",
          "operator",
          "values"
        ],
        "title": "Static Filter Request"
      },
      "QuestionFilterRequestDto": {
        "type": "object",
        "properties": {
          "questionId": {
            "type": "string",
            "description": "Question ID the filter applies to."
          },
          "operator": {
            "type": "string",
            "description": "Comparison operator.",
            "enum": [
              "IS",
              "IS_NOT",
              "CONTAINS",
              "STARTS_WITH",
              "ENDS_WITH",
              "DOES_NOT_CONTAIN",
              "IS_LESS_THAN",
              "IS_GREATER_THAN",
              "IS_LESS_THAN_OR_EQUAL",
              "IS_GREATER_THAN_OR_EQUAL",
              "IS_EMPTY",
              "IS_NOT_EMPTY",
              "HAS_ANY_OF",
              "HAS_ALL_OF",
              "HAS_NONE_OF",
              "IS_BETWEEN",
              "IS_DATE"
            ]
          },
          "values": {
            "description": "Value or set of question options IDs.",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "questionId",
          "operator",
          "values"
        ],
        "title": "Question Filter Request"
      },
      "TimeRangeResponseDto": {
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "description": "Start timestamp of the time range."
          },
          "end": {
            "type": "string",
            "description": "End timestamp of the time range."
          }
        },
        "required": [
          "start",
          "end"
        ],
        "title": "Time Range Response"
      },
      "GetReportCreatorsResponseDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Username of the creator."
          }
        },
        "required": [
          "name"
        ],
        "title": "Get Report Creators Response"
      },
      "DataItemResponseDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name or label of the data item."
          },
          "value": {
            "type": "number",
            "description": "Numeric value of the data item."
          }
        },
        "required": [
          "name",
          "value"
        ],
        "title": "Data Item Response"
      },
      "AnalyticsRequestDto": {
        "type": "object",
        "properties": {
          "staticFilters": {
            "description": "Set of static filters to be applied.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StaticFilterRequestDto"
            }
          },
          "questionFilters": {
            "description": "Set of question filters to be applied.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuestionFilterRequestDto"
            }
          },
          "timezone": {
            "type": "string",
            "description": "Timezone the creation timestamps of reports should be converted to.",
            "default": "UTC"
          }
        },
        "title": "Analytics Request"
      },
      "ReportsCountByHourRequestDto": {
        "type": "object",
        "properties": {
          "staticFilters": {
            "description": "Set of static filters to be applied.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StaticFilterRequestDto"
            }
          },
          "questionFilters": {
            "description": "Set of question filters to be applied.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuestionFilterRequestDto"
            }
          },
          "timezone": {
            "type": "string",
            "description": "Timezone applied when grouping the selected report timestamps. Buckets are serialized as UTC.",
            "default": "UTC"
          },
          "timestampField": {
            "type": "string",
            "description": "Timestamp used to group reports into hourly buckets.",
            "enum": [
              "completed-at",
              "created-at"
            ],
            "default": "created-at"
          },
          "completionStatus": {
            "type": "string",
            "description": "Completion status of reports to include. Completion-time statistics always contain completed reports.",
            "enum": [
              "all",
              "completed",
              "in-progress"
            ]
          },
          "start": {
            "type": "string",
            "description": "Inclusive start of the timestamp range as an ISO 8601 timestamp with a UTC designator or numeric offset."
          },
          "end": {
            "type": "string",
            "description": "Exclusive end of the timestamp range as an ISO 8601 timestamp with a UTC designator or numeric offset."
          }
        },
        "title": "Reports Count By Hour Request"
      },
      "NullableDataItemResponseDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name or label of the data item.",
            "nullable": true
          },
          "value": {
            "type": "number",
            "description": "Numeric value of the data item."
          }
        },
        "required": [
          "name",
          "value"
        ],
        "title": "Nullable Data Item Response"
      },
      "MetadataResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID of the item (i.e. question group, question etc.)."
          },
          "names": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Name or label of the item in multiple languages."
          }
        },
        "required": [
          "id",
          "names"
        ],
        "title": "Metadata Response"
      },
      "MultilingualDataItemResponseDto": {
        "type": "object",
        "properties": {
          "names": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Name or label of the data item in multiple languages."
          },
          "value": {
            "type": "number",
            "description": "Numeric value of the data item."
          }
        },
        "required": [
          "names",
          "value"
        ],
        "title": "Multilingual Data Item Response"
      }
    },
    "securitySchemes": {
      "x-api-key": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Use a [personal API token](/authentication/#personal-api-token)."
      }
    }
  }
}
