Scheduled Report Runs

This example shows how to use the API to configure a report to run on a regularly occurring schedule.

Endpoints used

Supported methods:

  • GET: returns all schedules for a given report
  • POST: creates a new schedule

How this example works

In this example, the create_scheduled_report_run method makes a POST request to app.mode.com/api/{organization}/reports/{report_token}/schedules, creating a schedule. You can specify the time interval and parameter values in the payload.

To try it yourself

  • Download the example code to a .py file
  • Input the API token, API secret, organization name, and other custom information as needed. An API token and secret can be generated here
  • Save the .py file in your desired directory
  • Open the terminal and navigate to that directory
  • Run the command python3 {file_name}.py
  • All of our Python recipes require Python 3
import json
import requests

from requests.auth import HTTPBasicAuth

host = 'https://modeanalytics.com'
org = 'org_name'
un = 'api_token'
pw = 'api_secret'

def create_scheduled_report_run(report_token):
  #create schedule and set up parameters the schedule should be run with
  url = '%s/api/%s/reports/%s/schedules' % (host, org, report_token)
  headers = {'Content-Type': 'application/json'}
  payload = {'report_schedule': {
                'freq': 'daily',
                'hour': 14,
                'time_zone': 'UTC',
                'day_of_week': 1,
                'day_of_month': 1,
                'minute': 0
              # params optional
                'foo': 'bar'
  r = requests.post(url, headers=headers, auth=HTTPBasicAuth(un, pw), json=payload)
  return r.status_code

const request = require('request-promise');

const host = 'https://modeanalytics.com';
const org = 'orgName';
const username = 'apiToken';
const password = 'apiSecret';

const createScheduledReportRun = async reportToken => {
  // create schedule and set up parameters the schedule should be run with
  const payload = {
    report_schedule: {
      cron: {
        freq: 'daily',
        hour: 14,
        time_zone: 'UTC',
        day_of_week: 1,
        day_of_month: 1,
        minute: 0,
      // params optional
      params: {
        foo: 'bar',
      timeout: 900,
    trk_source: 'report',

  return await request({
    method: 'POST',
    url: `${host}/api/${org}/reports/${reportToken}/schedules`,
    auth: { username, password },
    json: true,
    body: payload,