The following document provides guidance on the series of API calls that provide the opportunity to retrieve the current download link of a scheduled custom query API report on a recurring basis.
API Call Overview
- Schedule a custom Query through the Kochava UI. For more information about creating a custom query, refer to our Query support documentation.
- Use the following call/endpoint to retrieve the schedule token:
https://reporting.api.kochava.com/v1.4/schedule/tokens
{
   "api_key": "API-KEY",
   "app_guid": "APP GUID",
   "max_tokens": 10
}
- Use the schedule token to make the following call:
 POST: https://reporting.api.kochava.com/v1.4/schedule/progress
BODY:
{
    "api_key": "AA11AA11-5F0C-4641-9E18-FA745A32B172",
    "app_guid": "kokochavabingodemo1347526e855c56f11", 
    "token":  "AA871393717333493AA"}
}
- The call returns the current token:
{
    "status": "scheduled",
    "status_date": "2017-08-01 01:00:08",
    "next_scheduled_on": "2017-09-01 00:00:00",
    "last_requested_token": "BB00015415042240BB",
    "report_type": "summary",
    "report_request": {
        "api_key": "AA11AA11-5F0C-4641-9E18-FA745A32B172",
        "app_guid": "kokochavabingodemo1347526e855c56f11",
        "traffic": [
            "click",
            "impression",
            "install"
        ],
        "traffic_grouping": [
            "network",
            "campaign",
            "tracker",
            "site",
            "creative",
            "country"
        ],
        "time_series": "24",
        "traffic_filtering": {
            "country": [
                "US"
            ],
            "network": [
                "9"
            ],
            "tracker": [
                "4718722"
            ]
        },
        "time_zone": "Singapore",
        "delivery_format": "csv",
        "delivery_method": [
            "S3link"
        ],
        "notify": [
            "test@kochava.com"
        ],
        "frequency": "monthly",
        "run_on": "1",
        "previous_time": "1",
        "delay": "0",
        "template_name": "Network Summary"
    }
}
- Use the current token to make the following call:
 POST: https://reporting.api.kochava.com/v1.4/progress
BODY:
{
    "api_key": "AA11AA11-5F0C-4641-9E18-FA745A32B172",
    "app_guid": "kokochavabingodemo1347526e855c56f11", 
    "token":  "BB00015415042240BB"}
}
- The call will return the following payload, which includes the download link to the current report:
{
    "status": "completed",
    "status_date": "2017-08-01 01:00:11",
    "progress": "100",
    "report": "http://kochava-reporting.s3.amazonaws.com/KRS_Sch900001541504224000_14398519_kokochavabingodemo1347526e855c56f11.click.install.impression_network.campaign.tracker.site.creative.country_201707010800-201708010800-TZ_Singapore-TS24h.country.network.tracker.csv?AWSAccessKeyId=AKIAJ4JWD2OCXDYVOG4B&Expires=1502413211&Signature=AaAaA1C4OLcl1c%2FLJhPrhwdxjdE%3D",
    "report_type": "summary",
    "report_request": {
        "api_key": "AA11AA11-5F0C-4641-9E18-FA745A32B172",
        "app_guid": "kokochavabingodemo1347526e855c56f11",
        "time_start": "1498896000",
        "time_end": "1501574400",
        "traffic": [
            "click",
            "impression",
            "install"
        ],
        "traffic_grouping": [
            "network",
            "campaign",
            "tracker",
            "site",
            "creative",
            "country"
        ],
        "time_series": "24",
        "traffic_filtering": {
            "country": [
                "US"
            ],
            "network": [
                "9"
            ],
            "tracker": [
                "4718722"
            ]
        },
        "time_zone": "Singapore",
        "delivery_format": "csv",
        "delivery_method": [
            "S3link"
        ],
        "notify": [
            "test@kochava.com"
        ],
        "frequency": "monthly",
        "run_on": "1",
        "previous_time": "1",
        "delay": "0",
        "template_name": "Network Summary"
    }
}
