Distribution

Report Subscriptions

Mode reports can be scheduled to run automatically, but you may also wish to subscribe to those automated runs or have them delivered somewhere. You can find out more about scheduling reports here.

You can use the subscriptions resource on a given Mode report to manage and retrieve information about one or all subscriptions for that report, which in turn you may subscribe to for email or slack delivery.

Report Subscription object

Properties

data_previews_enabled

required

boolean

data_tables_enabled

required

boolean

csv_attachments_enabled

required

boolean

pdf_attachments_enabled

required

boolean

report_links_enabled

required

boolean

email_subscriber_count

required

integer

_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.

  • email_subscription_memberships
  • report_schedule
  • self
  • slack_subscription_memberships
{
  "data_previews_enabled": true,
  "data_tables_enabled": false,
  "csv_attachments_enabled": false,
  "pdf_attachments_enabled": false,
  "report_links_enabled": true,
  "email_subscriber_count": 0,
  "_links": {
    "self": {
      "href": "/api/mode/reports/1fc156tfy213/subscriptions/6c7bcebabdce"
    },
    "report_schedule": {
      "href": "/api/mode/reports/1fc156tfy213/schedules/a2a1b9288d59"
    },
    "email_subscription_memberships": {
      "href": "/api/mode/reports/1fc156tfy213/subscriptions/6c7bhqcf9411/email_memberships"
    },
    "slack_subscription_memberships": {
      "href": "/api/mode/reports/1fc156tfy213/subscriptions/6c7bhqcf9411/slack_memberships"
    }
  },
  "_forms": {...},
}

Get subscription

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

URL Params

account

required
string Account (Workspace or User) username

report

required
string Report token

subscription

required
string ReportSubscription token
Responses

200

ReportSubscription response

401

Unauthorized

404

ReportSubscription not found

GET /{account}/reports/{report}/subscriptions/{subscription}

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{account}/reports/{report}/subscriptions/{subscription}'
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}/subscriptions/{subscription}')
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}/subscriptions/{subscription}', 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}/subscriptions/{subscription}',
  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 schedule subscriptions

To return a list of all subscriptions for a given Report Schedule, send a GET request to the subscriptions specific to that report’s schedules resource.

URL Params

account

required
string Account (Workspace or User) username

report

required
string Report token

schedule

required
string Schedule token
Responses

200

ReportSubscription collection response

401

Unauthorized

404

ReportSchedule not found

GET /{account}/reports/{report}/schedules/{schedule}/subscriptions

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{account}/reports/{report}/schedules/{schedule}/subscriptions'
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}/subscriptions')
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}/subscriptions', 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}/subscriptions',
  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 subscriptions

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

URL Params

account

required
string Account (Workspace or User) username

report

required
string Report token
Responses

200

ReportSubscription collection response

401

Unauthorized

404

Report not found

GET /{account}/reports/{report}/subscriptions

curl --include \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{account}/reports/{report}/subscriptions'
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}/subscriptions')
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}/subscriptions', 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}/subscriptions',
  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 subscription

To create a new subscription, send a POST request to the subscriptions resource.

URL Params

account

required
string Account (Workspace or User) username

report

required
string Report token
POST Body Params

Object: csv_attachments

parameters

Responses

200

ReportSubscription response

401

Unauthorized

404

Report not found

POST /{account}/reports/{report}/subscriptions

curl --include \
     --request POST \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
     --data-binary "{
  \"report_subscription\": {
    \"csv_attachments_enabled\": true,
    \"pdf_attachments_enabled\": false,
    \"data_previews_enabled\": true,
    \"data_tables_enabled\": false,
    \"report_links_enabled\": true
  }
}" \
'https://app.mode.com/api/{account}/reports/{report}/subscriptions'
require 'http'

values = {
  report_subscription: {
    csv_attachments_enabled: true,
    pdf_attachments_enabled: false,
    data_previews_enabled: true,
    data_tables_enabled: false,
    report_links_enabled: true,
  }
}

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}/subscriptions', json: values)
puts response
from urllib2 import Request, urlopen

values = """
  {
    "report_subscription": {
      "csv_attachments_enabled": true,
      "pdf_attachments_enabled": false,
      "data_previews_enabled": true,
      "data_tables_enabled": false,
      "report_links_enabled": true,
    }
  }
"""

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{account}/reports/{report}/subscriptions', 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}/subscriptions',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  },
  body: "{   \"report_subscription\": {   \"csv_attachments_enabled\": true,   \"pdf_attachments_enabled\": false,   \"data_previews_enabled\": true,   \"data_tables_enabled\": false,   \"report_links_enabled\": true   }}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

Update subscription

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

URL Params

account

required
string Account (Workspace or User) username

report

required
string Report token

subscription

required
string ReportSubscription token
POST Body Params

Object: csv_attachments

parameters

Responses

200

ReportSubscription response

401

Unauthorized

404

ReportSubscription not found

PATCH /{account}/reports/{report}/subscriptions/{subscription}

curl --include \
     --request PATCH \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
     --data-binary "{
  \"report_subscription\": {
    \"csv_attachments_enabled\": true,
    \"pdf_attachments_enabled\": false,
    \"data_previews_enabled\": true,
    \"data_tables_enabled\": false,
    \"report_links_enabled\": true
  }
}" \
'https://app.mode.com/api/{account}/reports/{report}/subscriptions/{subscription}'
require 'http'

values = {
  report_subscription: {
    csv_attachments_enabled: true,
    pdf_attachments_enabled: false,
    data_previews_enabled: true,
    data_tables_enabled: false,
    report_links_enabled: true,
  }
}

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}/subscriptions/{subscription}', json: values)
puts response
from urllib2 import Request, urlopen

values = """
  {
    "report_subscription": {
      "csv_attachments_enabled": true,
      "pdf_attachments_enabled": false,
      "data_previews_enabled": true,
      "data_tables_enabled": false,
      "report_links_enabled": true,
    }
  }
"""

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/hal+json'
}
request = Request('https://app.mode.com/api/{account}/reports/{report}/subscriptions/{subscription}', 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}/subscriptions/{subscription}',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/hal+json'
  },
  body: "{   \"report_subscription\": {   \"csv_attachments_enabled\": true,   \"pdf_attachments_enabled\": false,   \"data_previews_enabled\": true,   \"data_tables_enabled\": false,   \"report_links_enabled\": true   }}"
}, function (error, response, body) {
  console.log('Status:', response.statusCode);
  console.log('Headers:', JSON.stringify(response.headers));
  console.log('Response:', body);
});

Delete subscription

To remove a given subscription from a Report, send a DELETE request to the subscriptions resource.

URL Params

account

required
string Account (Workspace or User) username

report

required
string Report token

subscription

required
string ReportSubscription token
Responses

200

Empty body

401

Unauthorized

404

ReportSubscription not found

DELETE /{account}/reports/{report}/subscriptions/{subscription}

curl --include \
     --request DELETE \
     --header "Content-Type: application/json" \
     --header "Accept: application/hal+json" \
  'https://app.mode.com/api/{account}/reports/{report}/subscriptions/{subscription}'
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}/subscriptions/{subscription}')
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}/subscriptions/{subscription}', 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}/subscriptions/{subscription}',
  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);
});