{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/frontapp/json-schema/frontapp-analytics-export-request-schema.json",
  "title": "AnalyticsExportRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/frontapp-analytics-api-openapi.yml#/components/schemas/AnalyticsExportRequest",
  "oneOf": [
    {
      "$ref": "#/$defs/AnalyticsMessagesExportColumns"
    },
    {
      "$ref": "#/$defs/AnalyticsActivitiesExportsColumns"
    }
  ],
  "properties": {
    "type": {
      "type": "string",
      "description": "The type of export to create. The type you specify determines which columns are available for the export.",
      "enum": [
        "messages",
        "events"
      ]
    },
    "start": {
      "type": "number",
      "description": "Start time of the data to include in the export (seconds since 1970-01-01T00:00:00+00). Will be rounded down to the start of the day."
    },
    "end": {
      "type": "number",
      "description": "End time of the data to include in the export (seconds since 1970-01-01T00:00:00+00). Will be rounded up to the end of the day."
    },
    "timezone": {
      "type": "string",
      "description": "[IANA name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) of the timezone to format the dates with. If omitted, the export will use Etc/UTC."
    },
    "filters": {
      "$ref": "#/$defs/AnalyticsFilters"
    }
  },
  "required": [
    "start",
    "end",
    "type"
  ],
  "$defs": {
    "AccountIds": {
      "type": "object",
      "required": [
        "account_ids"
      ],
      "properties": {
        "account_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ResourceID"
          }
        }
      }
    },
    "AnalyticsActivitiesColumns": {
      "title": "Columns",
      "type": "string",
      "enum": [
        "Activity ID",
        "Type",
        "Source",
        "Message ID",
        "Segment ID",
        "Conversation ID",
        "Ticket IDs",
        "Segment",
        "Segment start",
        "Segment end",
        "Direction",
        "Status",
        "Status at activity time",
        "Inbox",
        "Inbox API ID",
        "Inbox at activity time",
        "Inbox API IDs at activity time",
        "Previous inbox IDs",
        "Message date",
        "Autoreply",
        "Reaction time",
        "Total reply time",
        "Handle time",
        "Response time",
        "Stage resolution time",
        "Replies to resolution",
        "Ticket resolution time",
        "Ticket replies to resolution",
        "Attributed to",
        "Assignee",
        "Author",
        "Contact name",
        "Contact handle",
        "Account names",
        "From",
        "To",
        "Cc",
        "Bcc",
        "Extract",
        "Tags",
        "Tag API IDs",
        "Tags at activity time",
        "Tag API IDs at activity time",
        "Tag application duration",
        "Activity API ID",
        "Message API ID",
        "Comment API ID",
        "Conversation API ID",
        "Message original ID",
        "New Conversation",
        "First response",
        "Business hours",
        "Subject",
        "Account name",
        "Survey rating",
        "Survey comment",
        "Segment closed",
        "Segment contains messages",
        "Last segment activity",
        "Added tag",
        "Added tag API ID",
        "Removed tag",
        "Removed tag API ID",
        "Segment cumulative teammates",
        "Ticket status name",
        "Ticket status category",
        "Time spent in Ticket Status",
        "Transitions to Ticket Status",
        "Smart QA score",
        "Custom Field",
        "Updated Custom Field",
        "Attributed teammates"
      ]
    },
    "AnalyticsActivitiesExportsColumns": {
      "required": [
        "columns"
      ],
      "type": "object",
      "properties": {
        "columns": {
          "type": "array",
          "description": "List of the columns to include in the export.\n\n**Fixed columns** are plain strings selected from the predefined list (e.g., `\"Message ID\"`).\n\n**Parameterized columns** require an additional parameter and must be specified as an object\nwith `name` and `id` fields. Supported parameterized prefixes:\n  - `Time spent in Ticket Status` — `id` is the ticket status public API ID (e.g., `sts_123`)\n  - `Transitions to Ticket Status` — `id` is the ticket status public API ID (e.g., `sts_123`)\n  - `Smart QA score` — `id` is the Smart QA criteria name (e.g., `Comprehension`)\n  - `Custom Field` — `id` is the custom field public API ID (e.g., `fld_456`)\n  - `Updated Custom Field` — `id` is the custom field public API ID (e.g., `fld_456`)\n\nExample: `[\"Message ID\", {\"name\": \"Time spent in Ticket Status\", \"id\": \"sts_123\"}, {\"name\": \"Smart QA score\", \"id\": \"Comprehension\"}]`\n",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/AnalyticsActivitiesColumns"
              },
              {
                "$ref": "#/$defs/AnalyticsActivitiesSmartQAParameterizedColumn"
              },
              {
                "$ref": "#/$defs/AnalyticsActivitiesNumericParameterizedColumn"
              }
            ]
          },
          "default": [
            "Activity ID",
            "Type",
            "Source",
            "Message ID",
            "Segment ID",
            "Conversation ID",
            "Ticket IDs",
            "Segment",
            "Segment start",
            "Segment end",
            "Direction",
            "Status",
            "Status at activity time",
            "Inbox",
            "Inbox API ID",
            "Inbox at activity time",
            "Inbox API IDs at activity time",
            "Previous inbox IDs",
            "Message date",
            "Autoreply",
            "Reaction time",
            "Total reply time",
            "Handle time",
            "Response time",
            "Ticket resolution time",
            "Ticket replies to resolution",
            "Attributed to",
            "Assignee",
            "Author",
            "Contact name",
            "Contact handle",
            "Account names",
            "From",
            "To",
            "Cc",
            "Bcc",
            "Extract",
            "Tags",
            "Tag API IDs",
            "Tags at activity time",
            "Tag API IDs at activity time",
            "Tag application duration",
            "Activity API ID",
            "Message API ID",
            "Comment API ID",
            "Conversation API ID",
            "Message original ID",
            "New Conversation",
            "First response",
            "Business hours",
            "Subject",
            "Account name",
            "Survey rating",
            "Survey comment",
            "Segment closed",
            "Segment contains messages",
            "Last segment activity",
            "Added tag",
            "Added tag API ID",
            "Removed tag",
            "Removed tag API ID",
            "Segment cumulative teammates",
            "Attributed teammates"
          ]
        }
      }
    },
    "AnalyticsActivitiesNumericParameterizedColumn": {
      "title": "Columns with numeric parameter",
      "type": "object",
      "required": [
        "name",
        "id"
      ],
      "properties": {
        "name": {
          "type": "string",
          "enum": [
            "Time spent in Ticket Status",
            "Transitions to Ticket Status",
            "Custom Field",
            "Updated Custom Field"
          ]
        },
        "id": {
          "description": "Public API string ID (e.g., sts_123 for ticket statuses, fld_456 for custom fields) or legacy numeric ID",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "integer"
            }
          ]
        }
      }
    },
    "AnalyticsActivitiesSmartQAParameterizedColumn": {
      "title": "Smart QA Columns",
      "type": "object",
      "required": [
        "name",
        "id"
      ],
      "properties": {
        "name": {
          "type": "string",
          "enum": [
            "Smart QA score"
          ]
        },
        "id": {
          "$ref": "#/$defs/AnalyticsActivitiesSmartQAScoreParameters"
        }
      }
    },
    "AnalyticsActivitiesSmartQAScoreParameters": {
      "type": "string",
      "enum": [
        "Comprehension",
        "Solution_Offered",
        "Professionalism",
        "Professional_Behavior",
        "Professional_Relationship",
        "Readability",
        "Grammar_Spelling",
        "General_Empathy",
        "Cognitive_Empathy",
        "Emotional_Empathy",
        "Compassionate_Empathy",
        "Tone",
        "Adaptive_Tone",
        "Neutral_Tone",
        "Positive_Tone",
        "Brevity",
        "Demo_Offered",
        "Information_Gathering",
        "Upsell",
        "Friendly",
        "Greeting_Offered",
        "Personalisation",
        "Adaptability"
      ]
    },
    "AnalyticsFilters": {
      "description": "Resources to compute the analytics for. Defaults to all.",
      "anyOf": [
        {
          "$ref": "#/$defs/TagIds"
        },
        {
          "$ref": "#/$defs/TeammateIds"
        },
        {
          "$ref": "#/$defs/ChannelIds"
        },
        {
          "$ref": "#/$defs/InboxIds"
        },
        {
          "$ref": "#/$defs/TeamIds"
        },
        {
          "$ref": "#/$defs/AccountIds"
        }
      ]
    },
    "AnalyticsMessagesColumns": {
      "type": "string",
      "enum": [
        "Message ID",
        "Segment ID",
        "Conversation ID",
        "Ticket IDs",
        "Segment",
        "Direction",
        "Status",
        "Inbox",
        "Inbox API ID",
        "Inbox at activity time",
        "Inbox API IDs at activity time",
        "Message date",
        "Autoreply",
        "Reaction time",
        "Total reply time",
        "Handle time",
        "Response time",
        "Attributed to",
        "Assignee",
        "Author",
        "Contact name",
        "Contact handle",
        "Account names",
        "From",
        "To",
        "Cc",
        "Bcc",
        "Extract",
        "Tags",
        "Tag API IDs",
        "Message API ID",
        "Conversation API ID",
        "New Conversation",
        "First response",
        "Business hours",
        "Subject",
        "Segment start",
        "Segment end",
        "Segment closed",
        "Last segment activity",
        "Segment cumulative teammates",
        "Ticket status name",
        "Ticket status category",
        "Custom Field",
        "Attributed teammates"
      ]
    },
    "AnalyticsMessagesExportColumns": {
      "required": [
        "columns"
      ],
      "type": "object",
      "properties": {
        "columns": {
          "type": "array",
          "description": "List of the columns to include in the export.\n",
          "items": {
            "$ref": "#/$defs/AnalyticsMessagesColumns"
          },
          "default": [
            "Message ID",
            "Segment ID",
            "Conversation ID",
            "Ticket IDs",
            "Segment",
            "Direction",
            "Status",
            "Inbox",
            "Inbox API ID",
            "Inbox at activity time",
            "Inbox API IDs at activity time",
            "Message date",
            "Autoreply",
            "Reaction time",
            "Total reply time",
            "Handle time",
            "Response time",
            "Attributed to",
            "Assignee",
            "Author",
            "Contact name",
            "Contact handle",
            "Account names",
            "From",
            "To",
            "Cc",
            "Bcc",
            "Extract",
            "Tags",
            "Tag API IDs",
            "Message API ID",
            "Conversation API ID",
            "New Conversation",
            "First response",
            "Business hours",
            "Subject",
            "Segment start",
            "Segment end",
            "Segment closed",
            "Last segment activity",
            "Segment cumulative teammates",
            "Attributed teammates"
          ]
        }
      }
    },
    "ChannelIds": {
      "type": "object",
      "required": [
        "channel_ids"
      ],
      "properties": {
        "channel_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ResourceID"
          }
        }
      }
    },
    "InboxIds": {
      "type": "object",
      "required": [
        "inbox_ids"
      ],
      "properties": {
        "inbox_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ResourceID"
          }
        }
      }
    },
    "ResourceID": {
      "type": "string"
    },
    "TagIds": {
      "type": "object",
      "required": [
        "tag_ids"
      ],
      "properties": {
        "tag_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ResourceID"
          }
        }
      }
    },
    "TeamIds": {
      "type": "object",
      "required": [
        "team_ids"
      ],
      "properties": {
        "team_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ResourceID"
          }
        }
      }
    },
    "TeammateIds": {
      "type": "object",
      "required": [
        "teammate_ids"
      ],
      "properties": {
        "teammate_ids": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ResourceID"
          }
        }
      }
    }
  }
}