swagger: "2.0"
info:
  title: FunnelFlux Stats API
  description: Run reporting queries, retrieve available report groupings, export
    reports, update conversion or cost data, and reset scoped stats data.
  version: 2.0.0
schemes:
  - http
  - https
host: YOUR_FUNNELFLUX_DOMAIN
basePath: /admin/api/v2
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  ApiKeyQuery:
    type: apiKey
    name: apiKey
    in: query
    description: FunnelFlux API key passed as the `apiKey` query parameter.
security:
  - ApiKeyQuery: []
tags:
  - name: Reporting
    description: Stats reporting and exports.
  - name: Updates
    description: Conversion, cost, and stats update endpoints.
paths:
  /stats/reporting/groupings/index.php:
    get:
      tags:
        - Reporting
      description: Returns the list of available groupings
      parameters:
        - name: apiKey
          required: true
          in: query
          type: string
          description: An authorized api key
      responses:
        "200":
          description: The groupings list as a string array
          schema:
            type: array
            items:
              type: string
        "403":
          description: Not authorized
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Returns the list of available groupings
  /stats/reporting/drilldown/index.php:
    post:
      tags:
        - Reporting
      description: Create and run a new drilldown report
      parameters:
        - name: apiKey
          required: true
          in: query
          type: string
          description: An authorized api key
        - name: body
          required: true
          in: body
          schema:
            $ref: "#/definitions/DrilldownRequest"
      responses:
        "200":
          description: The requested report
          schema:
            $ref: "#/definitions/Report"
        "403":
          description: Not authorized
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Create and run a new drilldown report
  /stats/update/conversions/index.php:
    put:
      tags:
        - Updates
      description: Add new or update existing conversions
      parameters:
        - name: apiKey
          required: true
          in: query
          type: string
          description: An authorized api key
        - name: body
          required: true
          in: body
          schema:
            $ref: "#/definitions/ConversionsUpload"
      responses:
        "200":
          description: Background job created successfully
          schema:
            $ref: "#/definitions/BackgroundJobResponse"
        "403":
          description: Not authorized
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Add new or update existing conversions
  /stats/update/reset/index.php:
    delete:
      tags:
        - Updates
      description: Reset specific hits
      parameters:
        - name: apiKey
          required: true
          in: query
          type: string
          description: An authorized api key
        - name: body
          required: true
          in: body
          schema:
            $ref: "#/definitions/ResetHits"
      responses:
        "200":
          description: Background job created successfully
        "403":
          description: Not authorized
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Reset specific hits
    get:
      tags:
        - Updates
      description: Get the number of visits that would be deleted with the specified
        settings
      parameters:
        - name: apiKey
          required: true
          in: query
          type: string
          description: An authorized api key
        - name: body
          required: true
          in: body
          schema:
            $ref: "#/definitions/ResetHits"
      responses:
        "200":
          description: The number of would-be impacted visits
          schema:
            $ref: "#/definitions/IntegerValue"
        "403":
          description: Not authorized
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Get the number of visits that would be deleted with the specified
        settings
  /stats/update/cost/index.php:
    put:
      tags:
        - Updates
      description: Update the cost of a traffic segment
      parameters:
        - name: apiKey
          required: true
          in: query
          type: string
          description: An authorized api key
        - name: body
          required: true
          in: body
          schema:
            $ref: "#/definitions/CostUpload"
      responses:
        "200":
          description: Background job created successfully
          schema:
            $ref: "#/definitions/BackgroundJobResponse"
        "403":
          description: Not authorized
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Update the cost of a traffic segment
  /stats/reporting/export/csv/index.php:
    post:
      tags:
        - Reporting
      description: Export a drilldown report as CSV. Supports paginated export via
        offset/limit for large datasets.
      parameters:
        - name: apiKey
          required: true
          in: query
          type: string
          description: An authorized api key
        - name: body
          required: true
          in: body
          schema:
            $ref: "#/definitions/CsvExportRequest"
      responses:
        "200":
          description: CSV export result
          schema:
            $ref: "#/definitions/CsvExportResponse"
        "403":
          description: Not authorized
        default:
          description: Unexpected error
          schema:
            $ref: "#/definitions/Error"
      summary: Export a drilldown report as CSV
definitions:
  CostSegment:
    required:
      - cost
    properties:
      cost:
        type: number
        format: double
        minimum: 0
      costType:
        type: string
        enum:
          - costForWholeSegment
          - costPerEntrance
        default: costForWholeSegment
      applyToFilteredTraffic:
        description: If set to true, then the cost update will also take the filtered
          entrances into account
        type: boolean
        default: false
      restrictToCountryCode:
        description: If set, then update cost of traffic that comes from this country only
        type: string
        default: null
      restrictToTrackingFields:
        description: "If set, then update cost of traffic that have these tracking field
          values only. The KeyValuePair object is composed of: * key - The
          tracking field name * value - The tracking field value"
        type: array
        items:
          $ref: "#/definitions/KeyValuePair"
  CostUpload:
    required:
      - idTrafficSource
      - timeRange
      - timeZone
      - costSegments
    properties:
      idFunnel:
        description: Optional funnel ID to narrow scope. If omitted, cost update applies
          to all funnels for the traffic source.
        type: integer
        format: int64
      idTrafficSource:
        description: 64 bits integer id of the traffic source
        type: integer
        format: int64
        minimum: 1
      timeRange:
        $ref: "#/definitions/DateTimeRange"
      timeZone:
        $ref: "#/definitions/TimeZone"
      costSegments:
        type: array
        items:
          $ref: "#/definitions/CostSegment"
      notificationWhenComplete:
        type: boolean
        default: false
  ResetHits:
    required:
      - timeRange
      - timeZone
    properties:
      timeRange:
        $ref: "#/definitions/DateTimeRange"
      timeZone:
        $ref: "#/definitions/TimeZone"
      restrictToFunnelId:
        type: string
        default: null
      restrictToTrafficSourceId:
        type: string
        default: null
      restrictToVisitorId:
        type: string
        default: null
      restrictToTrackingFields:
        description: Map of tracking field name to value (or list of values). All
          conditions are AND-ed; multiple values per field are OR-ed.
        type: object
        additionalProperties:
          type: string
          description: String value or array of string values.
        default: null
  ConvertedHit:
    required:
      - idHit
    properties:
      idHit:
        description: 64 bits integer corresponding to the hit id
        type: integer
        format: int64
        minimum: 1
      transaction:
        description: The optional transaction id
        type: string
        default: ""
      payout:
        description: An optional payout amount. When not specified, the default payout
          from the converted offer is used. If set to -1, then this hit is set
          as non-converted.
        type: number
        format: double
        default: null
  ConversionsUpload:
    required:
      - hits
    properties:
      hits:
        type: array
        items:
          $ref: "#/definitions/ConvertedHit"
      postbackCalls:
        description: Call the traffic source postbacks of the sources that generated
          theses conversions. If set to 'none', then the postbacks are not
          called for any of the specified hits. If set to 'onlyOnce', then the
          postbacks are only called for the hits that never called them before.
          If set to 'all', the postbacks are called for all the specified hits,
          even if they were already called in the past for some/all hits.
        type: string
        enum:
          - none
          - onlyOnce
          - all
        default: none
      notificationWhenComplete:
        type: boolean
        default: false
  TimeZone:
    description: When a TimeZone object is provided as an input to an API function,
      then either offset or name is required. If both are given, then 'name'
      takes precedence. When a TimeZone object is sent back from an API
      function, both 'offset' and 'name' are filled.
    type: object
    properties:
      name:
        description: Time zone's name
        type: string
        enum:
          - Africa/Abidjan
          - Africa/Accra
          - Africa/Addis_Ababa
          - Africa/Algiers
          - Africa/Asmara
          - Africa/Bamako
          - Africa/Bangui
          - Africa/Banjul
          - Africa/Bissau
          - Africa/Blantyre
          - Africa/Brazzaville
          - Africa/Bujumbura
          - Africa/Cairo
          - Africa/Casablanca
          - Africa/Ceuta
          - Africa/Conakry
          - Africa/Dakar
          - Africa/Dar_es_Salaam
          - Africa/Djibouti
          - Africa/Douala
          - Africa/El_Aaiun
          - Africa/Freetown
          - Africa/Gaborone
          - Africa/Harare
          - Africa/Johannesburg
          - Africa/Juba
          - Africa/Kampala
          - Africa/Khartoum
          - Africa/Kigali
          - Africa/Kinshasa
          - Africa/Lagos
          - Africa/Libreville
          - Africa/Lome
          - Africa/Luanda
          - Africa/Lubumbashi
          - Africa/Lusaka
          - Africa/Malabo
          - Africa/Maputo
          - Africa/Maseru
          - Africa/Mbabane
          - Africa/Mogadishu
          - Africa/Monrovia
          - Africa/Nairobi
          - Africa/Ndjamena
          - Africa/Niamey
          - Africa/Nouakchott
          - Africa/Ouagadougou
          - Africa/Porto-Novo
          - Africa/Sao_Tome
          - Africa/Tripoli
          - Africa/Tunis
          - Africa/Windhoek
          - America/Adak
          - America/Anchorage
          - America/Anguilla
          - America/Antigua
          - America/Araguaina
          - America/Argentina/Buenos_Aires
          - America/Argentina/Catamarca
          - America/Argentina/Cordoba
          - America/Argentina/Jujuy
          - America/Argentina/La_Rioja
          - America/Argentina/Mendoza
          - America/Argentina/Rio_Gallegos
          - America/Argentina/Salta
          - America/Argentina/San_Juan
          - America/Argentina/San_Luis
          - America/Argentina/Tucuman
          - America/Argentina/Ushuaia
          - America/Aruba
          - America/Asuncion
          - America/Atikokan
          - America/Bahia
          - America/Bahia_Banderas
          - America/Barbados
          - America/Belem
          - America/Belize
          - America/Blanc-Sablon
          - America/Boa_Vista
          - America/Bogota
          - America/Boise
          - America/Cambridge_Bay
          - America/Campo_Grande
          - America/Cancun
          - America/Caracas
          - America/Cayenne
          - America/Cayman
          - America/Chicago
          - America/Chihuahua
          - America/Costa_Rica
          - America/Creston
          - America/Cuiaba
          - America/Curacao
          - America/Danmarkshavn
          - America/Dawson
          - America/Dawson_Creek
          - America/Denver
          - America/Detroit
          - America/Dominica
          - America/Edmonton
          - America/Eirunepe
          - America/El_Salvador
          - America/Fort_Nelson
          - America/Fortaleza
          - America/Glace_Bay
          - America/Godthab
          - America/Goose_Bay
          - America/Grand_Turk
          - America/Grenada
          - America/Guadeloupe
          - America/Guatemala
          - America/Guayaquil
          - America/Guyana
          - America/Halifax
          - America/Havana
          - America/Hermosillo
          - America/Indiana/Indianapolis
          - America/Indiana/Knox
          - America/Indiana/Marengo
          - America/Indiana/Petersburg
          - America/Indiana/Tell_City
          - America/Indiana/Vevay
          - America/Indiana/Vincennes
          - America/Indiana/Winamac
          - America/Inuvik
          - America/Iqaluit
          - America/Jamaica
          - America/Juneau
          - America/Kentucky/Louisville
          - America/Kentucky/Monticello
          - America/Kralendijk
          - America/La_Paz
          - America/Lima
          - America/Los_Angeles
          - America/Lower_Princes
          - America/Maceio
          - America/Managua
          - America/Manaus
          - America/Marigot
          - America/Martinique
          - America/Matamoros
          - America/Mazatlan
          - America/Menominee
          - America/Merida
          - America/Metlakatla
          - America/Mexico_City
          - America/Miquelon
          - America/Moncton
          - America/Monterrey
          - America/Montevideo
          - America/Montserrat
          - America/Nassau
          - America/New_York
          - America/Nipigon
          - America/Nome
          - America/Noronha
          - America/North_Dakota/Beulah
          - America/North_Dakota/Center
          - America/North_Dakota/New_Salem
          - America/Ojinaga
          - America/Panama
          - America/Pangnirtung
          - America/Paramaribo
          - America/Phoenix
          - America/Port-au-Prince
          - America/Port_of_Spain
          - America/Porto_Velho
          - America/Puerto_Rico
          - America/Rainy_River
          - America/Rankin_Inlet
          - America/Recife
          - America/Regina
          - America/Resolute
          - America/Rio_Branco
          - America/Santarem
          - America/Santiago
          - America/Santo_Domingo
          - America/Sao_Paulo
          - America/Scoresbysund
          - America/Sitka
          - America/St_Barthelemy
          - America/St_Johns
          - America/St_Kitts
          - America/St_Lucia
          - America/St_Thomas
          - America/St_Vincent
          - America/Swift_Current
          - America/Tegucigalpa
          - America/Thule
          - America/Thunder_Bay
          - America/Tijuana
          - America/Toronto
          - America/Tortola
          - America/Vancouver
          - America/Whitehorse
          - America/Winnipeg
          - America/Yakutat
          - America/Yellowknife
          - Antarctica/Casey
          - Antarctica/Davis
          - Antarctica/DumontDUrville
          - Antarctica/Macquarie
          - Antarctica/Mawson
          - Antarctica/McMurdo
          - Antarctica/Palmer
          - Antarctica/Rothera
          - Antarctica/Syowa
          - Antarctica/Troll
          - Antarctica/Vostok
          - Arctic/Longyearbyen
          - Asia/Aden
          - Asia/Almaty
          - Asia/Amman
          - Asia/Anadyr
          - Asia/Aqtau
          - Asia/Aqtobe
          - Asia/Ashgabat
          - Asia/Baghdad
          - Asia/Bahrain
          - Asia/Baku
          - Asia/Bangkok
          - Asia/Beirut
          - Asia/Bishkek
          - Asia/Brunei
          - Asia/Chita
          - Asia/Choibalsan
          - Asia/Colombo
          - Asia/Damascus
          - Asia/Dhaka
          - Asia/Dili
          - Asia/Dubai
          - Asia/Dushanbe
          - Asia/Gaza
          - Asia/Hebron
          - Asia/Ho_Chi_Minh
          - Asia/Hong_Kong
          - Asia/Hovd
          - Asia/Irkutsk
          - Asia/Jakarta
          - Asia/Jayapura
          - Asia/Jerusalem
          - Asia/Kabul
          - Asia/Kamchatka
          - Asia/Karachi
          - Asia/Kathmandu
          - Asia/Khandyga
          - Asia/Kolkata
          - Asia/Krasnoyarsk
          - Asia/Kuala_Lumpur
          - Asia/Kuching
          - Asia/Kuwait
          - Asia/Macau
          - Asia/Magadan
          - Asia/Makassar
          - Asia/Manila
          - Asia/Muscat
          - Asia/Nicosia
          - Asia/Novokuznetsk
          - Asia/Novosibirsk
          - Asia/Omsk
          - Asia/Oral
          - Asia/Phnom_Penh
          - Asia/Pontianak
          - Asia/Pyongyang
          - Asia/Qatar
          - Asia/Qyzylorda
          - Asia/Rangoon
          - Asia/Riyadh
          - Asia/Sakhalin
          - Asia/Samarkand
          - Asia/Seoul
          - Asia/Shanghai
          - Asia/Singapore
          - Asia/Srednekolymsk
          - Asia/Taipei
          - Asia/Tashkent
          - Asia/Tbilisi
          - Asia/Tehran
          - Asia/Thimphu
          - Asia/Tokyo
          - Asia/Ulaanbaatar
          - Asia/Urumqi
          - Asia/Ust-Nera
          - Asia/Vientiane
          - Asia/Vladivostok
          - Asia/Yakutsk
          - Asia/Yekaterinburg
          - Asia/Yerevan
          - Atlantic/Azores
          - Atlantic/Bermuda
          - Atlantic/Canary
          - Atlantic/Cape_Verde
          - Atlantic/Faroe
          - Atlantic/Madeira
          - Atlantic/Reykjavik
          - Atlantic/South_Georgia
          - Atlantic/St_Helena
          - Atlantic/Stanley
          - Australia/Adelaide
          - Australia/Brisbane
          - Australia/Broken_Hill
          - Australia/Currie
          - Australia/Darwin
          - Australia/Eucla
          - Australia/Hobart
          - Australia/Lindeman
          - Australia/Lord_Howe
          - Australia/Melbourne
          - Australia/Perth
          - Australia/Sydney
          - Europe/Amsterdam
          - Europe/Andorra
          - Europe/Athens
          - Europe/Belgrade
          - Europe/Berlin
          - Europe/Bratislava
          - Europe/Brussels
          - Europe/Bucharest
          - Europe/Budapest
          - Europe/Busingen
          - Europe/Chisinau
          - Europe/Copenhagen
          - Europe/Dublin
          - Europe/Gibraltar
          - Europe/Guernsey
          - Europe/Helsinki
          - Europe/Isle_of_Man
          - Europe/Istanbul
          - Europe/Jersey
          - Europe/Kaliningrad
          - Europe/Kiev
          - Europe/Lisbon
          - Europe/Ljubljana
          - Europe/London
          - Europe/Luxembourg
          - Europe/Madrid
          - Europe/Malta
          - Europe/Mariehamn
          - Europe/Minsk
          - Europe/Monaco
          - Europe/Moscow
          - Europe/Oslo
          - Europe/Paris
          - Europe/Podgorica
          - Europe/Prague
          - Europe/Riga
          - Europe/Rome
          - Europe/Samara
          - Europe/San_Marino
          - Europe/Sarajevo
          - Europe/Simferopol
          - Europe/Skopje
          - Europe/Sofia
          - Europe/Stockholm
          - Europe/Tallinn
          - Europe/Tirane
          - Europe/Uzhgorod
          - Europe/Vaduz
          - Europe/Vatican
          - Europe/Vienna
          - Europe/Vilnius
          - Europe/Volgograd
          - Europe/Warsaw
          - Europe/Zagreb
          - Europe/Zaporozhye
          - Europe/Zurich
          - Indian/Antananarivo
          - Indian/Chagos
          - Indian/Christmas
          - Indian/Cocos
          - Indian/Comoro
          - Indian/Kerguelen
          - Indian/Mahe
          - Indian/Maldives
          - Indian/Mauritius
          - Indian/Mayotte
          - Indian/Reunion
          - Pacific/Apia
          - Pacific/Auckland
          - Pacific/Bougainville
          - Pacific/Chatham
          - Pacific/Chuuk
          - Pacific/Easter
          - Pacific/Efate
          - Pacific/Enderbury
          - Pacific/Fakaofo
          - Pacific/Fiji
          - Pacific/Funafuti
          - Pacific/Galapagos
          - Pacific/Gambier
          - Pacific/Guadalcanal
          - Pacific/Guam
          - Pacific/Honolulu
          - Pacific/Johnston
          - Pacific/Kiritimati
          - Pacific/Kosrae
          - Pacific/Kwajalein
          - Pacific/Majuro
          - Pacific/Marquesas
          - Pacific/Midway
          - Pacific/Nauru
          - Pacific/Niue
          - Pacific/Norfolk
          - Pacific/Noumea
          - Pacific/Pago_Pago
          - Pacific/Palau
          - Pacific/Pitcairn
          - Pacific/Pohnpei
          - Pacific/Port_Moresby
          - Pacific/Rarotonga
          - Pacific/Saipan
          - Pacific/Tahiti
          - Pacific/Tarawa
          - Pacific/Tongatapu
          - Pacific/Wake
          - Pacific/Wallis
          - UTC
      offset:
        description: The offset in seconds from UTC
        type: integer
        format: int32
  Grouping:
    type: object
    required:
      - groupBy
    properties:
      groupBy:
        type: string
        enum:
          - URL Tracking Field
          - "Element: Campaign"
          - "Element: Funnel"
          - "Element: Lander"
          - "Element: Offer"
          - "Element: Lander-Offer Category"
          - "Element: Node ID"
          - "Element: Node Name"
          - "Insight: Conversion Path (All Nodes)"
          - "Insight: Conversion Path (Landers and Offers)"
          - "Insight: MVT Combination"
          - "Insight: MVT Key-Value Pairs"
          - "Insight: Time on Page"
          - "Third Parties: Traffic Source"
          - "Third Parties: Offer Source"
          - "Traffic: Visitor ID"
          - "Traffic: Visitor Tag"
          - "Traffic: Filtered Status"
          - "Hit: Hit ID"
          - "Hit: Hit Time"
          - "Hit: Hit ID and Time"
          - "Hit: Conversion ID"
          - "Hit: Conversion TxID"
          - "Hit: Conversion Time"
          - "Hit: Time to Conversion"
          - "Click: Action Num"
          - "Click: Click Time"
          - "Device: Device Type"
          - "Device: Brand"
          - "Device: Model"
          - "Device: OS"
          - "Device: OS Version"
          - "Device: Browser"
          - "Device: Browser Version"
          - "Device: Browser Main Language"
          - "Device: Browser Other Languages"
          - "Device: User Agent"
          - "Connection: Connection Type"
          - "Connection: ISP"
          - "Connection: Mobile Carrier"
          - "Connection: Referrer"
          - "Connection: Referrer Domain"
          - "Connection: IP"
          - "Connection: Block-C IP"
          - "Location: Continent"
          - "Location: Country"
          - "Location: Country Code"
          - "Location: Region"
          - "Location: City"
          - "Location: Timezone"
          - "Time: Date"
          - "Time: HH:MM"
          - "Time: 15min. Block"
          - "Time: Week-Parting"
          - "Time: Day-Parting"
          - "Hash: Location Hash"
          - "Hash: User Agent Hash"
          - "Hash: Network Hash"
      whitelistFilters:
        description: If not empty, then only rows where at least one of the specified
          filters is true will be returned. For asset-related groupings like
          'traffic source', 'campaign', 'lander' etc, a filter must be the
          asset's id. Otherwise, for groupings like 'country', 'device type'
          etc, a filter is a case-insensitive string representing the data, like
          'Malaysia', 'Smartphone' etc... Filters can contain wildcards *
        type: array
        items:
          type: string
      blacklistFilters:
        description: If not empty, then only rows where all the specified filters are
          false will be returned. For asset-related groupings like 'traffic
          source', 'campaign', 'lander' etc, a filter must be the asset's id.
          Otherwise, for groupings like 'country', 'device type' etc, a filter
          is a case-insensitive string representing the data, like 'Malaysia',
          'Smartphone' etc... Filters can contain wildcards *
        type: array
        items:
          type: string
  MetricNames:
    type: object
    properties:
      names:
        type: string
        enum:
          - Entrances
          - Node Views
          - Lander Views
          - Lander Clicks
          - Offer Views
          - Offer Clicks
          - Conv.
          - Indirect Conv.
          - Revenue
          - Indirect Revenue
          - Cost
          - P/L
          - ROI
          - Lander CTR
          - Offer CTR
          - EPa
          - CPa
          - CVRe
          - EPe
          - CPe
          - CVRov
          - EPov
          - CPov
          - CVRlv
          - EPlv
          - CPlv
          - CVRnv
          - EPnv
          - CPnv
          - Unique Entrances
          - Unique Node Views
          - Unique Lander Views
          - Unique Lander Clicks
          - Unique Offer Views
          - Unique Offer Clicks
          - Unique Lander CTR
          - Unique Offer CTR
          - Unique CVRe
          - Unique EPe
          - Unique CPe
          - Unique CVRov
          - Unique EPov
          - Unique CPov
          - Unique CVRlv
          - Unique EPlv
          - Unique CPlv
          - Unique CVRnv
          - Unique EPnv
          - Unique CPnv
  RequestPaging:
    type: object
    properties:
      start:
        type: integer
        format: int32
        default: 0
        minimum: 0
      length:
        type: integer
        format: int32
        default: 50
        minimum: 1
  FilterColumn:
    type: object
    required:
      - columnName
      - filter
    properties:
      columnName:
        description: Name of the column to filter. It can be a grouping name as defined
          in the 'Grouping' object, or a metric name as defined in the
          'MetricNames' oject
        type: string
      filter:
        description: Grouping filters can contain wildcards '*'. Metric filters can
          contain '<', '<=', '>', '>='
        type: string
  RequestColumnFilters:
    type: object
    properties:
      filterColumns:
        type: array
        default: []
        items:
          $ref: "#/definitions/FilterColumn"
  SortingColumn:
    type: object
    properties:
      columnName:
        description: Column name to sort by. It can be a grouping name as defined in the
          'Grouping' object, or a metric name as defined in the 'MetricNames'
          oject
        type: string
        default: Entrances
      order:
        type: string
        default: desc
        enum:
          - desc
          - asc
  RequestSorting:
    type: object
    properties:
      sortingColumns:
        type: array
        default: []
        items:
          $ref: "#/definitions/SortingColumn"
  RequestOptions:
    type: object
    properties:
      viewType:
        description: "'flat' returns flattened rows. 'tree' returns full tree rows.
          'mixed' returns flattened rows except for groupings like 'conversion
          paths' that are best represented as a tree."
        type: string
        enum:
          - flat
          - tree
          - mixed
        default: tree
      showArchivedAssets:
        type: boolean
        default: true
      showFilteredTraffic:
        type: boolean
        default: false
      onlyConvertedHits:
        type: boolean
        default: false
      computeCTRConfidenceRate:
        type: boolean
        default: false
      computeCVRConfidenceRate:
        type: boolean
        default: false
      computeEPVConfidenceRate:
        type: boolean
        default: false
      confidenceRateIncludeAll:
        description: If true, then the calculated confidence rates also take rows with 0
          successes into account.
        type: boolean
        default: false
      timeAttribution:
        description: Selects whether the report time range is applied to entrance time
          or event time.
        type: string
        enum:
          - entrance
          - event
        default: entrance
      idCampaignFilter:
        type: string
        default: null
        description: If set, stats are restricted to the specified campaign
      idFunnelFilter:
        type: string
        default: null
        description: If set, stats are restricted to the specified funnel
      idTrafficSourceFilter:
        type: string
        default: null
        description: If set, stats are restricted to the specified traffic source
  DrilldownRequest:
    type: object
    required:
      - timeRange
      - timeZone
    properties:
      timeRange:
        $ref: "#/definitions/DateTimeRange"
      timeZone:
        $ref: "#/definitions/TimeZone"
      groupings:
        type: array
        items:
          $ref: "#/definitions/Grouping"
      topLevelFilters:
        type: array
        items:
          $ref: "#/definitions/Grouping"
      columnFilters:
        $ref: "#/definitions/RequestColumnFilters"
      paging:
        $ref: "#/definitions/RequestPaging"
      sorting:
        $ref: "#/definitions/RequestSorting"
      options:
        $ref: "#/definitions/RequestOptions"
      metrics:
        type: array
        description: Optional metric names to include in the response. Omit to return
          all metrics.
        items:
          type: string
      responseFormat:
        type: string
        default: standard
        description: Use compact-v1 to return report row cells as positional arrays
          [formatted, raw]. Omit or use standard for the legacy cell object
          shape.
        enum:
          - standard
          - compact-v1
  ConfidenceRate:
    type: object
    properties:
      rate:
        description: Confidence rate of being the winner. -1 means not calculated
        type: number
        format: double
        minimum: 0
        maximum: 1
  ReportColumn:
    type: object
    required:
      - name
      - type
    properties:
      name:
        description: Column name
        type: string
      type:
        description: If type is 'metric', then the column name MUST be one of the names
          defined in 'MetricNames'. If type is 'grouping', then the column name
          MUST be one of the names defined in the 'Grouping' object
        type: string
        enum:
          - grouping
          - metric
      description:
        description: Column description
        default: ""
        type: string
  ReportCell:
    type: object
    required:
      - formatted
      - raw
    properties:
      formatted:
        description: Cell's value formatted like 'Google Adwords', '0.23%' or 'N/A'.
        type: string
      raw:
        description: Non formatted cell's value like 0.213245454 for the ctr etc ...
          null means 'N/A'. If the cell is from a grouping column, then this
          value represents its id.
        type: string
  ReportRow:
    type: object
    required:
      - cells
      - rowId
    properties:
      cells:
        type: array
        items:
          $ref: "#/definitions/ReportCell"
      rowId:
        type: string
        description: Unique id of this row
      ctrLanderConfidenceRate:
        $ref: "#/definitions/ConfidenceRate"
      ctrOfferConfidenceRate:
        $ref: "#/definitions/ConfidenceRate"
      cvrConfidenceRate:
        $ref: "#/definitions/ConfidenceRate"
      epvConfidenceRate:
        $ref: "#/definitions/ConfidenceRate"
      children:
        type: array
        items:
          $ref: "#/definitions/ReportRow"
      parentRowId:
        type: string
        description: Id of the parent row or null if none. Note that a row cannot have
          children or a parent when 'RequestOptions.viewType' is 'flat'.
  Report:
    type: object
    required:
      - columns
      - rows
      - totals
      - rowsReturned
      - rowsTotal
    properties:
      columns:
        type: array
        items:
          $ref: "#/definitions/ReportColumn"
      rows:
        type: array
        items:
          $ref: "#/definitions/ReportRow"
      totals:
        $ref: "#/definitions/ReportRow"
      rowsReturned:
        description: The number of returned rows
        type: integer
        format: int32
        minimum: 0
      rowsTotal:
        description: The total number of available rows when RequestPaging is not
          restricting what is returned
        type: integer
        format: int32
        minimum: 0
  DateTimeRange:
    type: object
    required:
      - start
      - end
    description: "'start' is included while 'end' is excluded. Typically, the test
      is start <= time < end"
    properties:
      start:
        $ref: "#/definitions/DateTime"
      end:
        $ref: "#/definitions/DateTime"
  DateTime:
    type: object
    required:
      - date
      - time
    properties:
      date:
        $ref: "#/definitions/Date"
      time:
        $ref: "#/definitions/TimeHHMM"
  Date:
    type: object
    required:
      - year
      - month
      - day
    properties:
      year:
        type: integer
        format: int32
        minimum: 1970
      month:
        type: integer
        format: int32
        minimum: 1
        maximum: 12
      day:
        type: integer
        format: int32
        minimum: 1
        maximum: 31
  TimeHHMM:
    type: object
    required:
      - hour
      - minutes
    properties:
      hour:
        type: integer
        format: int32
        minimum: 0
        maximum: 23
      minutes:
        type: integer
        format: int32
        minimum: 0
        maximum: 59
  IntegerValue:
    type: object
    properties:
      value:
        type: integer
        format: int32
  KeyValuePair:
    type: object
    required:
      - key
    properties:
      key:
        type: string
      value:
        type: string
  CsvExportRequest:
    type: object
    required:
      - drilldownRequest
    properties:
      drilldownRequest:
        $ref: "#/definitions/DrilldownRequest"
      filename:
        type: string
        description: Optional filename for the exported CSV
      offset:
        type: integer
        format: int32
        default: 0
        description: Row offset for paginated exports
      limit:
        type: integer
        format: int32
        default: 10000
        description: Maximum number of rows to export per request
      addHeader:
        type: boolean
        description: Whether to include a header row in the CSV output
  CsvExportResponse:
    type: object
    properties:
      success:
        type: boolean
      complete:
        type: boolean
        description: True if all rows have been exported
      rowsWritten:
        type: integer
        format: int32
      url:
        type: string
        description: URL to download the exported CSV file (present when complete)
      nextOffset:
        type: integer
        format: int32
        description: Offset to use for the next request (present when not complete)
  BackgroundJobResponse:
    type: object
    properties:
      success:
        type: boolean
      jobIds:
        type: array
        items:
          type: string
        description: Opaque string identifiers for the background jobs created
      queuedAt:
        type: string
        format: date-time
        description: ISO 8601 timestamp when the jobs were queued
  Error:
    type: object
    required:
      - code
      - message
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
