# Tracker plans

User of **dealer** can switch tracker from the plan **t1** to plan **t2** if:

1. Tracker belongs to user and isn't a **clone**.
2. Tracker's tariff last changed more than **tariff.freeze.period** (config option. default 30 days) ago.
3. **t1.tariff\_id** != **t2.tariff\_id**, i.e. the new plan must be different from the current.
4. **t1.dealer\_id** = **t2.dealer\_id** = **dealer.effectiveDealerId**, i.e. current and new plans must belong to user's effective dealer.
5. **t2.active** = **1**, i.e. new plan is **active** (plan's option "Allow users to switch to this plan independently" in **panel** is set **on**).
6. **t1.grouping** = **t2.grouping**, i.e. user can change tariff only within one group of tariffs.
7. **t2.device** = **tracker**, i.e. new plan must be for trackers.
8. The new plan is [available to user's legal type](https://navixy.com/docs/navixy-api/user-api/backend-api/resources/billing/index#plan).

User's **effective dealer** is

1. User's dealer if its **dealer\_id** = **defaultDealerId** (config option) or **dogovor\_type** = 'paas'.
2. Parent of user's dealer otherwise.

## API actions

API path: `/tariff/tracker/`.

### change

Changes plan of tracker (with `tracker_id`) to new plan (with `tariff_id`).

**required sub-user rights**: `admin` (available only to master users).

| name        | description                                                                                     | type |
| ----------- | ----------------------------------------------------------------------------------------------- | ---- |
| tracker\_id | ID of a tracking device (aka "object\_id"). The tracking device must belong to authorized user. | int  |
| tariff\_id  | If of the new plan.                                                                             | int  |

#### Examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/tariff/tracker/change' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "22eac1c27af4be7b9d04da2ce1af111b", "tracker_id": 345215, "tariff_id": 12}'
```

{% endcode %}
{% endtab %}

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

```
https://api.eu.navixy.com/v2/tariff/tracker/change?hash=a6aa75587e5c59c32d347da438505fc3&tracker_id=345215&tariff_id=12
```

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

#### Response

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

#### Errors

* 201 – Not found in the database - if user doesn't have trackers with given `tracker_id`.
* 219 – Not allowed for clones of the device.
* 237 – Invalid plan - if there are no plan with specified `tariff_id` and belongs to user's **effective dealer**.
* 221 - Device limit exceeded – when new plan limit for devices is less than the current count of devices in the account.
* 238 - Changing plan is not allowed – user can't switch tracker to that plan.
* 239 – New plan doesn't exist.
* 240 - Not allowed changing plan too frequently – plan last changed less or equal to 30 days (**tariff.freeze.period** config option).

### list

List plans on which user can switch the passed tracker (even when tariff last changed less or equal than **tariff.freeze.period** time ago).

#### Parameters

| name        | description                                                                   | type |
| ----------- | ----------------------------------------------------------------------------- | ---- |
| tracker\_id | ID of the tracker (aka "object\_id"). Tracker must belong to authorized user. | int  |

#### Examples

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

```sh
curl -X POST 'https://api.eu.navixy.com/v2/tariff/tracker/list' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "22eac1c27af4be7b9d04da2ce1af111b", "tracker_id": 345215}'
```

{% endtab %}

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

```http
https://api.eu.navixy.com/v2/tariff/tracker/list?hash=a6aa75587e5c59c32d347da438505fc3&tracker_id=345215
```

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

#### Response

```json
{
  "success": true,
  "list": [
    {
      "id": 10,
      "name": "Business",
      "group_id": 2,
      "active": true,
      "type": "monthly",
      "price": 13.0,
      "early_change_price": 23.0,
      "device_limit": 1000,
      "has_reports": true,
      "paas_free": false,
      "store_period": "12m",
      "features": [
        "map_layers"
      ],
      "map_filter": {
        "exclusion": true,
        "values": []
      }
    }
  ],
  "days_to_next_change": 11
}
```

* `list` - array of objects. List of [plan objects](https://navixy.com/docs/navixy-api/user-api/backend-api/resources/billing/index#plan-object).
* `days_to_next_change` - int. Days to the next free change, or 0 if free change available.

#### Errors

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


---

# 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/billing/tariff/tariff_tracker.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.
