GET /api/report_templates
List all report templates

GET /api/locations/:location_id/report_templates
List all report templates per location

GET /api/organizations/:organization_id/report_templates
List all report templates per organization

Examples

GET /api/report_templates
200
{
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [
    {
      "description": null,
      "created_at": "2021-09-01 12:42:34 UTC",
      "updated_at": "2021-09-01 12:42:34 UTC",
      "name": "report_template92",
      "id": 1007981707
    }
  ]
}

Params

Param name Description
location_id
optional

Scope by locations

Validations:

  • Must be a Integer

organization_id
optional

Scope by organizations

Validations:

  • Must be a Integer

search
optional

filter results

Validations:

  • Must be a String

order
optional

Sort and order by a searchable field, e.g. ‘id DESC’

Validations:

  • Must be a String

page
optional

Page number, starting at 1

Validations:

  • Must be a number.

per_page
optional

Number of results per page to return, ‘all’ to return all results

Validations:

  • Must match regular expression /\A([1-9]\d|all)\Z$/.

Search fields

Field name Type Possible values
default true, false
location string
location_id integer
locked true, false
name string
organization string
organization_id integer
snippet true, false
template text

GET /api/report_templates/:id
Show a report template

Examples

GET /api/report_templates/1007981722-report_template104
200
{
  "template": "template content 93",
  "default": false,
  "snippet": false,
  "locked": false,
  "description": null,
  "created_at": "2021-09-01 12:42:36 UTC",
  "updated_at": "2021-09-01 12:42:36 UTC",
  "name": "report_template104",
  "id": 1007981722,
  "locations": [],
  "organizations": []
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.


POST /api/report_templates
Create a report template

Examples

POST /api/report_templates
{
  "report_template": {
    "name": "report_template_test",
    "template": "a,b,c"
  }
}
201
{
  "template": "a,b,c",
  "default": false,
  "snippet": false,
  "locked": false,
  "description": null,
  "created_at": "2021-09-01 12:42:35 UTC",
  "updated_at": "2021-09-01 12:42:35 UTC",
  "name": "report_template_test",
  "id": 1007981716,
  "locations": [],
  "organizations": []
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

report_template
required

Validations:

  • Must be a Hash

report_template[name]
required

Validations:

  • Must be a String

report_template[description]
optional , nil allowed

Validations:

  • Must be a String

report_template[template]
required

Validations:

  • Must be a String

report_template[snippet]
optional , nil allowed

Validations:

  • Must be one of: true, false, 1, 0.

report_template[audit_comment]
optional , nil allowed

Validations:

  • Must be a String

report_template[locked]
optional , nil allowed

Whether or not the template is locked for editing

Validations:

  • Must be one of: true, false, 1, 0.

report_template[default]
optional , nil allowed

Whether or not the template is added automatically to new organizations and locations

Validations:

  • Must be one of: true, false, 1, 0.

report_template[location_ids]
optional , nil allowed

REPLACE locations with given ids

Validations:

  • Must be an array of any type

report_template[organization_ids]
optional , nil allowed

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type


POST /api/report_templates/import
Import a report template

Examples

POST /api/report_templates/import
{
  "report_template": {
    "name": "report_template110",
    "template": "b"
  }
}
201
{
  "template": "b",
  "name": "report_template110",
  "id": 1007981730,
  "snippet": false,
  "description": null,
  "template_kind_id": null,
  "created_at": "2021-09-01T12:42:37.466Z",
  "updated_at": "2021-09-01T12:42:37.505Z",
  "locked": false,
  "default": false,
  "vendor": null,
  "os_family": null
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

report_template
required

Validations:

  • Must be a Hash

report_template[name]
optional

template name

Validations:

  • Must be a String

report_template[template]
optional

template contents including metadata

Validations:

  • Must be a String

report_template[location_ids]
optional , nil allowed

REPLACE locations with given ids

Validations:

  • Must be an array of any type

report_template[organization_ids]
optional , nil allowed

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type

options
optional

Validations:

  • Must be a Hash

options[force]
optional , nil allowed

use if you want update locked templates

Validations:

  • Must be one of: true, false, 1, 0.

options[associate]
optional , nil allowed

determines when the template should associate objects based on metadata, new means only when new template is being created, always means both for new and existing template which is only being updated, never ignores metadata

Validations:

  • Must be one of: new, always, never.

options[lock]
optional , nil allowed

lock imported templates (false by default)

Validations:

  • Must be one of: true, false, 1, 0.

options[default]
optional , nil allowed

makes the template default meaning it will be automatically associated with newly created organizations and locations (false by default)

Validations:

  • Must be one of: true, false, 1, 0.


GET /api/report_templates/revision

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

version
optional

template version

Validations:

  • Must be a String


PUT /api/report_templates/:id
Update a report template

Examples

PUT /api/report_templates/1007981708
{
  "report_template": {
    "template": ""
  }
}
422
{
  "error": {
    "id": 1007981708,
    "errors": {
      "template": [
        "can't be blank"
      ]
    },
    "full_messages": [
      "Template can't be blank"
    ]
  }
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be a String

report_template
required

Validations:

  • Must be a Hash

report_template[name]
optional

Validations:

  • Must be a String

report_template[description]
optional , nil allowed

Validations:

  • Must be a String

report_template[template]
optional

Validations:

  • Must be a String

report_template[snippet]
optional , nil allowed

Validations:

  • Must be one of: true, false, 1, 0.

report_template[audit_comment]
optional , nil allowed

Validations:

  • Must be a String

report_template[locked]
optional , nil allowed

Whether or not the template is locked for editing

Validations:

  • Must be one of: true, false, 1, 0.

report_template[default]
optional , nil allowed

Whether or not the template is added automatically to new organizations and locations

Validations:

  • Must be one of: true, false, 1, 0.

report_template[location_ids]
optional , nil allowed

REPLACE locations with given ids

Validations:

  • Must be an array of any type

report_template[organization_ids]
optional , nil allowed

REPLACE organizations with given ids.

Validations:

  • Must be an array of any type


DELETE /api/report_templates/:id
Delete a report template

Examples

DELETE /api/report_templates/1007981709-report_template94
{
  "report_template": {}
}
200
{
  "id": 1007981709,
  "name": "report_template94",
  "template": "template content 83",
  "snippet": false,
  "template_kind_id": null,
  "created_at": "2021-09-01T12:42:34.613Z",
  "updated_at": "2021-09-01T12:42:34.613Z",
  "locked": false,
  "default": false,
  "vendor": null,
  "os_family": null,
  "description": null
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be a String


POST /api/report_templates/:id/clone
Clone a template

Examples

POST /api/report_templates/1007981712-report_template97/clone
{
  "report_template": {
    "name": ""
  }
}
422
{
  "error": {
    "id": null,
    "errors": {
      "name": [
        "can't be blank"
      ]
    },
    "full_messages": [
      "Name can't be blank"
    ]
  }
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

report_template
required

Validations:

  • Must be a Hash

report_template[name]
required

template name

Validations:

  • Must be a String


GET /api/report_templates/:id/export
Export a report template to ERB

Examples

GET /api/report_templates/1007981714-report_template99/export
200
<%#
name: report_template99
snippet: false
model: ReportTemplate
-%>
template content 88

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.


POST /api/report_templates/:id/generate
Generate report from a template

Examples

POST /api/report_templates/1007981723/generate
{
  "report_format": "html",
  "report_template": {}
}
200
<html><head><title>report_template60</title><style>th { background-color: black; color: white; }
table,th,td { border-collapse: collapse; border: 1px solid black; }
</style></head><body><table><thead><tr><th>&lt;b&gt;</th></tr></thead><tbody><tr><td>1</td></tr><tr><td>&lt;br&gt;</td></tr></tbody></table></body></html>

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

input_values
optional

Hash of input values where key is the name of input, value is the value for this input

Validations:

  • Must be a Hash

gzip
optional

Compress the report uzing gzip

Validations:

  • Must be one of: true, false, 1, 0.

report_format
optional

Report format, defaults to ‘csv’

Validations:

  • Must be one of: csv, json, yaml, html.


POST /api/report_templates/:id/schedule_report
Schedule generating of a report

The reports are generated asynchronously. If mail_to is not given, action returns an url to get resulting report from (see report_data).

Examples

POST /api/report_templates/:id/schedule_report/
200
{
  "job_id": UNIQUE-REPORT-GENERATING-JOB-UUID
  "data_url": "/api/v2/report_templates/1/report_data/UNIQUE-REPORT-GENERATING-JOB-UUID"
}
POST /api/report_templates/1007981704/schedule_report
{
  "report_template": {}
}
200
{
  "job_id": "JOB-UNIQUE-IDENTIFIER",
  "data_url": "/api/v2/report_templates/1007981704-report_template182/report_data/JOB-UNIQUE-IDENTIFIER"
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

input_values
optional

Hash of input values where key is the name of input, value is the value for this input

Validations:

  • Must be a Hash

gzip
optional

Compress the report using gzip

Validations:

  • Must be one of: true, false, 1, 0.

mail_to
optional

If set, scheduled report will be delivered via e-mail. Use ‘,’ to separate multiple email addresses.

Validations:

  • Must be a String

generate_at
optional

UTC time to generate report at

Validations:

  • Must be a String

report_format
optional

Report format, defaults to ‘csv’

Validations:

  • Must be one of: csv, json, yaml, html.


GET /api/report_templates/:id/report_data/:job_id
Downloads a generated report

Returns the report data as a raw response. In case the report hasn’t been generated yet, it will return an empty response with http status 204 - NoContent.

Examples

GET /api/report_templates/1007981704/report_data/JOBID
422
{
  "errors": null
}

Params

Param name Description
location_id
optional

Set the current location context for the request

Validations:

  • Must be a Integer

organization_id
optional

Set the current organization context for the request

Validations:

  • Must be a Integer

id
required

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hypen(-) with no leading or trailing space.

job_id
required

ID assigned to generating job by the schedule command

Validations:

  • Must be a String