# Auto-routing

### Difference from Routing

|             | Routing                               | Autorouting                                   |
| ----------- | ------------------------------------- | --------------------------------------------- |
| Data        | Base64 profile is transferred once    | URL source, the profile is downloaded from it |
| Update      | Only when the subscription is updated | Automatically at an interval (24h by default) |
| `sourceURL` | Not set                               | Set — the profile is tied to the URL          |
| Indicator   | None                                  | Cloud icon in the profile list                |

### Link types

| Link format                  | Description                                                      |
| ---------------------------- | ---------------------------------------------------------------- |
| `://autorouting/onadd/{url}` | Downloads the profile by URL, sets auto-update, and activates it |
| `://autorouting/add/{url}`   | Downloads the profile by URL, sets auto-update                   |

> **Important:** `://routing/onadd/{url}` **not** is autorouting — this is a one-time import without auto-update. Only the scheme `://autorouting/` sets `sourceURL` and enables auto-update.

> `{url}` — direct link to the profile JSON file (starts with `http://` or `https://`).

#### Type definition

The type is determined **by the link scheme**:

* `://autorouting/` → **autorouting** (set `sourceURL`, auto-update enabled)
* `://routing/` → **routing** (one-time import, without `sourceURL`, without auto-update)

Examples:

```
://autorouting/onadd/https://example.com/profile.json   → autorouting (auto-update)
://routing/onadd/https://example.com/profile.json        → routing (one-time import)
://routing/onadd/ewogICJOYW1lIjogIlRlc3QiCn0=          → routing (base64)
```

### HTTP header

Header `autorouting` contains the URL where the routing JSON profile is available:

```
HTTP/2 200
autorouting: https://raw.githubusercontent.com/user/repo/main/profile.json
```

The profile is downloaded when the subscription is updated, saved bound to the source URL, and periodically updated.

### Subscription body

The autorouting string is placed in the subscription body alongside server configurations:

```
vless://uuid@server1:443?security=tls#Server1
vless://uuid@server2:443?security=tls#Server2
://autorouting/onadd/https://raw.githubusercontent.com/user/repo/main/profile.json
```

### Source priority

If multiple routing sources are present, the **first found**:

| Priority    | Source                      | Type          |
| ----------- | --------------------------- | ------------- |
| 1 (highest) | Header `autorouting`        | Auto-updating |
| 2           | Body — a string with a URL  | Auto-updating |
| 3           | Header `routing`            | Static        |
| 4 (lowest)  | Body — a string with base64 | Static        |

***

### GitHub URL conversion

Links to files in GitHub repositories are automatically converted from the “blob” format to “raw”:

```
https://github.com/user/repo/blob/main/path/profile.json
→
https://raw.githubusercontent.com/user/repo/main/path/profile.json
```

This happens transparently during import and auto-update. You can use normal GitHub links — the app will substitute the correct URL itself.

***

### Content by URL

A file at a URL may contain:

**1. Nested deep link:**

If the content starts with `incy://` — the app automatically extracts the profile data from the link. This makes it possible to place `.deeplink` files:

```
incy://routing/onadd/ewogICJOYW1lIjogIlJvc2NvbVZQTiIKfQ==
```

The app will extract the base64 data and decode the profile.

**2. JSON profile (recommended):**

```json
{
    "Name": "RoscomVPN",
    "GlobalProxy": "true",
    "RemoteDNSType": "DoH",
    "RemoteDNSDomain": "https://cloudflare-dns.com/dns-query",
    "RemoteDNSIP": "1.1.1.1",
    "Geoipurl": "https://example.com/geoip.dat",
    "Geositeurl": "https://example.com/geosite.dat",
    "DirectSites": ["geosite:ru"],
    "DirectIp": ["geoip:ru"],
    "DomainStrategy": "IPIfNonMatch"
}
```

**3. Base64-encoded JSON:**

```
ewogICAgIk5hbWUiOiAiUm9zY29tVlBOIiwKICAgICJHbG9iYWxQcm94eSI6ICJ0cnVlIgp9
```

The app tries: nested deep link → JSON → base64 (in priority order).

The profile field structure is described in routing.md.

***

### Auto-update

#### Mechanism

* The app checks all profiles with `sourceURL` every 30 minutes
* If more than`sourceLastUpdated`has passed since the last update ( `updateInterval` ) — the profile is downloaded again
* When updating, the following are preserved: profile ID, `sourceURL`, `updateInterval`, geofile hashes
* If the geofile URLs changed after the update — the geofiles are re-downloaded automatically

#### Update intervals

| Value (sec) | Display                |
| ----------- | ---------------------- |
| `43200`     | 12 hours               |
| `86400`     | 24 hours **(default)** |
| `259200`    | 3 days                 |
| `604800`    | 7 days                 |

#### UI management

Profiles with `sourceURL` display a cloud icon in the list. In the profile editor, the “Update Source” section is available:

* **URL** — you can view and change the source URL
* **Update frequency** — choose the update interval
* **Updated** — time of the last update
* **Update now** — manual profile update
* **Remove source** — detach the profile from the URL (turns it into static)

***

### Updating existing profiles

* Profiles with the same `Name` are updated, not duplicated
* When updating an auto-updating profile, the following are preserved: `sourceURL`, `updateInterval`, geofile hashes
* If the geofile URLs (`Geoipurl`, `Geositeurl`) have changed — the geofiles are re-downloaded automatically


---

# 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://incy.gitbook.io/docs/docs-en/developer-documentation/auto-routing.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.
