# Report schedule

Contains report schedule object description and API calls to interact with it.

## schedule\_entry object:

```json
{
  "id": 1,
  "enabled": true,
  "parameters": {
    "period": "1m",
    "schedule": {
      "type": "weekdays",
      "weekdays": [1, 2, 3, 4, 5]
    },
    "report": {
      "trackers": [1],
      "title": "Title",
      "time_filter": {
        "from": "00:00:00",
        "to": "23:59:59",
        "weekdays": [1, 2, 3, 4, 5, 6, 7]
      },
      "geocoder": "yandex",
      "plugin": {
        "plugin_id": 4,
        "show_idle_duration": false
      }
    },
    "emails": ["email@example.ru"],
    "email_format": "pdf",
    "email_zip": false,
    "sending_time": "12:00:00"
  },
  "fire_time": "2014-09-05 00:00:00",
  "last_result": {
    "success": true,
    "id": 1
  }
}
```

* `id` - int. Schedule id, ignored on create.
* `enabled` - boolean. `true` if the scheduled report enabled.
* `period` - string. Report period, "Xm" | "w" | "d" | "y".
* `emails` - optional string array. List of emails.
* `email_format` - [enum](https://navixy.com/docs/navixy-api/user-api/backend-api/..#data-types). Can be "pdf" | "xls".
* `sending_time` - optional string. Local time for sending reports, default "00:00:00", hourly granularity.
* `fire_time` - optional string. Last schedule fire time, ignored on create/update.
* `last_result` object with last report creation result.
  * `id` - int. An ID of generated report.

## API actions

API path: `/report/schedule`.

### create

Creates a new report schedule entry.

**required sub-user rights**: `reports`.

#### Parameters

| name     | description                                                        | type        |
| -------- | ------------------------------------------------------------------ | ----------- |
| schedule | Schedule object without fields "id", "fire\_time", "last\_result". | JSON object |

#### Example

cURL

{% code overflow="wrap" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/report/schedule/create' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "a6aa75587e5c59c32d347da438505fc3", "schedule": {"enabled": true, "parameters": {"report": {"title": "Trip report", "trackers": [669673], "time_filter": {"from": "00:00:00", "to": "23:59:59", "weekdays": [1,2,3,4,5,6,7]}, "plugin": {"hide_empty_tabs": true, "plugin_id": 4, "show_seconds": false, "include_summary_sheet_only": false, "split": true, "show_idle_duration": false, "show_coordinates": false, "filter": true, "group_by_driver": false}}, "period": "1w", "email_zip": false, "email_format": "xls", "emails": ["test@example.com"], "sending_time": "00:00:00", "schedule": {"type": "weekdays", "weekdays": [1]}}}}}'
```

{% endcode %}

#### Response

```json
{
  "success": true,
  "id": 111
}
```

* `id` - int. An ID of the created schedule entry.

#### Errors

* 217 - List contains nonexistent entities - if one or more of tracker IDs belong to nonexistent tracker (or to a tracker belonging to different user).
* 222 - Plugin not found - if specified report plugin not found.
* 236 - Feature unavailable due to.

### delete

Deletes report schedule with the specified ID.

**required sub-user rights**: `reports`.

#### Parameters

| name         | description                          | type |
| ------------ | ------------------------------------ | ---- |
| schedule\_id | ID of the report schedule to delete. | int  |

#### Examples

{% tabs %}
{% tab title="cURL" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/report/schedule/delete' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "a6aa75587e5c59c32d347da438505fc3", "schedule_id": 1234567}'
```

{% endtab %}

{% tab title="HTTP GET" %}
{% code overflow="wrap" %}

```http
https://api.eu.navixy.com/v2/report/schedule/delete?hash=a6aa75587e5c59c32d347da438505fc3&schedule_id=1234567
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response

```json
{
  "success": true
}
```

#### Errors

* 201 - Not found in the database - if there is no schedule with specified ID.

### list

Get all report schedules belonging to user.

**required sub-user rights**: `reports`.

#### Parameters

Only API key `hash`.

#### Examples

{% tabs %}
{% tab title="cURL" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/report/schedule/list' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "a6aa75587e5c59c32d347da438505fc3"}'
```

{% endtab %}

{% tab title="HTTP GET" %}
{% code overflow="wrap" %}

```http
https://api.eu.navixy.com/v2/report/schedule/list?hash=a6aa75587e5c59c32d347da438505fc3
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response

```json
{
  "success": true,
  "list": [
    {
      "id": 1,
      "enabled": true,
      "parameters": {
        "period": "1m",
        "schedule": {
          "type": "weekdays",
          "weekdays": [1, 2, 3, 4, 5]
        },
        "report": {
          "trackers": [1],
          "title": "Title",
          "time_filter": {
            "from": "00:00:00",
            "to": "23:59:59",
            "weekdays": [1, 2, 3, 4, 5, 6, 7]
          },
          "geocoder": "yandex",
          "plugin": {
            "plugin_id": 4,
            "show_idle_duration": false
          }
        },
        "emails": ["email@example.ru"],
        "email_format": "pdf",
        "email_zip": false,
        "sending_time": "12:00:00"
      },
      "fire_time": "2014-09-05 00:00:00",
      "last_result": {
        "success": true,
        "id": 1
      }
    }
  ]
}
```

#### Errors

[General](https://navixy.com/docs/navixy-api/user-api/errors#error-codes) types only.

### update

Update existing report schedule.

**required sub-user rights**: `reports`.

#### Parameters

| name     | description                                                  | type        |
| -------- | ------------------------------------------------------------ | ----------- |
| schedule | Schedule object without fields "fire\_time", "last\_result". | JSON object |

#### Example

cURL

{% code overflow="wrap" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/report/schedule/update' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "a6aa75587e5c59c32d347da438505fc3", "schedule": {"enabled": true, "parameters": {"report": {"title": "Trip report", "trackers": [669673], "time_filter": {"from": "00:00:00", "to": "23:59:59", "weekdays": [1,2,3,4,5,6,7]}, "plugin": {"hide_empty_tabs": true, "plugin_id": 4, "show_seconds": false, "include_summary_sheet_only": false, "split": true, "show_idle_duration": false, "show_coordinates": false, "filter": true, "group_by_driver": false}}, "period": "1w", "email_zip": false, "email_format": "xls", "emails": ["test@example.com"], "sending_time": "00:00:00", "schedule": {"type": "weekdays", "weekdays": [1]}}}}}'
```

{% endcode %}

#### Response

```json
{
  "success": true
}
```

#### Errors

* 217 - List contains nonexistent entities - if one or more of tracker IDs belong to nonexistent tracker (or to a tracker belonging to different user).
* 222 - Plugin not found - if specified report plugin not found.
* 236 - Feature unavailable due to tariff restrictions - if device's tariff does not allow usage of reports.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://navixy.com/docs/navixy-api/user-api/backend-api/resources/commons/report/report_schedule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
