Distribution

Report Schedules

Mode reports can be scheduled to run automatically, and even with specific report parameters. You can find out more about scheduling reports here.

You can use the schedules resource on a given Mode report to manage and retrieve information about one or all schedules for that report.

Report Schedule object

Properties

name

required

string

token

required

string

parameters

required

string

created_at

required

string

updated_at

required

string

retry_state

required

string

retry_count

required

string

retry_delay

required

string

timeout

required

string

last_run_at

required

string

last_succeeded_at

required

string

last_scheduled_run

required

string

next_scheduled_run

required

string

report_name

required

string

delivery

required

string

report_token

required

string

report_type

required

string

subscribed

required

string

subscriber_count

required

string

_links

required

object

All resource responses contain a set of links that describe other related resources or actions that you can take on this resource. A link is comprised of two main pieces: its name (which describes its relationship to this resource) and its href (the URL of the related action or resource). All resources have at least a _self link which is the URL that will return a representation of this resource.

  • account
  • creator
  • report
  • report_runs
  • report_subscriptions
  • report_web
  • self
{
  "token": "9288da2a1b59",
  "name": "Qui Officia",
  "parameters": {},
  "created_at": "2019-05-08T22:12:19.237Z",
  "updated_at": "2020-04-06T20:02:02.321Z",
  "retry_state": "ok",
  "retry_count": 1,
  "retry_delay": 0,
  "timeout": 86100,
  "last_run_at": "2020-04-06T20:01:53.431Z",
  "last_succeeded_at": "2020-04-06T20:02:02.313Z",
  "last_scheduled_run": "2020-04-06T20:00:00.000+00:00",
  "next_scheduled_run": "2020-04-07T20:00:00.000+00:00",
  "subscribed": false,
  "frequency": "daily",
  "time_zone": "UTC",
  "hour": "8:00 pm",
  "minute": "the top of the hour",
  "_links": {
    "account": {
      "href": "/api/hogwarts"
    },
    "creator": {
      "href": "/api/albus_dumbledore"
    },
    "self": {
      "href": "/api/hogwarts/reports/1fc11c31fdc4/schedules/9288da2a1b59"
    },
    "report": {
      "href": "/api/hogwarts/reports/1fc11c31fdc4"
    },
    "report_runs": {
      "href": "/api/hogwarts/reports/1fc11c31fdc4/schedules/9288da2a1b59/runs?embed[report_runs][executed_by]=1"
    },
    "report_subscriptions": {
      "href": "/api/hogwarts/reports/1fc11c31fdc4/schedules/9288da2a1b59/subscriptions"
    }
  },
  "_forms": {...}
}

Get a report schedule

To retrieve information about a single schedule, send a GET request including the report and schedule tokens to the schedules resource.

URL Params

workspace

required
string Workspace username

report

required
string Report token

schedule

required
string Schedule token
Responses

200

Report Schedule response

401

Unauthorized

404

ReportSchedule not found

GET /{workspace}/reports/{report}/schedules/{schedule}

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}'
require 'http'

username = 'your_api_key'
password = 'your_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .get('https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}', headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'GET',
  url: 'https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

List schedules for a report

To return a list of all schedules for a given Report, send a GET request to the schedules resource.

URL Params

workspace

required
string Workspace username

report

required
string Report token
Responses

200

Report Schedule collection response

401

Unauthorized

404

Report not found

GET /{workspace}/reports/{report}/schedules

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{account}/reports/{report}/schedules'
require 'http'

username = 'your_api_key'
password = 'your_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .get('https://app.mode.com/api/{account}/reports/{report}/schedules')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{account}/reports/{report}/schedules', headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'GET',
  url: 'https://app.mode.com/api/{account}/reports/{report}/schedules',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

Create a report schedule

To create a new schedule, send a POST request to the schedules resource.

URL Params

workspace

required
string Workspace username

report

required
string Report token
POST Body Params

Object: cron

freq

How often this schedule repeats

Example: hourly

day_of_month

The day of the month this schedule runs on

Example: 15

day_of_week

The day of the week this schedule runs on (Sunday to Saturday)

Example: 5

hour

The hour of the day this schedule runs at (12am to 11pm)

Example: 8

minute

The minute of the hour this schedules runs at

Example: 0

time_zone

The name of the time zone in which to evaluate the scheduled time to run

Example: Pacific Time (US & Canada)

Responses

200

Report Schedule response

401

Unauthorized

404

Report not found

POST /{workspace}/reports/{report}/schedules

curl --include \
     --request POST \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
     --data-binary "{
  \"report_schedule\": {
    \"name\": \"Qui Officia\",
    \"cron\": {
      \"freq\": \"daily\",
      \"hour\": 14,
      \"time_zone\": \"UTC\",
      \"day_of_week\": 1,
      \"day_of_month\": 1,
      \"minute\": 0
    },
    \"params\": {
      \"foo\": \"bar\"
    },
    \"timeout\": 900
  }
}" \
'https://app.mode.com/api/{account}/reports/{report}/schedules'
require 'http'

values = {
  report_schedule: {
    name: 'Qui Officia',
    cron:{
      freq: 'daily',
      hour: 14,
      time_zone: 'UTC',
      day_of_week: 1,
      day_of_month: 1,
      minute: 0
    },
    params:{
      foo: 'bar'
     },
    timeout:900
  }
}

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .post('https://app.mode.com/api/{account}/reports/{report}/schedules', json: values)
puts response
from urllib2 import Request, urlopen

values = """
  {
    "report_schedule": {
      "name": "Qui Officia",
      "cron": {
        "freq": "daily",
        "hour": 14,
        "time_zone": "UTC',
        "day_of_week": 1,
        "day_of_month": 1,
        "minute": 0
      }
      "params":{
        "foo": "bar"
       }
      "timeout":900
     }
  }
"""

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{account}/reports/{report}/schedules', data=values, headers=headers)

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'POST',
  url: 'https://app.mode.com/api/{account}/reports/{report}/schedules',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  },
  body: "{  \"report_schedule\": {    \"cron\": {    \"freq\": \"daily\",    \"hour\" :14,    \"time_zone\": \"UTC\",    \"day_of_week\": 1,    \"day_of_month\": 1,    \"minute\": 0    },    \"params\": {    \"foo\": \"bar\"    },    \"timeout\": 900    }}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

Update a report schedule

To update a schedule, send a PATCH request including the corresponding report and schedule tokens to the schedules resource.

URL Params

workspace

required
string Workspace username

report

required
string Report token

schedule

required
string Schedule token
POST Body Params

Object: cron

freq

How often this schedule repeats

Example: hourly

day_of_month

The day of the month this schedule runs on

Example: 15

day_of_week

The day of the week this schedule runs on (Sunday to Saturday)

Example: 5

hour

The hour of the day this schedule runs at (12am to 11pm)

Example: 8

minute

The minute of the hour this schedules runs at

Example: 0

time_zone

The name of the time zone in which to evaluate the scheduled time to run

Example: Pacific Time (US & Canada)

Responses

200

Report Schedule response

401

Unauthorized

404

ReportSchedule not found

PATCH /{workspace}/reports/{report}/schedules/{schedule}

curl --include \
     --request PATCH \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
     --data-binary "{
  \"report_schedule\": {
    \"name\": \"Qui Officia\",
    \"cron\": {
      \"freq\": \"daily\",
      \"hour\": 14,
      \"time_zone\": \"UTC\",
      \"day_of_week\": 1,
      \"day_of_month\": 1,
      \"minute\": 0
    },
    \"params\": {
      \"foo\": \"bar\"
    },
    \"timeout\": 900
  }
}" \
'https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}'
require 'http'

values = {
  report_schedule: {
    name: 'Qui Officia',
    cron:{
      freq: 'daily',
      hour: 14,
      time_zone: 'UTC',
      day_of_week: 1,
      day_of_month: 1,
      minute: 0
    },
    params:{
      foo: 'bar'
     },
    timeout:900
  }
}

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .patch('https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}', json: values)
puts response
from urllib2 import Request, urlopen

values = """
  {
    "report_schedule": {
      "name": "Qui Officia",
      "cron": {
        "freq": "daily",
        "hour": 14,
        "time_zone": "UTC',
        "day_of_week": 1,
        "day_of_month": 1,
        "minute": 0
      }
      "params":{
        "foo": "bar"
       }
      "timeout":900
     }
  }
"""

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}', data=values, headers=headers)
request.get_method = lambda: 'PATCH'

response_body = urlopen(request).read()
print(response_body)
var request = require('request');

request({
  method: 'PATCH',
  url: 'https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  },
  body: "{  \"report_schedule\": {    \"name\": \"Qui Officia\",    \"cron\": {    \"freq\": \"daily\",    \"hour\" :14,    \"time_zone\": \"UTC\",    \"day_of_week\": 1,    \"day_of_month\": 1,    \"minute\": 0    },    \"params\": {    \"foo\": \"bar\"    },    \"timeout\": 900    }}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

Delete a report schedule

To remove a given schedule from a Report, send a DELETE request to the schedules resource.

URL Params

workspace

required
string Workspace username

report

required
string Report token

schedule

required
string Schedule token
Responses

200

Empty body

401

Unauthorized

404

ReportSchedule not found

DELETE /{workspace}/reports/{report}/schedules/{schedule}

curl --include \
     --request DELETE \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}'
require 'http'

username = 'your_api_key'
password = 'your_api_secret'

headers = {
  content_type: 'application/json',
  accept: 'application/hal+json'
}

response = HTTP.basic_auth(user: username, pass: password)
               .headers(headers)
               .delete('https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}')
puts response
from urllib2 import Request, urlopen

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}', headers=headers)
request.get_method = lambda: 'DELETE'

response_body = urlopen(request).read()
var request = require('request');

request({
  method: 'DELETE',
  url: 'https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  }}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});