# Embed

Whitelabel URnetwork into your own apps: your backend provisions a client for each installation, your apps embed the SDK, and no root credential ships in an app.

URnetwork runs on every major platform, including Android, iOS, macOS, Windows and Linux, and integrates as a native library inside your app with minimal permissions. With tunneled sockets it needs only network access: no VPN permission, no device-wide tunnel and no administrator rights.

Most apps replace their own sockets with tunneled sockets from the Device, as [Socket](/docs/socket) shows. You can also tunnel the whole system, which takes the platform's [tunnel permission](/docs/getting-started-sdk), or pass custom messages between your installations with [Messages](https://github.com/urnetwork/examples/blob/main/MESSAGES_PROTOCOL.md).

For your websites, an Embed network also gets the [drift test](#drift-test): a small widget that checks whether a visitor's connection ends in the country of their IP address.

> **An Embed plan is required.** Embedding URnetwork in your own product needs an Embed plan for your network. Each plan starts with a review of your project and a contract, and then our team enables Embed for your network. [Request one on the Services page](/services), with your monthly active users and monthly data budget.

![Embed — your backend signs in your user, provisions one URnetwork client per installation with the root JWT (POST /network/auth-client answers with a client_id and a scoped client JWT), keeps each installation's client_id and may set per-installation data caps, and delivers only the client JWT to your app on the user's device; the app's embedded SDK connects to URnetwork with it and carries the app's own traffic, in-app only rather than a device VPN; past 100 active installations an Embed plan raises your network's client limit, and no root JWT ships in the app](/docs-assets/diagram-dev-embed.svg)

An embed integration puts URnetwork inside your own product, under your own brand, and it has two halves of equal weight. Your backend provisions a client for each installation of your app and sets its data caps. Your app packages the SDK and starts a Device with that installation's client JWT. The Device carries only your app's own traffic; what your app sends through it continues in [Socket](/docs/socket). Runnable examples cover twelve languages and three platforms of their own: Electron, Tauri and Android. They all implement the [embed contract](https://github.com/urnetwork/examples/blob/main/EMBED_CONTRACT.md), which holds the exact rules; this page explains how the parts fit.

## Who holds what

An embed integration splits the work three ways, and no key ships in an app.

- **Your backend** signs in your users and holds your network's root credential. It provisions one client per installation, sets each client's data caps, delivers each installation's scoped client JWT and removes the clients you no longer want.
- **Your app** embeds the SDK, runs a local Device with its installation's client JWT, sends its own traffic through it and shows the status. It never holds the root credential, never sets caps and never provisions or removes clients.
- **URnetwork** enforces each client's data caps and your network's client limit.

| Value | Kept by | Purpose |
| --- | --- | --- |
| Root credential: an API key or `URNETWORK_ROOT_JWT` | Your backend's secret store | Provisions clients, sets data caps and removes clients for the whole network |
| Client map, `user:<service-user-id>:<installation-id>` to `client_id` | Your backend's private state | Decides which installation may obtain or renew which client; it stores client IDs, never tokens |
| `client.jwt` | The installation's private state | The installation's scoped credential, which the SDK refreshes |
| `instance-id` | The installation's private state | One UUID for the life of the installation, and the installation ID your app sends your backend |
| Data caps | URnetwork, set by your backend | Optional monthly and running-total byte caps for each client; the app reads its own |
| ACL group | URnetwork, set by your backend | `default` or `isolated`: whether the client is in your network's peer list |

## Provision clients {#provision-a-client-for-each-installation}

Your backend provisions with [`POST /network/auth-client`](/docs/api/network#post-network-auth-client) and the root credential: the same request the [integration contract](https://github.com/urnetwork/examples/blob/main/INTEGRATION_CONTRACT.md#backend-provisioning) uses for a top-level client.

### One client per installation {#one-client-per-running-installation}

The platform keeps one live connection per `client_id`. When a second installation connects with the same client, it displaces the first, and the two keep knocking each other off. So every installation that can run at the same time as another needs its own client.

Your backend's map keeps each installation's `client_id` under one composite key: `user:<service-user-id>:<installation-id>`. The installation ID is the installation's `instance-id`, which the app sends. The service user ID comes from your own sign-in, never from the request. That user part is what lets your backend refuse another user's installation: whatever installation ID a caller presents, it only reaches a key under the caller's own user, so your backend never reissues another user's client. A service whose users only ever run one installation may key by `user:<service-user-id>` alone.

An app picks its own installation ID, so your backend bounds how many installations one user may create. The token server allows 5 by default.

### The root credential

Use an **API key** as your backend's credential in production. Create one with [`POST /account/api-key`](/docs/api/account#post-account-api-key), called with a network JWT from sign-in. The key begins `urn_` and is shown only in that answer. [`GET /account/api-keys`](/docs/api/account#get-account-api-keys) lists your keys without their secrets, and [`POST /account/api-key/remove`](/docs/api/account#post-account-api-key-remove) revokes one.

An API key authenticates as your network exactly like a network JWT and carries no `client_id`, so it is the bearer credential for every request on this page. Its scope is the same: the whole network. It is not narrower, and anyone who holds it can provision clients, change caps and remove clients. Treat it like a production database password: keep it in your backend's secret store, give it only to the service that provisions, and keep it out of apps, logs, error messages, URLs and repositories.

To rotate a key, create a new one, deploy it to your backend, then remove the old one. Remove a leaked key at once. Removing a credential stops it from provisioning; it does not cut off a user. To do that, [pause or remove their client](#pause-remove-or-delete-a-user).

### Provision and reissue

An installation's first sign-in provisions a new client. Send `description` and `device_spec`, and neither `client_id` nor `source_client_id`:

```json
{
  "description": "embed client",
  "device_spec": "urnetwork-examples/curl"
}
```

The answer carries the new `client_id` and its scoped `by_client_jwt`. Map the `client_id` to the installation's key and deliver the JWT, which the installation saves as `client.jwt`. Later sign-ins reissue: send the stored `client_id` with the same description and device spec, and the answer carries a fresh JWT for the same client.

A client that has not connected for 30 days is deactivated, and its reissue answers `Client does not exist.` Drop that mapping, provision a new client and apply the installation's caps to it again.

Check every answer before you store or deliver anything: the HTTP result, `error`, both success fields, that the JWT's `client_id` claim equals the answer's `client_id`, and that your map does not already give that `client_id` to another key. A refusal answers 200 with `error.message`. URnetwork can see the description, so keep your users' identifiers out of it; your map already links each client to its user. The [contract](https://github.com/urnetwork/examples/blob/main/EMBED_CONTRACT.md#backend-provision-clients) shows the requests with curl.

### The client limit

A network can have **100 active top-level clients** by default. Exactly, the limit counts the network's clients that are active, have no `source_client_id` and are not provider installs. With one client per running installation, that is your active installations. A client stops counting when you remove it, or when it is deactivated after 30 days without connecting. Child clients and provider installs never count.

Past the limit, provisioning a new client is refused with `error.client_limit_exceeded` and the message `Client limit exceeded.` An **Embed plan** raises your network's limit: [request one on the Services page](/services), with your monthly active users and monthly data budget. A refusal with `error.upgrade_required` comes from a second limit, your plan's cap on concurrently connected top-level clients; a request that asks for x402 terms (`X-UR-X402: 1`) gets HTTP 402 with the terms for an upgrade instead, where the platform can quote one. An Embed plan sets your network's allowance for both limits.

Check your network with [`GET /network/embed`](/docs/api/network#get-network-embed) and the root credential. It answers `enabled`, whether the team has enabled Embed for your network; `client_limit`, your network's limit; and `active_client_count`, the exact number that limit counts.

### Per-installation data caps {#data-caps-for-each-installation}

Each client has two optional caps. Set either, both or neither:

- The **monthly cap** limits the bytes the client uses in each UTC calendar month. It resets at 00:00 UTC on the first of the month, not at midnight in your user's time zone.
- The **running-total cap** limits the bytes used since the total started: at your first cap request for the client, or at its last `reset_total`. It never resets on its own: raise or clear it, or start a new total with `reset_total`.

At a cap the client gets no new transfer contracts until the month rolls over, the cap is raised or cleared, or the total is reset. That is a hard stop, not a throttle, and its new contracts are refused the way an empty balance is, so read the caps to tell the two apart. Usage is counted when transfer contracts settle and rolled up within about two minutes, so the used counts lag live traffic, a cap takes effect within about two minutes of being reached, and a client can go past a cap by up to the size of its contracts that are still open: leave headroom. Metering never over-counts; each contract is counted at most once. A cap of `0` pauses the client at once, and the pause lasts until that cap changes. A new month does not lift a monthly cap of `0`.

Every byte the client pays for counts toward its caps; no traffic is exempt. Lowering a cap below what the client has already used stops it within the same two minutes, and raising or clearing a cap lets it resume. At a cap your app's status reads `data cap reached`, or `paused` for a cap of `0`.

Set caps with [`POST /network/client-data-cap`](/docs/api/network#post-network-client-data-cap) and the root credential. A client JWT is refused, and the client must belong to your network. Each limit field merges, so one call changes one cap without touching the other. Omit a field to keep its value, send `null` to clear that cap, or send a whole number of bytes, `0` or more, to set it. In the table, `C` is the client's `client_id`:

| Body | Effect |
| --- | --- |
| `{"client_id": C, "monthly_byte_limit": 10000000000}` | 10 GB a month; the running-total cap is unchanged |
| `{"client_id": C, "total_byte_limit": null}` | Clears the running-total cap; the monthly cap is unchanged |
| `{"client_id": C, "monthly_byte_limit": 0}` | Pauses the client until the monthly cap changes |
| `{"client_id": C, "reset_total": true}` | Starts a new running total; both caps are unchanged |

The API counts whole bytes; show GB or TB only in your interface. Read caps and usage three ways:

- [`GET /network/client-data-cap?client_id=C`](/docs/api/network#get-network-client-data-cap) with the root credential reads any client of your network.
- The same request with a client JWT reads that client. This is how your app shows its own data.
- [`GET /network/client-data-caps`](/docs/api/network#get-network-client-data-caps) with the root credential pages through every client that has a cap set. `limit` takes 1 to 1000, and you pass each answer's `next_cursor` back as `cursor` until it is `null`.

Each answer carries both caps, the bytes used this month and in the running total, the period dates, and `capped` with its reason. Monthly usage is metered for every client, capped or not, so the single read also serves your billing. There are no threshold notifications: your backend and your app poll these reads.

Caps belong to a client, so with one client per installation they apply per installation. To give one user one budget across several installations, set each installation's caps from that user's budget, read usage across the user's clients with the bulk read, and adjust.

The data-cap routes work once the team has enabled Embed for your network. Until then they answer with the `error.message` `Embed isn't enabled for this network.` If Embed is later disabled, caps you already set keep applying.

### Isolating installations {#keep-installations-out-of-each-others-peer-list}

Every top-level client is a peer in your network: it can appear in the network's peer list and receive that list. An embed app usually wants the opposite, so each client has an **ACL group**:

- `default`: the client is a normal peer. New clients start here.
- `isolated`: the client never appears in your network's peer list, receives no peer list itself, and does not count toward the 100 recently active clients that keep the peer list on. It still counts toward your client limit and your concurrent connection limit.

Set the group with [`POST /network/client-acl-group`](/docs/api/network#post-network-client-acl-group) and the root credential, for example `{"client_id": C, "acl_group": "isolated"}`, and read it with [`GET /network/client-acl-group`](/docs/api/network#get-network-client-acl-group), using the root credential or the client's own JWT. Set it when you provision, before you deliver the client JWT: a client isolated while it is connected stops receiving peer updates, but keeps the list it already had. The token server and backend tools isolate new clients by default (`URNETWORK_DEFAULT_ACL_GROUP`). Messages finds other clients through the peer list, so an installation that uses Messages stays in `default`.

Like the data-cap routes, the ACL-group routes answer `Embed isn't enabled for this network.` until the team enables Embed for your network, and groups you already set keep applying if Embed is later disabled.

### Pause, remove, delete users {#pause-remove-or-delete-a-user}

- **Pause** an installation with a cap of `0`. It gets no new transfer contracts, and its data stops within the life of the contracts already open. Set the cap back to resume.
- **Remove** a client with [`POST /network/remove-client`](/docs/api/network#post-network-remove-client) and `{"client_id": C}`. The platform refuses its client JWT at the next connection, so the installation loses access when it reconnects. Drop the mapping as well. If that installation signs in again, your backend would provision a new client, so to keep a user out, refuse their sign-in in your own service.
- **Delete** a user by removing the client of each of their installations and dropping those mappings.

Coming from another whitelabel SDK, the usual controls map like this:

| Elsewhere | Here |
| --- | --- |
| Disable a user | A cap of `0` on each of their installations |
| Delete a user | Remove each installation's client and drop its mapping |
| Account expiry | No expiry; a client idle for 30 days is deactivated |
| Device limit | Your backend's bound on installations per user; the token server allows 5 |
| Per-user data limit | Caps on each installation, budgeted from the user's limit |
| Hide users from each other | The `isolated` ACL group |

### Token server and tools {#the-token-server-and-backend-tools}

The examples include a minimal backend in two forms:

- The **Go token server**, in [`go/embed/server`](https://github.com/urnetwork/examples/tree/main/go/embed/server), has the shape of your service's sign-in endpoint. Your app posts its `instance-id` to `POST /urnetwork/client-token`, with a demo session as the bearer token. The server provisions or reissues that installation's client, applies optional default caps to a new client, and answers with the `client_id`, the `by_client_jwt` and the current caps. It uses only the Go standard library, allows 5 installations per user by default and listens on `127.0.0.1:8790`: serve it to the internet only through your own HTTPS front end, and replace its demo sessions with your real sign-in. The Electron, Tauri and Android examples use it.
- Each console language has a **backend tool** in `<language>/embed/server/`. It extends that language's [integration allocator](https://github.com/urnetwork/examples/blob/main/INTEGRATION_CONTRACT.md#runnable-backend-allocators) with `provision`, `cap`, `usage`, `usage-all` and `remove`.

Both keep the private client map, hold a lock while they provision so that one key never gets two clients, check every answer, and never print the root credential or a client JWT. Each has a credential-free self-test. The contract defines the [token server's HTTP contract](https://github.com/urnetwork/examples/blob/main/EMBED_CONTRACT.md#the-token-server) and the [backend tools' commands](https://github.com/urnetwork/examples/blob/main/EMBED_CONTRACT.md#backend-tools).

## Package the SDK {#package-and-embed-the-sdk}

### Permissions

With tunneled sockets, the embedded Device routes only the traffic your app sends through it: a socket opened on the Device, or an HTTP client pointed at its loopback proxy. It does not use the operating system's VPN interfaces, so your app needs no Android `VpnService` and no Apple Network Extension VPN entitlement, and Google Play's VpnService declaration does not apply. Whole-system tunneling is different: your app holds the platform's [tunnel permission](/docs/getting-started-sdk), and the store rules for VPN apps then apply. The embed examples use tunneled sockets.

Your privacy disclosures still apply. Your app routes some of its users' traffic through URnetwork, and its privacy policy, App Store privacy details and Play data safety form must say so. The SDK ships no Apple privacy manifest (`PrivacyInfo.xcprivacy`), so your app's own disclosures cover it. Under the [terms](/terms) you must not permit unlawful use of the network, which makes your users' use your responsibility, and you support your own users.

### Add the SDK

Pin an exact release, never a branch:

| Platform | Add and pin the SDK | Binding |
| --- | --- | --- |
| Go | `go get github.com/urnetwork/sdk/v2026@<version>` | The Go SDK, in process |
| C | vcpkg or Conan `urnetwork-sdk`, pinned by port or recipe version | The C ABI, `urnetwork_sdk.h` |
| C++ | The same package, with `urnetwork_sdk.hpp` | The C ABI |
| C# | NuGet `URnetwork.SDK` | P/Invoke over the C ABI |
| Java | Maven `io.ur:urnetwork-sdk:<version>` | JNA over the C ABI |
| Kotlin | The same Maven artifact | JNA over the C ABI |
| Python | `pip install urnetwork-sdk==<version>` | ctypes over the C ABI |
| Ruby | `gem install urnetwork-sdk -v <version>` | FFI over the C ABI |
| Rust | `cargo add urnetwork-sdk@<version>` | The C ABI, through the crate |
| Swift | The C ABI through a SwiftPM C module; Apple app targets may use the gomobile XCFramework instead | The C ABI, or gomobile on Apple |
| JavaScript | The native companion in embed mode, started as a child process | A side-service process |
| TypeScript | The same companion | A side-service process |
| Electron | The same companion, started by the main process | A side-service process |
| Tauri | The `urnetwork-sdk` crate in the Rust core | The C ABI, through the crate, in process |
| Android | `implementation("io.ur:urnetwork-sdk-android:<version>")` | The gomobile AAR |

The C ABI bindings load the URnetwork SDK shared library, which ships with your app; the NuGet, Maven, Python and Ruby packages and the Rust crate carry it for you. JavaScript, TypeScript and Electron ship one companion binary for each OS and architecture. Some package coordinates are awaiting their first publication, and each example's README gives the local build path. [Install the SDK](/docs/install-sdk) covers the packages.

### Keep the installation's state

Each installation keeps its state in one private directory: `client.jwt`, `instance-id` and the SDK's bounded `logs/`, plus `token-server.json` in the GUI and Android apps. On POSIX the directory is 0700 and its files 0600, a file that group or others can read, or a symlinked file, is refused, and every file is replaced atomically. On Windows keep it under `%LOCALAPPDATA%`. Console examples read its absolute path from `URNETWORK_EMBED_STATE_DIR`; GUI and Android apps use a private `embed` directory in their application data, on Android in the no-backup files directory.

The client JWT is a bearer secret: never print, log or back it up. A production app may also encrypt it with the platform's secret store:

| Platform | Secret store |
| --- | --- |
| Apple platforms | The Keychain |
| Android | The Android Keystore |
| Windows | DPAPI |
| Linux | The Secret Service (libsecret) |
| Electron | `safeStorage` |

### Run the Device {#start-and-stop-the-device}

The app's lifecycle is the same on every platform:

1. Load the installation state, and create `instance-id` on the first run.
2. Obtain the client JWT: from your backend, or from a `client.jwt` that a backend tool wrote. The examples call the token server on every start, which reissues the client. A network JWT is refused, because it has no `client_id`.
3. Point the SDK's logs at `logs/`, create a network space manager, and give the space's API the client JWT.
4. Create the local Device with `NewDeviceLocalWithDefaults` and the installation's `instance-id`. Leave the provide mode at its default: an embed app does not provide.
5. Listen for token refreshes and save each one as `client.jwt`, for a logout and stop, and for contract status changes and read the caps again.
6. Set the connect location to the best available location.
7. Read the caps with the client JWT at start and every 5 minutes, and the status every second.
8. To stop, close the subscriptions, then the Device, then the manager.

The contract's [app lifecycle](https://github.com/urnetwork/examples/blob/main/EMBED_CONTRACT.md#app-lifecycle) gives the exact calls for the Go SDK, gomobile and the C ABI.

### What the app shows

Every example shows three fields, with the same rules:

| Field | Shows |
| --- | --- |
| Status | `signed out`, `stopped`, `client limit`, `paused`, `data cap reached`, `connected` or `connecting`, checked in that order |
| Data this month | `checking`, `unavailable`, `no cap`, or the bytes used of the monthly cap |
| Data total | The same, for the running-total cap |

`signed out` and `stopped` appear only in the GUI and Android apps. `client limit` adds its retry time, as `client limit, retry at HH:MM UTC`. `paused` means the cap that stopped the client is `0`. A monthly cap adds when it resets, as `data cap reached, resets YYYY-MM-DD HH:MM UTC`. `connected` means the Device has at least one provider. Amounts use decimal units, as data plans do. Console examples print a status line whenever a field changes, and otherwise once a minute:

```text
status: connected | data this month: 1.2 GB of 5.0 GB | data total: no cap
```

The [contract's golden vectors](https://github.com/urnetwork/examples/blob/main/EMBED_CONTRACT.md#status) pin every text exactly. Console examples exit 0 after a requested stop, 78 for a configuration or credential problem that a restart does not fix, and 1 for any other failure.

### License

The SDK and connect are licensed under the [Mozilla Public License 2.0](https://mozilla.org/MPL/2.0/), a file-level copyleft. Your app's own code can stay proprietary; changes you make to the SDK's own source files must be shared under the MPL. Publish the SDK's licenses and data attributions with your app: `GetLicenses(app)`, or `urnet_get_licenses` in the C ABI, returns them for your app kind without a network call.

## Next: Sockets and Messages

The embed integration ends where your app's own traffic begins.

- **Sockets** route your app's TCP, UDP and HTTP clients through the Device. Libraries that need an operating system socket use its loopback proxy. Start with [Socket](/docs/socket) and each language's socket example.
- **Messages** exchange text with other clients of your network over the [URMS protocol](https://github.com/urnetwork/examples/blob/main/MESSAGES_PROTOCOL.md). They do not run on the embed Device: messages attach to a provider-capable Device, and the embed Device does not provide. A Messages program starts its own provider-capable Device for the installation, which provides to your network, so your network's other clients can route traffic through that installation. Before you turn that on, show a consent screen that says so, let the user turn it off at any time, and disclose it in your terms. A Messages installation also stays in the `default` ACL group.

The installation's state works with the socket and messages programs: pass the content of `client.jwt` as `URNETWORK_CLIENT_JWT` and of `instance-id` as `URNETWORK_INSTANCE_ID`, and run one program at a time with one identity. An embed client in the `default` ACL group appears in your network's peer list while the network has 100 or fewer recently active top-level clients; past that, the peer list is off, and the Messages examples depend on it. An `isolated` client never appears in it.

## Examples

Each example's README has build and run steps for every OS it supports, the backend steps for its language, and a credential-free self-test. The console examples run on Windows, macOS and Linux. The [Go embed app](https://github.com/urnetwork/examples/blob/main/go/embed/README.md) and its token server are the reference implementations.

| Platform | Example | Built on |
| --- | --- | --- |
| C | [C embed](https://github.com/urnetwork/examples/blob/main/c/embed/README.md) | The C ABI |
| C++ | [C++ embed](https://github.com/urnetwork/examples/blob/main/cpp/embed/README.md) | The C ABI |
| C# | [C# embed](https://github.com/urnetwork/examples/blob/main/csharp/embed/README.md) | The C ABI, through .NET |
| Go | [Go embed](https://github.com/urnetwork/examples/blob/main/go/embed/README.md) | The Go SDK, with the token server |
| Java | [Java embed](https://github.com/urnetwork/examples/blob/main/java/embed/README.md) | The C ABI, through JNA |
| JavaScript | [JavaScript embed](https://github.com/urnetwork/examples/blob/main/javascript/embed/README.md) | Node and the native companion |
| Kotlin | [Kotlin embed](https://github.com/urnetwork/examples/blob/main/kotlin/embed/README.md) | The C ABI, through JNA |
| Python | [Python embed](https://github.com/urnetwork/examples/blob/main/python/embed/README.md) | The C ABI, through ctypes |
| Ruby | [Ruby embed](https://github.com/urnetwork/examples/blob/main/ruby/embed/README.md) | The C ABI, through FFI |
| Rust | [Rust embed](https://github.com/urnetwork/examples/blob/main/rust/embed/README.md) | The C ABI, through the Rust crate |
| Swift | [Swift embed](https://github.com/urnetwork/examples/blob/main/swift/embed/README.md) | The C ABI, through a SwiftPM C module |
| TypeScript | [TypeScript embed](https://github.com/urnetwork/examples/blob/main/typescript/embed/README.md) | Node and the native companion |
| Electron | [Electron embed](https://github.com/urnetwork/examples/blob/main/electron/embed/README.md) | A desktop app on the native companion |
| Tauri | [Tauri embed](https://github.com/urnetwork/examples/blob/main/tauri/embed/README.md) | A desktop app with the Rust crate in process |
| Android | [Android embed](https://github.com/urnetwork/examples/blob/main/android/embed/README.md) | The gomobile AAR |

**Release availability:** the embed examples need no SDK API beyond what ships today: they read the caps over HTTP. They need an SDK release from the first release after sdk `c638dfa8`, which adds the client limit status. The data-cap routes and the per-network client limit that an Embed plan raises ship with the server release that adds them. On an older server the cap routes answer 404: the apps show `unavailable` for the data fields, and the backend tools report the failure. [Install the SDK](/docs/install-sdk) covers the packages, and the [examples browser](/docs/examples) has each language's other examples.

## Drift test {#drift-test}

The drift test checks that a visitor's connection ends in the country their IP address says. Your page shows a small widget, like a captcha. For several seconds it pings URnetwork's extenders, forwarding hops at known places around the world, from the visitor's browser. Then it shows the verdict with the IP country, and your backend reads the verdict from the API.

- **Pass:** the visitor's pings place them in the country their IP address says, and the verdict is `agree`.
- **Reject:** the pings place them outside that country by more than the measurement's uncertainty, and the verdict is `disagree`.
- **Retest:** the visitor can retest with the same token, and the verdict always comes from the token's last 3 runs.

A third verdict, `inconclusive`, means the test couldn't decide, and it comes with the reason. The widget runs only the latency measurement of [lag.dev](https://lag.dev), URnetwork's latency test, with no download or upload. The extenders sign and report the round trips they measure, and URnetwork computes the verdict from those reports, never from figures the browser supplies.

Every network with Embed enabled can use drift tests, with its API key or root JWT. For now they come with Embed, with no separate setting, allowance or billing.

To try it, open [lag.dev/drift-test](https://lag.dev/drift-test). Its developer box has the frame's HTML and the API calls to copy, and a link that runs the [demo](#drift-test-demo).

### What it checks {#drift-test-checks}

The drift test checks that an IP address is where its geolocation says, not where a person is. It locates whatever ends the connection: the visitor's own device, or the VPN or proxy server they use. A tunnel adds about the same delay to every path, so it shows in the last-mile offset, `last_mile_ms`, and not in the position.

It catches an address whose country is wrong for where its connection ends:

- a VPN's "virtual locations": a server in one country with an address registered to another;
- address blocks that are misregistered or misgeolocated;
- anycast or relocated ranges.

It doesn't catch a VPN whose server really is in the address's country. A visitor in France on a VPN whose server is in Germany, with a German address, passes as Germany.

- **A helper can't take the test for the visitor.** A run counts only when it starts from the same network as the address you allocated the token for, `client_ip`: its /29 for IPv4, or its /56 for IPv6. A run from another network is measured and listed, but never enters the verdict. When a run came over the other IP family and couldn't be compared, the verdict's `bound` says so.
- **It raises the bar against ordinary browsers and VPNs, not against a determined attacker.** No client can answer a ping early, so a connection can only look farther away. A browser can't delay its replies, but a custom client can, to mimic a farther place. That costs about 15 ms of last-mile offset for every 1,000 km, and `relay_suspected` flags an offset far above normal.
- **Disputed borders:** verdicts use Natural Earth's de facto borders, and IP geolocation assigns an address by its registration and routing. Where the two differ, for example around Crimea, Kashmir and Western Sahara, a verdict can disagree with what you expect.
- **Small countries and enclaves,** such as Vatican City, Monaco, Liechtenstein and Lesotho, are smaller than the measurement's uncertainty. Their visitors can't be rejected toward a neighbor, so there the test errs toward a pass.

### How a check runs {#drift-test-flow}

1. **Your backend allocates a token** with [`POST /lag/drift-test`](/docs/api/other#post-lag-drift-test), your API key and the visitor's IP address. The answer carries the token, the widget's `embed_url` and the `drift_test_id`.

2. **Your page shows the widget,** a frame whose source is the `embed_url`: `https://lag.dev/?t=<token>`.

3. **The widget starts a run** as soon as it is visible. URnetwork chooses 12 extenders around the place the visitor's IP address gives, and the widget pings each of them 4 times a second. Its radar shows the estimate and its uncertainty as they settle.

4. **The run stops** as soon as its estimate is steady or its result is clear, and never later than 12 seconds after the pings start. The extenders report the round trips, and URnetwork computes the verdict.

5. **The widget shows the outcome** with the IP country: "Verified Germany", or "Couldn't verify Germany" with a Retest button. It also posts a `complete` message to your page.

6. **Your backend reads the verdict** with [`GET /lag/drift-test`](/docs/api/other#get-lag-drift-test) and your API key when the visitor moves on, for example when they submit your form.

From start to verdict, a check usually takes about 8 to 12 seconds, a little less on a retest, and at most about 15. The widget makes its own calls to the API with only the token, so your backend needs just the two routes below.

### Allocate a token {#drift-test-allocate}

Allocate one token for each check, from your backend, with [`POST /lag/drift-test`](/docs/api/other#post-lag-drift-test). The call takes your network's [API key](#the-root-credential) or root JWT, which must never reach the page.

```sh
API=https://api.bringyour.com
curl -fsS -X POST "$API/lag/drift-test" \
  -H "Authorization: Bearer $URNETWORK_API_KEY" -H 'Content-Type: application/json' \
  --data '{"client_ip": "203.0.113.7", "reference": "signup-8812"}'
```

| Field | Required | Meaning |
| --- | --- | --- |
| `client_ip` | Yes | The visitor's IP address, as your server sees it |
| `parent_origins` | No | The origins that may show this token's widget, within your network's [allowed origins](#drift-test-origins) |
| `confidence` | No | `0.95` or `0.99`, the default: the confidence of the region the verdict judges; `0.999` is refused as invalid |
| `reference` | No | Your own label, at most 128 characters, returned as given |
| `ttl_seconds` | No | How long the first run has to start: 60 to 3600 seconds, 300 by default |

The answer:

```json
{
  "drift_test_id": "0193…",
  "token": "dt1_<43 characters of base64url>",
  "embed_url": "https://lag.dev/?t=dt1_…",
  "expires_at": "2026-11-17T18:05:00Z"
}
```

- **`token`** is the widget's credential for this one test: 32 random bytes, which URnetwork keeps only as a hash.
- **`embed_url`** is the widget's source, with the token in it.
- **`expires_at`** is when the token expires if no run has started.
- **`drift_test_id`** is how your backend reads the verdict. Keep it on your server with the visitor's session, and read the verdict by the id you kept. Never use an id the page sends back: a page can send any id, including one from another visitor's test that passed.

**`client_ip` binds the test to the visitor's network.** Pass the address the visitor's request to your server came from. Behind a load balancer, CDN or reverse proxy, that is the client address your own proxy forwards, not the proxy's. A run counts only when it starts from the same network as this address: the same /29 for IPv4, or the same /56 for IPv6. A run from another network is still measured, and listed with `client_ip_matches: false`, but it never enters the verdict.

The test binds the network rather than the exact address, since a visitor's address can change within their provider's block, through carrier-grade NAT pools and IPv6 privacy addresses. URnetwork compares in memory and keeps only a peppered hash of the network, which it deletes when the token closes or expires. It also looks up `client_ip`'s country when you allocate, and judges every run against that country, never against the country of the address a run starts from.

A dual-stack visitor may reach your server over IPv6 and lag.dev over IPv4, and addresses are compared only within one family. So the widget starts each run over `client_ip`'s family, retrying its start at `api-v4.bringyour.com` or `api-v6.bringyour.com` when it must. Nothing is needed on your side.

A run that still comes from the other family reads `client_ip_matches: null`. It counts only when its address is in `client_ip`'s country, and then the verdict's `bound` is `false`. If you need protection against relays, require `bound: true`.

### Embed the widget {#drift-test-widget}

```html
<iframe src="https://lag.dev/?t=<token>" width="300" height="104"
        title="Location check" style="border:0"></iframe>
```

- **Source:** the allocation's `embed_url`. On a light page, add `&theme=light`, as in `https://lag.dev/?t=<token>&theme=light`. The widget is dark by default.
- **Size:** 300 × 104 px, close to a captcha's. Its width can be set anywhere from 280 to 400 px.
- **Placement:** the widget starts by itself once the frame is visible, with no click, and it doesn't measure a visitor who never scrolls to it. Put it where the visitor sees it, for example beside your form's submit button.
- **HTTPS:** only an `https:` page can frame the widget, apart from local development pages at `http://localhost` or `http://127.0.0.1`, on any port. If your page's Content Security Policy limits frames, allow `frame-src https://lag.dev`.
- **Cross-origin isolation:** a page that sends `Cross-Origin-Embedder-Policy: require-corp` or `credentialless` can frame the widget with no extra setup, since the widget's responses send `Cross-Origin-Resource-Policy: cross-origin` and `Cross-Origin-Embedder-Policy: require-corp`.
- **No sandbox:** don't put the frame in a `sandbox`. Without `allow-same-origin`, the widget gets an opaque origin, and every call to lag.dev's API and extenders fails. If your page must sandbox the frame, give it at least `allow-scripts allow-same-origin`, and `allow-popups` for its footer link.
- **Referrer:** don't give the frame `referrerpolicy="no-referrer"`. The widget learns your page's origin from `location.ancestorOrigins` where the browser has it, and from the referrer in other browsers, such as Firefox. Without your origin, it sends your page no messages, and a network with allowed origins refuses it.
- **Footer:** "powered by URnetwork", which links to `https://lag.dev/drift-test`. That page tells the visitor what the check measures and what your site receives.

While a run measures, the widget shows its radar and "Checking your connection…", with the uncertainty so far. Then it shows the outcome with the IP country, such as "Verified Germany", or "Couldn't verify Germany" with a Retest button. The widget never names the country or place the pings point to, so a reject and an inconclusive verdict look the same to the visitor. The API tells them apart.

When the token has expired, or a run is refused, the widget says the check couldn't run, as in "This check has expired. Reload the page to try again." So allocate a new token each time the page loads. [Errors](#drift-test-errors) lists the reasons.

**Messages.** The widget posts messages to your page with `postMessage`, and only to your page's origin. Each message is an object `{source: "lag.dev", event, …}` with the fields below:

| `event` | Fields | When |
| --- | --- | --- |
| `ready` | None | The widget has loaded |
| `progress` | `run`, `answered`, `total` | While a run measures: `answered` of its `total` extenders have answered |
| `complete` | `driftTestId`, `run` | After each run |
| `error` | `code` | The check couldn't run; [Errors](#drift-test-errors) lists the codes |

```js
window.addEventListener("message", (msg) => {
  if (msg.origin !== "https://lag.dev" || msg.data?.source !== "lag.dev") return;
  if (msg.data.event === "complete") {
    // a run is over: let the visitor go on, and read the verdict on your server
  }
});
```

No message carries the verdict. Any script on your page can forge a message from the frame, so use the messages for your page's interface only, and read the verdict from your backend.

### Read the verdict {#drift-test-verdict}

Read it with [`GET /lag/drift-test`](/docs/api/other#get-lag-drift-test) and the `drift_test_id` you kept:

```sh
curl -fsS "$API/lag/drift-test?drift_test_id=$DRIFT_TEST_ID" \
  -H "Authorization: Bearer $URNETWORK_API_KEY"
```

Read the verdict when the visitor moves on, for example when they submit your form, not at the first `complete`. While retests are allowed, every run can change it.

- **`pending_run`:** when `result.pending_run` is a run number, that run's verdict isn't in yet. Read again in a second or two rather than act on the previous verdict. A run's verdict usually arrives about 2 seconds after the run ends, and within 20 seconds when a report is slow.
- **No `result` yet:** `result` is `null` until the first run has completed. Until then, `runs` shows whether a run is under way, and the state `created` means none has started.
- **Final:** once `state` is `closed`, the verdict can't change.

For a token whose first run was rejected and whose retest is still processing, the answer looks like this:

```json
{
  "drift_test_id": "0193…",
  "reference": "signup-8812",
  "state": "active",
  "created_at": "2026-11-17T18:00:00Z",
  "first_started_at": "2026-11-17T18:00:04Z",
  "retest_until": "2026-11-17T18:15:04Z",
  "updated_at": "2026-11-17T18:00:31Z",
  "runs": [
    { "run": 1, "state": "complete", "started_at": "2026-11-17T18:00:04Z",
      "completed_at": "2026-11-17T18:00:10Z", "measured_ms": 3750, "stop": "converged",
      "client_ip_matches": true, "extenders": 12, "answered": 11, "in_verdict": true },
    { "run": 2, "state": "processing", "started_at": "2026-11-17T18:00:26Z",
      "measured_ms": 3250, "stop": "clear",
      "client_ip_matches": true, "extenders": 12, "answered": 12, "in_verdict": false }
  ],
  "result": {
    "verdict": "disagree",
    "reason": "region_outside",
    "runs_in_verdict": [1],
    "bound": true,
    "pending_run": 2,
    "confidence": 0.99,
    "k": 3.035,
    "geometry_version": "ne-admin0-10m-<release>",
    "ip": { "country_code": "de", "country_name": "Germany", "family": 4 },
    "drift": {
      "country_code": "fr",
      "distance_km": 910,
      "significance_km": 140,
      "margin_km": 770,
      "ellipse_km": { "major": 48, "minor": 31, "bearing_deg": 72 },
      "last_mile_ms": [9.4],
      "relay_suspected": false,
      "fit_chi2_per_dof": 1.3,
      "extenders": 11
    }
  }
}
```

The test:

| Field | Meaning |
| --- | --- |
| `drift_test_id` | The test's id, from the allocation |
| `reference` | Your label from the allocation, as given |
| `state` | The token's state, below |
| `created_at` | When you allocated the token |
| `first_started_at` | When the first run started |
| `retest_until` | When retests end: 15 minutes after the first run started |
| `updated_at` | When the test last changed |
| `runs` | The token's runs, below |
| `result` | The verdict, once a run has completed; each completed run replaces it |

| `state` | Meaning |
| --- | --- |
| `created` | No run has started yet |
| `active` | Runs are allowed |
| `closed` | 6 runs, or the retest window is over: the verdict is final |
| `expired` | No run started before `expires_at` |
| `failed` | An internal error, which also alerts URnetwork |

Each run:

| Field | Meaning |
| --- | --- |
| `run` | The run's number, from 1 |
| `state` | `started` while it measures, `processing` once it has stopped, then `complete` |
| `started_at`, `completed_at` | When the run started, and when it completed |
| `measured_ms` | How long it pinged, in milliseconds |
| `stop` | Why the widget ended it, below |
| `client_ip_matches` | `true` from `client_ip`'s network, `false` from another network, `null` from the other IP family |
| `extenders` | The extenders it was given, 12 |
| `answered` | How many of them answered |
| `in_verdict` | Whether the run is in the current verdict |

| `stop` | Meaning |
| --- | --- |
| `converged` | The usual stop: more pings couldn't make the estimate more precise |
| `clear` | The result was already decisive, well inside or well outside the IP country |
| `interrupted` | No extender answered for 4 seconds |
| `cap` | 12 seconds passed, and the verdict uses what arrived |

URnetwork checks each stop against the extenders' signed reports, so a browser can't end a run at a moment that suits it. A run that ended early without the reports' support stays out of the verdict as `stopped_early`.

The result:

| Field | Meaning |
| --- | --- |
| `verdict` | `agree` (pass), `disagree` (reject) or `inconclusive` |
| `reason` | Why, below |
| `runs_in_verdict` | The runs the verdict pools: the token's last 3 that count |
| `bound` | `true` when every run in the verdict matched `client_ip` in its family; require it for protection against relays |
| `pending_run` | A run whose verdict isn't in yet, or `null` |
| `confidence` | The confidence of the region the verdict judges, from the allocation |
| `k` | The region's size the verdict was judged at, for the confidence and `client_ip`'s continent, below |
| `geometry_version` | The version of the country borders the verdict used, so it can be reproduced |
| `ip` | `client_ip`'s `country_code` and `country_name`, which every run is judged against, and the `family` of the runs judged |
| `drift` | What the pings show, below |

| `drift` field | Meaning |
| --- | --- |
| `country_code` | The country the pings place the connection in: the one holding the fit, else the nearest within 300 km, else none |
| `distance_km` | From the fit to the IP country, toward where the region comes closest; 0 when the fit is inside |
| `significance_km` | The region's radius in that direction, at the verdict's `k` |
| `margin_km` | `distance_km` minus `significance_km`: positive only when the whole region lies outside the IP country |
| `ellipse_km` | The 1σ uncertainty ellipse: semi-axes `major` and `minor` in km, and `bearing_deg`, clockwise from north |
| `last_mile_ms` | Each counted run's last-mile offset in ms: the delay every path shares, such as the access link or a tunnel |
| `relay_suspected` | Advisory, and not part of the verdict: `true` when the last-mile offset is far above normal for the network type |
| `fit_chi2_per_dof` | How well the round trips fit the model: about 1 as expected, higher when they scatter more, which widens the region |
| `extenders` | The extenders in the fit |

**How the verdict is decided.** The verdict judges a region, not a point. The region is the 1σ ellipse in `ellipse_km`, scaled by `k`: every position the measurement is consistent with at the allocation's confidence, 99% by default. The visitor is outside the IP country only when the whole region lies outside it. If any part of the region touches the country, the verdict is `agree`. The widget's radar draws the same region, dashed, around its estimate.

URnetwork sets `k` by the continent of `client_ip`'s country, from simulations of its own network, and never below the textbook value of 3.035 at 99% or 2.448 at 95%. In those simulations, fewer than 1% of visitors who really are in their IP country are rejected at 99%, on every continent. Where extenders are sparse, as around New Zealand, the region is wider, so a reject needs a larger drift. The result reports the `k` it used:

| Continent | `k` at 99% | `k` at 95% |
| --- | --- | --- |
| Europe | 3.035 | 2.448 |
| North America | 3.25 | 2.448 |
| Asia | 3.35 | 2.448 |
| South America | 3.50 | 2.448 |
| Africa | 3.95 | 2.50 |
| Oceania | 7.88 | 2.79 |
| Antarctica, or unknown | 3.49 | 2.448 |

The API never returns the fitted position. You get the countries, the distances and the uncertainty, not a location.

| `verdict` | `reason` | Meaning |
| --- | --- | --- |
| `agree` | `inside_ip_country` | The fit is inside the IP country |
| `agree` | `region_overlaps` | The fit is outside, but the uncertainty region touches the IP country |
| `disagree` | `region_outside` | The whole uncertainty region lies outside the IP country |
| `inconclusive` | `ip_mismatch` | No run started from `client_ip`'s network, so none could count |
| `inconclusive` | `too_few_extenders` | At least 6 extenders reported, but fewer than 6 had the 8 round trips a usable report needs |
| `inconclusive` | `low_precision` | The measurement can't place the visitor: its 1σ long axis is over 1,500 km |
| `inconclusive` | `ip_country_unknown` | The IP address's country is unknown |
| `inconclusive` | `ip_family_mismatch` | Most of the run's sessions used another IP family than its start, so they may have taken another route |
| `inconclusive` | `inconsistent` | Some round trips are too short for the IP country even at the speed of light, while the region touches it |
| `inconclusive` | `reports_missing` | Fewer than 6 of the run's extenders sent a signed report at all |
| `inconclusive` | `stopped_early` | The widget ended the run at a moment the reports don't support |

### The 3-run window {#drift-test-retests}

After "Couldn't verify", the widget offers Retest. A retest is the token's next run, so it needs no new token, and each run adds evidence. After every run, URnetwork recomputes the verdict from the pooled round trips of the token's last 3 runs that count. It is one fit over all their evidence, not a vote: a noisy run is outweighed by later ones, and one lucky run can't wash out two bad ones.

- **Which runs count:** `in_verdict` and `runs_in_verdict` show them. A run from another network never counts, nor does one with fewer than 6 usable reports. Once more than 3 runs count, the oldest drops out.
- **One family:** runs over IPv4 and over IPv6 can end at different places, so the verdict pools only runs of the family of its latest run that counts.
- **New paths:** a retest prefers extenders the token's earlier runs didn't use, since a new path adds independent evidence and a repeated one mostly adds pings.
- **6 runs, one at a time:** the first must start before `expires_at`, and retests are allowed until `retest_until`, 15 minutes after it. Then the token is `closed`, the widget hides Retest, and the verdict is final.
- **Too few reports:** a run with fewer than 6 usable reports completes as `inconclusive`, for `reports_missing` or `too_few_extenders`. It stays out of the verdict, but it still counts toward the 6.

### Try the demo token {#drift-test-demo}

The token `demo` runs the widget without an allocation, for trying it on your pages and for testing accuracy:

```html
<iframe src="https://lag.dev/?t=demo" width="300" height="104"
        title="Location check" style="border:0"></iframe>
```

- **A real measurement:** URnetwork chooses 12 extenders as for any run, and the widget pings them and stops by the same rules.
- **A local verdict:** the widget computes the verdict itself, by the same rule but with a simplified world map, so it can differ slightly from what the server would decide. Retests work and pool the last 3 runs, as for a real token.
- **More figures:** the demo shows what a real token never shows the visitor: the country the pings point to, the distance and margin to the IP country, and the ±. For example, "Demo · pings: France, 21 km outside Spain, region 170 km". It posts the same figures to your page as a `demo-result` message.
- **Nothing stored:** the demo needs no API key and no Embed network. It has no `drift_test_id` and stores no test, so no API can tell whether it passed.
- **Where:** any `https:` page, or a local development page at `http://localhost` or `http://127.0.0.1`, on any port.
- **In a full tab:** `https://lag.dev/?t=demo` runs the demo under the same developer box as [lag.dev/drift-test](https://lag.dev/drift-test), with the frame's HTML and the API calls to copy.
- **Limit:** 30 demo runs an hour from each /24 IPv4 or /48 IPv6 network.

### Limits {#drift-test-limits}

| Limit | Value |
| --- | --- |
| Allocations | 600 a minute for each network |
| The first run | Starts before `expires_at`: 5 minutes after allocation by default, from 1 minute to 1 hour with `ttl_seconds` |
| Runs | 6 for each token, one at a time |
| Retests | For 15 minutes after the first run starts |
| The verdict | Pools the token's last 3 runs that count |
| A check | Usually 8 to 12 seconds from start to verdict, a little less on a retest, at most about 15; a run pings for at most 12 |
| Run starts | 120 an hour from each /24 IPv4 or /48 IPv6 network, shared by everyone behind it, such as an office |
| Demo runs | 30 an hour from each /24 or /48 network |
| Records | Tests and their runs are kept 7 days |

### Privacy {#drift-test-privacy}

- **The visitor** learns only their IP country and whether it was verified.
- **You** learn the verdict, the IP country, the country the pings point to, the distances, the uncertainty, the last-mile offsets and the runs. You don't learn the fitted position or which extenders took part.
- **URnetwork** keeps no IP address, prefix or address hash, with two exceptions. It keeps a peppered hash of `client_ip`'s network until the token closes or expires. And the hourly start limits count runs under a peppered hash of the /24 or /48, each count expiring at the end of its hour.
- **What is kept:** the token only as a hash, with `client_ip`'s country, and for each run the city-level place and network (ASN) of the address that started it. Tests and runs are kept 7 days, URnetwork's IP geolocation never reads them, and lag.dev keeps no access log.
- **The widget** sets no cookies and uses no local storage. Only the token identifies the test.
- **Disclosure:** the widget's footer links to `https://lag.dev/drift-test`, which tells the visitor what is measured, what your site receives and how long it is kept. Your own privacy policy must also cover the check, as the Embed terms require.

### Allowed origins {#drift-test-origins}

By default, the widget runs on any `https:` page, on a local development page at `http://localhost` or `http://127.0.0.1`, and on a page whose origin it can't tell. To limit the sites that can show your network's tokens, [contact us](mailto:support@ur.io) to set your network's allowed origins. A token can narrow them with `parent_origins`, never widen them.

Allowed origins aren't a security boundary: anyone who holds a token can call the API directly and claim any origin. What binds a test to its visitor is `client_ip`'s network.

### Errors {#drift-test-errors}

The two routes your backend calls refuse with these statuses, each with a body of `{"error": {"code", "message"}}`:

| Status | When |
| --- | --- |
| `400` | Code `invalid`: `client_ip` is missing or isn't an IP address, or a field is outside its range, such as a `confidence` of `0.999` |
| `403` | Your network doesn't have Embed enabled: code `embed`, message `Embed isn't enabled for this network.` |
| `403` | The credential is a client JWT, not your network's API key or root JWT |
| `429` | Over 600 allocations in a minute: wait `error.retry_after_ms` milliseconds, or the `Retry-After` header's seconds |

Until our team enables Embed for your network, [request an Embed plan on the Services page](/services). The routes take your network's API key or root JWT, never a client JWT. The API reference lists every status and field of [`POST /lag/drift-test`](/docs/api/other#post-lag-drift-test) and [`GET /lag/drift-test`](/docs/api/other#get-lag-drift-test).

When the widget can't start or finish a check, it posts an `error` message with one of these codes, and asks the visitor to reload the page:

| `code` | Meaning |
| --- | --- |
| `expired` | The token is unknown, or its first run didn't start before `expires_at` |
| `closed` | The token has used its 6 runs, or its retest window is over |
| `busy` | Another run of the token is still measuring |
| `origin` | Your network's allowed origins don't include the page's origin |
| `limit` | A rate limit, such as the hourly start limit for the visitor's /24 or /48 |
| `unavailable` | URnetwork can't run a check now: it has no extenders or no border data to use |
| `network` | The widget got no answer from lag.dev's API |
| `timeout` | The run's verdict didn't reach the widget in time |

Allocate a new token each time the page loads, and treat a code not listed here as a check that couldn't run.

- **Every run reads `client_ip_matches: false`,** and the verdict is `inconclusive` for `ip_mismatch`. You passed an address outside the visitor's network, usually your load balancer's or proxy's.
- **The frame stays blank** on a page that is neither `https:` nor a local development page, or when the page's Content Security Policy doesn't allow `frame-src https://lag.dev`.
- **Every call fails** in a `sandbox` without `allow-same-origin`.
- **There's nothing to read for `demo`:** it has no `drift_test_id`.

**Release availability:** the drift test needs the server release that adds its routes. On an older server, `POST /lag/drift-test` answers 404.
