report.create

Description

object report.create(object/array reports)

This method allows to create new scheduled reports.

This method is only available to Admin and Super admin user types. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object/array) Scheduled reports to create.

Additionally to the standard scheduled report properties, the method accepts the following parameters.

ParameterTypeDescription
usersobject/array of objectsUsers to send the report to.
user_groupsobject/array of objectsUser groups to send the report to.

Return values

(object) Returns an object containing the IDs of the created scheduled reports under the reportids property. The order of the returned IDs matches the order of the passed scheduled reports.

Examples

Creating a scheduled report

Create a weekly report that will be prepared for the previous week every Monday-Friday at 12:00 from 2021-04-01 to 2021-08-31.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "report.create",
  4. "params": {
  5. "userid": "1",
  6. "name": "Weekly report",
  7. "dashboardid": "1",
  8. "period": "1",
  9. "cycle": "1",
  10. "start_time": "43200",
  11. "weekdays": "31",
  12. "active_since": "2021-04-01",
  13. "active_till": "2021-08-31",
  14. "subject": "Weekly report",
  15. "message": "Report accompanying text",
  16. "status": "1",
  17. "description": "Report description",
  18. "users": [
  19. {
  20. "userid": "1",
  21. "access_userid": "1",
  22. "exclude": "0"
  23. },
  24. {
  25. "userid": "2",
  26. "access_userid": "0",
  27. "exclude": "1"
  28. }
  29. ],
  30. "user_groups": [
  31. {
  32. "usrgrpid": "7",
  33. "access_userid": "0"
  34. }
  35. ]
  36. },
  37. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  38. "id": 1
  39. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "reportids": [
  5. "1"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

CReport::create() in ui/include/classes/api/services/CReport.php.