> For the complete documentation index, see [llms.txt](https://docs.rtkdata.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rtkdata.com/reseller-hub/api/v2.md). Agents can also search and read this documentation through its [MCP server](https://docs.rtkdata.com/~gitbook/mcp).

# API v2: Partner API Guide for Deeper Integrations

The partner API for resellers: NTRIP licenses, trials, customers, grants and bills, an event feed with signed webhooks, and a sandbox.

API v2 is the partner API of the [Reseller Hub](https://docs.rtkdata.com/reseller-hub/reseller-hub.md). With it your shop or back office does everything the portal does: sell trials and paid NTRIP licenses, extend them after each payment, read credentials, follow connections, reconcile your monthly bill against every purchase, and hear about all of it through events.

> **Preview.** v2 is published and working, and RTKdata enables it per account. Until the first stable release a detail of the contract may still change. Ask <support@rtkdata.com> to have v2 switched on for your account. The current API, v1, keeps working as described on the [API v1](https://docs.rtkdata.com/reseller-hub/api/api-v1.md) page; v1 suits a simple shop integration, v2 a deeper one.

|                    |                                                                                                                                                                                                                                                                |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Base URL           | `https://reseller.rtkdata.com/v2`                                                                                                                                                                                                                              |
| OpenAPI document   | `https://reseller.rtkdata.com/v2/openapi.json` (no key needed)                                                                                                                                                                                                 |
| Version descriptor | `GET /v2/meta` (no key needed): status, deprecation and sunset dates, the timestamp format and where the docs live                                                                                                                                             |
| In the portal      | **API > Docs** with the version switch on v2: every endpoint with a working curl, its fields and the errors it answers, generated from the OpenAPI document. **Build with AI** downloads the whole reference as one Markdown file for your AI coding assistant |

This page is the guide: the concepts, the rules every call follows, an overview of every endpoint and how to move from v1. The field-by-field reference is the OpenAPI document and the portal's docs page.

***

## Quickstart

1. In the Reseller Hub, open **API**, switch to **v2**, and create a **test key** under **Keys**. It starts with `rtk_test_` and only ever touches test data.
2. Read your account to check the key works:

   ```bash
   curl https://reseller.rtkdata.com/v2/account \
     -H "Authorization: Bearer rtk_test_xxxxxxxxxxxx"
   ```
3. Start a trial for a customer. The customer is created on the way if the reference is new:

   ```bash
   curl -X POST https://reseller.rtkdata.com/v2/licenses \
     -H "Authorization: Bearer rtk_test_xxxxxxxxxxxx" \
     -H "Idempotency-Key: order-1001-trial" \
     -H "Content-Type: application/json" \
     -d '{
       "kind": "trial",
       "trialDays": 30,
       "customer": { "reference": "shop-customer-1187", "email": "buyer@example.com", "name": "Jane Doe" }
     }'
   ```
4. Read the credentials with `GET /v2/licenses/{id}/credentials` and show them to your customer, or have RTKdata email them in your branding with `POST /v2/licenses/{id}/credentials/send`.
5. With the first successful subscription payment, call `convert` once. With every later payment, call `extend` once. Use your payment id as the `Idempotency-Key` each time.
6. Do nothing when a payment fails. The license ends on its date.

With a test key you can [move the license's clock forward](#sandbox-helpers) and watch all of this happen in minutes. Going live changes the key and nothing else.

***

## Concepts

### A license has an end

A **license** is one set of NTRIP credentials for one of your customers. It is valid until an absolute end, `expiresAt`. You buy access time by creating the license and by extending it; when nobody extends it, it ends by itself. Your shop owns the subscription logic, RTKdata enforces the end on the caster, records each purchase and sends you one bill a month.

| Field                                   | Meaning                                                                                                                                                                                                               |
| --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `validFrom`                             | Start of the first period                                                                                                                                                                                             |
| `expiresAt`                             | End of the access time you bought, the date to show your customer                                                                                                                                                     |
| `accessEndsAt`                          | When the credentials stop working, holds aside: `expiresAt` plus three days of grace for a paid license, no grace for a trial. The grace absorbs a payment confirmed late; it is never billed, so do not plan with it |
| `reinstatableUntil`                     | Until when an expired or ended license can be brought back (30 days); `null` while it is running                                                                                                                      |
| `holds`                                 | The open holds, each with its `owner` (`partner` or `rtkdata`), reason and start                                                                                                                                      |
| `pendingOperation`                      | A change of yours that is still running or unresolved, with its operation id; `null` otherwise                                                                                                                        |
| `firstConnectionAt`, `lastConnectionAt` | What the caster has seen of this login                                                                                                                                                                                |
| `autoRenew`                             | Whether RTKdata extends the license by its last term at the end, like the portal's auto renew. Off by default for API licenses; most shops extend themselves instead                                                  |
| `metadata`                              | Up to 20 string pairs of your own (keys up to 40 characters, values up to 500)                                                                                                                                        |
| `sequence`                              | The license's version, bumped by every change, the same number its events carry                                                                                                                                       |

### Statuses

| `status`       | Meaning                                                      | Credentials                             |
| -------------- | ------------------------------------------------------------ | --------------------------------------- |
| `provisioning` | A create is running or unresolved                            | Not usable yet                          |
| `active`       | Access is granted, no hold                                   | Work                                    |
| `suspended`    | At least one hold is open                                    | Refused                                 |
| `expired`      | `expiresAt` has passed and the license was not ended         | Work until `accessEndsAt`, then refused |
| `ended`        | You or RTKdata ended it early                                | Refused                                 |
| `removed`      | The reinstatement deadline has passed                        | Refused; the license stays readable     |
| `failed`       | The create conclusively failed, nothing was bought or billed | None                                    |

What each call does in each status:

| Call                           | Trial                                                                  | Paid, running                   | `suspended`                                                   | `expired`                     | `ended`                                                                |
| ------------------------------ | ---------------------------------------------------------------------- | ------------------------------- | ------------------------------------------------------------- | ----------------------------- | ---------------------------------------------------------------------- |
| `extend`                       | `invalid_state`, use `convert`                                         | Adds time after `expiresAt`     | Adds time                                                     | Adds time from now            | `reinstate_required` unless `reinstate: true`, then adds time from now |
| `convert`                      | A paid term from the trial's end (`startsAt: "trial_end"`) or from now | `invalid_state`, already paid   | As for running                                                | A paid term from now          | `reinstate_required` unless `reinstate: true`                          |
| `seats`                        | `invalid_state`, a trial has one seat                                  | Adds seats now, priced pro rata | As for running                                                | `invalid_state`, extend first | `invalid_state`                                                        |
| `end`                          | Ends now                                                               | Ends now                        | Ends now                                                      | Ends now                      | Unchanged, 200                                                         |
| `suspend`                      | Places your hold                                                       | Places your hold                | Unchanged if your hold is open                                | `invalid_state`               | `invalid_state`                                                        |
| `reactivate`                   | Unchanged, 200                                                         | Unchanged, 200                  | Clears your hold; `hold_by_rtkdata` if only RTKdata's remains | `invalid_state`               | `invalid_state`                                                        |
| `PATCH` (metadata, auto renew) | Yes                                                                    | Yes                             | Yes                                                           | Yes                           | Yes                                                                    |

In `provisioning`, every changing call answers `operation_in_progress`; in `removed`, `license_removed`; in `failed`, `invalid_state` (make a new create with a new key). A call that changes nothing answers 200 with the unchanged license and produces no event.

### Trials

A trial is free, has one seat and lasts 7, 14 or 30 days. Each of your end customers gets **one trial, ever**. RTKdata recognises the customer by the customer record, every email address it ever had with you, and an optional `entitlementKey` you send on the create, for example the serial number of the receiver you sold. A trial that matches an identifier already used for a trial is refused with `trial_already_used`. After `convert`, the same license, with the same credentials, is paid.

### Grants

Every purchase of access time is recorded as a **grant**: one for the trial (free), one for every paid term, and, when you add seats, one for every paid term that still has time left. A grant carries the price frozen at purchase, your idempotency key and the metadata of the purchase call, and never changes. Your monthly bill lists the grants not yet billed, one line each. `GET /v2/grants?invoiceId=` is the annex of a bill, `GET /v2/grants?unbilled=true` the next bill so far, `GET /v2/grants?licenseId=` the history of a license.

### Holds

A license is `suspended` while it has at least one hold. You place and clear your own with `suspend` and `reactivate`. RTKdata can place its own, for example when bills are long overdue, and only RTKdata clears it (it clears as soon as the access on that license is paid for). Buying time never clears a hold. The license object lists the open holds with their owner.

### Test and live

|                     | Test                                 | Live                   |
| ------------------- | ------------------------------------ | ---------------------- |
| Key prefix          | `rtk_test_`                          | `rtk_live_`            |
| Credentials         | Valid in shape, never connect        | Real                   |
| Billing             | Never; a bill preview is available   | Yes, for paid grants   |
| Clock               | Can be advanced per license          | Real time              |
| Emails to customers | Not sent, the call answers `skipped` | Sent                   |
| Data                | Invisible to live keys               | Invisible to test keys |

Both environments run the same code. An id from the other environment answers 404. Test purchases never influence your live prices or discounts, and nothing in the test environment reaches your inbox or your bill.

***

## Authentication and scopes

Send your key as a bearer token on every request:

```
Authorization: Bearer rtk_test_xxxxxxxxxxxx
```

A key carries one or more **scopes**; each endpoint names the one it needs. Keys created with the portal's presets or through `POST /v2/api-keys` carry exactly the scopes you pick. A key created on the v1 page carries every integration scope and none of the administrative ones.

| Scope                                       | Allows                                                                                       |
| ------------------------------------------- | -------------------------------------------------------------------------------------------- |
| `account:read`                              | Your account, prices and capabilities, the activity feed                                     |
| `licenses:read`                             | Read and list licenses, diagnostics, extension requests, devices and slots                   |
| `licenses:provision`                        | Create, convert, extend, add seats, quotes, the sandbox helpers                              |
| `licenses:write`                            | End, suspend, reactivate, metadata and auto renew, extension requests, claim codes, slots    |
| `credentials:read`                          | Read the NTRIP credentials of a license                                                      |
| `credentials:send`                          | Email the credentials to the customer                                                        |
| `customers:read`, `customers:write`         | Read and list customers; create, change, archive, delete, invite them to the customer portal |
| `bills:read`                                | Grants and bills                                                                             |
| `events:read`                               | The event feed                                                                               |
| `stats:read`                                | The stats roll-ups and the request log                                                       |
| `sessions:read`                             | Caster sessions, live connections and tracks                                                 |
| `webhooks:manage`                           | Webhook endpoints and their deliveries                                                       |
| `keys:manage`                               | API keys of the key's own environment                                                        |
| `members:manage`                            | Your team: invite and change roles (live keys only)                                          |
| `notifications:read`, `notifications:write` | The account's inbox and its settings (settings: live keys only)                              |
| `alerts:manage`                             | Reserved for alert rules, not in use yet                                                     |

Give your checkout service `licenses:provision`, `licenses:read` and `credentials:read`, your subscription job `licenses:provision` and `licenses:write`, and your reconciliation `licenses:read`, `customers:read`, `bills:read` and `events:read`. A key with more scopes than it needs is a bigger risk when it leaks, so harden live keys with an expiry or an IP allowlist and rotate them on a schedule (`POST /v2/api-keys/{id}/rotate`: a successor with the same settings, the old key expires after an overlap of 24 hours by default).

A missing scope answers `403 insufficient_scope`. If RTKdata switches the API off for your account, every key answers `403 api_disabled`.

***

## Conventions

* **Format.** JSON, UTF-8. Requests are strict: an unknown field answers `422 validation_failed`, so a typo never passes silently. Answers may gain fields, ignore the ones you do not know.
* **Timestamps.** `YYYY-MM-DDTHH:mm:ssZ`, UTC, whole seconds, in exactly that spelling. A numeric offset or fractional seconds are rejected.
* **Ids.** Opaque, prefixed strings: `lic_`, `cus_`, `grt_`, `inv_`, `evt_`, `whe_`, `key_`, `ses_`, `dev_`, `op_`, ... Do not parse them.
* **Money.** An integer `amount` in the smallest unit with its `currency`.
* **Metadata.** Up to 20 string pairs on licenses, customers, grants, webhooks and keys. Lists can filter on it with `metadata.<key>=<value>`.
* **Lists.** Take `limit` (1 to 100, default 25) and `cursor`, and answer one page:

  ```json
  {
    "data": [ ... ],
    "hasMore": true,
    "nextCursor": "eyJ...",
    "asOf": "2026-10-08T12:00:00Z"
  }
  ```

  A cursor remembers its filters and expires after a while with `410 cursor_expired`: start the list again.
* **CSV.** The lists marked CSV below answer `text/csv` when your `Accept` header prefers it. `hasMore`, `nextCursor` and `asOf` then travel as the headers `RTK-Has-More`, `RTK-Next-Cursor` and `RTK-As-Of`.
* **Headers on every answer.** `RTK-Request-Id` identifies the request, quote it to support (the portal's request history shows it too). `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` describe your key's sliding window: 60 requests per minute unless the key has a higher tier. Past it, `429 rate_limited` with `Retry-After`.
* **Versioning.** Changes inside v2 are additive: new endpoints, new optional request fields, new response fields, new event types. Ignore fields you do not know. A retiring version announces itself with `Deprecation` and `Sunset` headers on every answer and in `GET /v2/meta`.

***

## Idempotency

Every `POST` and `PATCH` that creates or changes something takes an `Idempotency-Key` header (1 to 200 characters), marked **keyed** in the endpoint tables below. Use something stable from your own system: your order or payment id. Keys are scoped to your account and environment; another account using the same key never affects you.

| Situation                             | Answer                                                                        |
| ------------------------------------- | ----------------------------------------------------------------------------- |
| First use                             | The call runs                                                                 |
| Same key, same request, finished      | The stored answer, with `Idempotency-Replayed: true`; `RTK-Request-Id` is new |
| Same key, same request, still running | `409 operation_in_progress` with `Retry-After`                                |
| Same key, different request           | `409 idempotency_key_reused`; send the new request under a new key            |
| The outcome could not be confirmed    | `503 outcome_unknown` with `Retry-After`; repeat the identical call           |

Which refusals use up a key: `trial_already_used`, `username_taken`, `member_already_exists`, `invalid_state`, `reinstate_required`, `hold_by_rtkdata`, `license_removed` and `provisioning_failed` do, so the same answer is replayed and a different action needs a new key. Everything else (400, 401, 403, 404, 422, 429, `account_past_due`, `operation_in_progress`, `billing_limit_reached`, `caster_unavailable`) does not: fix the request or wait, then send it again unchanged. The [error catalogue](https://docs.rtkdata.com/reseller-hub/api/v2/errors.md) lists it per code.

`RTK-Operation-Id` on the answer names the operation your call started; a license shows an unresolved one as `pendingOperation`, and other changes to that license wait with `409 operation_in_progress` until it resolves. Repeating a call can never create a second license, extend twice or charge twice.

***

## Endpoints

Every path below sits under `https://reseller.rtkdata.com/v2`. **Keyed** calls take an `Idempotency-Key`; **CSV** lists answer `text/csv` on request. The scope column names the key scope the call needs; *any key* means every key of your account may call it, *no key* that the call is public.

### Meta

| Call                      | Scope   | Purpose                                                                                                                  |
| ------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `GET /meta`               | no key  | The version descriptor                                                                                                   |
| `GET /openapi.json`       | no key  | The OpenAPI document                                                                                                     |
| `GET /products`           | any key | What is sold, with the term, trial and seat rules a purchase is validated against                                        |
| `GET /mountpoints`        | any key | The mountpoints every login serves and the frame each resolves to                                                        |
| `GET /casters`            | any key | The caster the credentials name, with host, port and the GGA position rule                                               |
| `GET /coverage?lat=&lng=` | any key | Whether RTK corrections reach a point: `precise` within 25 km of a base station, `standard` within 100 km, `none` beyond |

### Account

| Call                            | Scope            | Purpose                                                                                                                    |
| ------------------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------- |
| `GET /account`                  | `account:read`   | The calling account                                                                                                        |
| `GET /account/pricing`          | `account:read`   | The price list and the discount as in effect now; a purchase freezes its price in its grant                                |
| `GET /account/capabilities`     | `account:read`   | What the account may buy at its current stage, the overdue stages, the purchase limits and the rate limit tiers it may use |
| `GET /activity` (CSV)           | `account:read`   | The activity feed the portal's dashboard shows, newest first                                                               |
| `GET /members` (CSV)            | `members:manage` | Your team: who has joined and who is invited                                                                               |
| `POST /members/invites` (keyed) | `members:manage` | Invite a person by email, as `user` or `admin`; the invite is valid 7 days. Live keys only                                 |
| `PATCH /members/{id}` (keyed)   | `members:manage` | Change a member's or an open invite's role, never the last admin down. Live keys only                                      |

### Customers

| Call                                          | Scope             | Purpose                                                                                                                                                                      |
| --------------------------------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET /customers` (CSV)                        | `customers:read`  | List customers; filters `reference`, `email`, `archived`, `createdSince`, `updatedSince`                                                                                     |
| `POST /customers` (keyed)                     | `customers:write` | Create a customer: `reference` (required, your own id), `email`, `name`, `metadata`                                                                                          |
| `GET /customers/{id}`                         | `customers:read`  | Read a customer                                                                                                                                                              |
| `PATCH /customers/{id}` (keyed)               | `customers:write` | Change a customer                                                                                                                                                            |
| `POST /customers/{id}/archive` (keyed)        | `customers:write` | Archive a customer; refused while it has an active license. A license create with its reference brings it back                                                               |
| `POST /customers/{id}/unarchive` (keyed)      | `customers:write` | Bring an archived customer back                                                                                                                                              |
| `DELETE /customers/{id}`                      | `customers:write` | Delete an archived customer that never had a license                                                                                                                         |
| `POST /customers/{id}/portal-invites` (keyed) | `customers:write` | Email the customer a login link to the [customer portal](https://docs.rtkdata.com/reseller-hub/customer-portal.md), in your branding, valid 15 minutes, one per five minutes |

A license create names its customer by `reference` and creates the customer when the reference is new, so most shops never call `POST /customers` themselves.

### Licenses

| Call                                                            | Scope                | Purpose                                                                                                                                        |
| --------------------------------------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET /licenses` (CSV)                                           | `licenses:read`      | List licenses; filters `status`, `kind`, `customerId`, `reference`, `updatedSince`, `expiresBefore`                                            |
| `POST /licenses` (keyed)                                        | `licenses:provision` | Create a trial or a paid license, see below                                                                                                    |
| `GET /licenses/{id}`                                            | `licenses:read`      | Read a license                                                                                                                                 |
| `PATCH /licenses/{id}` (keyed)                                  | `licenses:write`     | Change `metadata` or `autoRenew`                                                                                                               |
| `GET /licenses/{id}/credentials`                                | `credentials:read`   | `host`, `port`, `mountpoint`, `username`, `password` and a ready-made `setupString`                                                            |
| `POST /licenses/{id}/credentials/send` (keyed)                  | `credentials:send`   | Email the credentials to the customer in your branding; answers `sent`, `skipped` (test license) or `suppressed`                               |
| `POST /licenses/{id}/convert` (keyed)                           | `licenses:provision` | Convert a trial: a term as on create, `seats`, `startsAt` (`trial_end` or `now`), `reinstate`                                                  |
| `POST /licenses/{id}/extend` (keyed)                            | `licenses:provision` | Buy more time: a term as on create, optionally more `seats` for the new term, `reinstate`                                                      |
| `POST /licenses/{id}/seats` (keyed)                             | `licenses:provision` | Add seats to a running paid license, 1 to 100 in total, priced pro rata for every paid term still ahead                                        |
| `POST /licenses/{id}/end` (keyed)                               | `licenses:write`     | End now, with an optional `reason`                                                                                                             |
| `POST /licenses/{id}/suspend` (keyed)                           | `licenses:write`     | Place your hold                                                                                                                                |
| `POST /licenses/{id}/reactivate` (keyed)                        | `licenses:write`     | Clear your hold                                                                                                                                |
| `POST /quotes`                                                  | `licenses:provision` | Price a `create`, `convert`, `extend` or `seats` call without making it                                                                        |
| `GET /licenses/diagnostics` (CSV)                               | `licenses:read`      | Every license with its connection diagnostics of the last 30 days: connected now, parallel connections, failed logins, GGA received, last seen |
| `GET /licenses/{id}/diagnostics`                                | `licenses:read`      | One license's diagnostics; the caster's answer of the last five minutes is reused                                                              |
| `POST /licenses/{id}/diagnostics/run`                           | `licenses:read`      | The same, the caster asked afresh                                                                                                              |
| `POST /licenses/{id}/extension-requests` (keyed)                | `licenses:write`     | Ask RTKdata for more days (1 to 90) or more seats on a running trial; decided by RTKdata, a test request is approved at once                   |
| `GET /extension-requests` (CSV), `GET /extension-requests/{id}` | `licenses:read`      | Your extension requests and their decisions                                                                                                    |

**Creating a license.** `POST /v2/licenses` takes:

| Field                           | Meaning                                                                                                                                                                        |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `kind`                          | `trial` or `paid` (required)                                                                                                                                                   |
| `trialDays`                     | For a trial: 7, 14 or 30                                                                                                                                                       |
| `months`, `days` or `expiresAt` | For a paid license, exactly one: 1 to 12 months (12 is the annual rate), 30 to 364 days, or an absolute end                                                                    |
| `seats`                         | 1 to 100, default 1; a trial always has one                                                                                                                                    |
| `customer`                      | `reference` (required; letters, digits and `-_.:@+~`, up to 120 characters), `email`, `name`. An existing customer is found by reference, a new one created                    |
| `entitlementKey`                | Optional, for trials: an identifier such as the receiver's serial number, so a second trial on the same hardware is refused                                                    |
| `credentials`                   | Optional: your own `username` (3 to 64 characters) and `password` (6 to 64) for the login instead of a generated pair. A username in use anywhere answers `409 username_taken` |
| `autoRenew`                     | Default `false`                                                                                                                                                                |
| `metadata`                      | Your own pairs, stored on the license and frozen on the grant                                                                                                                  |

The answer is the license with status `active` and no credentials inside: read them with the credentials call. A create that could not reach the caster answers `503 caster_unavailable` and leaves nothing behind; a create that conclusively failed answers `502 provisioning_failed` with the license id, and the license reads `failed`.

**Purchases and your standing.** A purchase is refused with `402 account_past_due` once your account is far enough behind on a bill: new licenses and trials first, then conversions, extensions and seats. `GET /v2/account/capabilities` says what is allowed right now, and [Billing](https://docs.rtkdata.com/reseller-hub/billing.md#when-a-bill-is-overdue) explains the stages. A purchase that would push your unbilled total past what one bill can carry answers `409 billing_limit_reached`.

### Devices

For hardware that signs itself in without your backend in the loop:

| Call                                          | Scope            | Purpose                                                                                                                                                                                               |
| --------------------------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST /licenses/{id}/claim-code` (keyed)      | `licenses:write` | Mint a single-use claim code, valid 7 days, answered once; replaces the license's open code                                                                                                           |
| `POST /devices/claim`                         | no key           | The device spends the code with its `serial`: it takes a free slot of the license and receives its `clientId`, a `clientSecret` (answered once) and the NTRIP credentials. The code is the credential |
| `POST /oauth/token`                           | no key           | OAuth 2.0 client credentials: the device trades client id and secret for a device token valid one hour                                                                                                |
| `GET /devices/self`                           | device token     | The device behind the calling token; a device token may also read its own license, credentials and diagnostics                                                                                        |
| `GET /licenses/{id}/slots`                    | `licenses:read`  | The license's slots, one per seat, with the device in each                                                                                                                                            |
| `PATCH /licenses/{id}/slots/{slotId}` (keyed) | `licenses:write` | Name a slot, or `release: true` the device in it so the slot is free for the next claim                                                                                                               |
| `GET /devices` (CSV), `GET /devices/{id}`     | `licenses:read`  | Your claimed devices, released ones included                                                                                                                                                          |

A full license answers `409 slots_full`; buy seats or release a device.

### Grants and bills

| Call                          | Scope        | Purpose                                                                                                                                                     |
| ----------------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET /grants` (CSV)           | `bills:read` | The purchase ledger; filters `invoiceId`, `billedPeriod`, `unbilled`, `licenseId`, `customerId`                                                             |
| `GET /bills` (CSV)            | `bills:read` | Your monthly bills; filters `status` (`open`, `overdue`, `paid`, `void`), `period`, `source` (`portal`, or `legacy` for the archive of the previous portal) |
| `GET /bills/upcoming`         | `bills:read` | The running month so far: a header, the lines are `GET /grants?unbilled=true`                                                                               |
| `GET /bills/{id}`             | `bills:read` | Read a bill                                                                                                                                                 |
| `GET /bills/{id}/lines` (CSV) | `bills:read` | Its grants, the same rows as `GET /grants?invoiceId=`                                                                                                       |
| `GET /bills/{id}/pdf`         | `bills:read` | The PDF; `409 pdf_not_ready` while it is being rendered                                                                                                     |
| `GET /stats/bills`            | `stats:read` | Counts, what is outstanding, the most recent and the next due                                                                                               |

A grant carries `listAmount`, `discountRate` and `amount` (list less your discount), and `billing`: `chargeable`, `free` or `settled`. Prices are frozen at purchase, so the annex of a bill never changes after the fact. Nothing in the test environment is ever billed.

### Events

| Call                         | Scope         | Purpose                                                                                                                      |
| ---------------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `GET /events?afterPosition=` | `events:read` | The feed, oldest first from the position you give; filters `type`, `licenseId`. Answers `data`, `hasMore` and `nextPosition` |
| `GET /events/{id}`           | `events:read` | Read one event                                                                                                               |

Events are kept 90 days. A position older than that answers `410 event_history_expired` with the position to resume from. See [events and webhooks](#events-and-webhooks).

### Webhooks

| Call                                                | Scope             | Purpose                                                                                                                                                                |
| --------------------------------------------------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET /webhooks`, `GET /webhooks/{id}`               | `webhooks:manage` | Your endpoints in the key's environment                                                                                                                                |
| `POST /webhooks` (keyed)                            | `webhooks:manage` | Register an endpoint: `url`, `events` (the types it wants), `payloadVersion` (`v2` default, `v1` for the legacy body), `metadata`. The signing secret is answered once |
| `PATCH /webhooks/{id}` (keyed)                      | `webhooks:manage` | Change url, events, payload version, or switch it off and on (`enabled`)                                                                                               |
| `DELETE /webhooks/{id}`                             | `webhooks:manage` | Remove an endpoint                                                                                                                                                     |
| `GET /webhooks/{id}/deliveries`                     | `webhooks:manage` | The delivery log; filters `status`, `eventType`                                                                                                                        |
| `POST /webhooks/{id}/deliveries/{deliveryId}/retry` | `webhooks:manage` | Send one delivery again                                                                                                                                                |
| `POST /webhooks/{id}/test`                          | `webhooks:manage` | A signed `webhook.ping`                                                                                                                                                |
| `POST /webhooks/{id}/roll-secret`                   | `webhooks:manage` | A new signing secret; the old one signs as well for 24 hours                                                                                                           |

### API keys and the request log

| Call                                  | Scope         | Purpose                                                                                                                                                                  |
| ------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `GET /api-keys`, `GET /api-keys/{id}` | `keys:manage` | The keys of the calling key's environment                                                                                                                                |
| `GET /api-keys/self`                  | any key       | The calling key                                                                                                                                                          |
| `POST /api-keys` (keyed)              | `keys:manage` | Create a key: `label`, `scopes` (within the caller's own), `principal`, `expiresAt`, `ipAllowlist` (up to 50 CIDR entries), `rateLimitTier`. The secret is answered once |
| `PATCH /api-keys/{id}` (keyed)        | `keys:manage` | Change any of those                                                                                                                                                      |
| `POST /api-keys/{id}/revoke`          | `keys:manage` | Revoke at once                                                                                                                                                           |
| `POST /api-keys/{id}/rotate` (keyed)  | `keys:manage` | A successor with the same settings and a new secret; `overlapHours` 0 to 168, default 24, then the old key expires                                                       |
| `GET /api-keys/{id}/usage?days=`      | `keys:manage` | One key's calls: totals, by route, per day                                                                                                                               |
| `GET /api-requests` (CSV)             | `stats:read`  | The request log, newest first; find a call by the `RTK-Request-Id` it answered with                                                                                      |

### Stats

Ready-made roll-ups for your own dashboards, all under `stats:read`: `GET /stats/customers`, `/stats/licenses`, `/stats/trials`, `/stats/usage`, `/stats/usage/trend` (CSV), `/stats/sessions`, `/stats/sessions/trend`, `/stats/api`, `/stats/api/trend`, plus `/stats/bills` and `/stats/notifications` under their own scopes. A test key sees its own test data.

### Sessions

| Call                       | Scope           | Purpose                                                                                                                                                                     |
| -------------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET /sessions` (CSV)      | `sessions:read` | Caster sessions of your licenses, newest first, the last 30 days unless you give `startedSince` and `startedBefore`; filters `licenseId`, `customerId`, `status`, `outcome` |
| `GET /sessions/live`       | `sessions:read` | The open connections with a known position right now                                                                                                                        |
| `GET /sessions/{id}/track` | `sessions:read` | The recorded path of a session as JSON, GeoJSON (`format=geojson` or `Accept: application/geo+json`) or GPX (`format=gpx` or `Accept: application/gpx+xml`)                 |

### Notifications

The account's inbox as the portal shows it under the bell: `GET /notifications` (CSV) and `GET /stats/notifications` under `notifications:read`; `PATCH /notifications/{id}` (read or unread), `POST /notifications/read-all`, `DELETE /notifications/{id}`, and `GET` and `PATCH /notification-settings` (which kind reaches which channel, the recipient address, the digest cadence) under `notifications:write`. A test key's inbox is empty, and only a live key may change the settings.

***

## Events and webhooks

Everything that happens to your licenses, customers, bills and integration is an **event**. Read them in order from `GET /v2/events`, or register a webhook endpoint with the event types it wants and receive each as a signed `POST`. Nothing is pushed to an endpoint that did not subscribe to it.

### Event types

| Area                              | Types                                                                                                                                                                                                                                                                                                                              |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| License lifecycle                 | `license.created`, `license.activated` (the credentials work from now on), `license.failed`, `license.converted`, `license.extended`, `license.updated` (seats, metadata, auto renew or a hold changed without changing access), `license.suspended`, `license.reactivated`, `license.expired`, `license.ended`, `license.removed` |
| License reminders and connections | `license.trial_expiring` and `license.expiring` (one day before the end, with `threshold` and `expiresAt`), `license.first_connection`, `license.never_connected`, `license.credentials_sent`                                                                                                                                      |
| Sessions                          | `session.started`, `session.ended`                                                                                                                                                                                                                                                                                                 |
| Customers                         | `customer.created`, `customer.updated`, `customer.archived`, `customer.unarchived`, `customer.deleted`                                                                                                                                                                                                                             |
| Billing                           | `invoice.issued`, `invoice.paid`, `account.past_due` (your standing changed, with `pastDue` and `stage`)                                                                                                                                                                                                                           |
| Your integration                  | `api_key.created`, `api_key.updated`, `api_key.revoked`, `api_key.rotated`, `webhook.created`, `webhook.updated`, `webhook.deleted`, `webhook.failing`, `webhook.recovered`                                                                                                                                                        |
| Team, requests, devices           | `member.invited`, `member.updated`, `extension_request.submitted`, `extension_request.decided`, `device.claimed`, `device.released`                                                                                                                                                                                                |
| v1 names                          | `license.cancelled`, `license.renewed` and the other six v1 types still exist for v1 subscribers: an endpoint with payload version `v1` receives `license.ended` as `license.cancelled`, `license.extended` as `license.renewed` and `license.converted` as `license.updated`                                                      |

### The envelope

```json
{
  "id": "evt_3f2b8c1e5d4a4e7b9c1f2a6d8e0b7c45",
  "position": 48214,
  "type": "license.suspended",
  "occurredAt": "2026-10-08T12:00:00Z",
  "sequence": 12,
  "data": {
    "license": {
      "id": "lic_3f2b8c1e5d4a4e7b9c1f2a6d8e0b7c45",
      "status": "suspended",
      "...": "the license as GET /v2/licenses/{id} returns it, without credentials"
    }
  }
}
```

`position` is the event's place in your account's feed, `sequence` the resource's version after it (`null` for invoice, account and ping events), so a receiver can drop an event that arrives after a newer one of the same resource. License and customer events carry the full object, never credentials. The same event can arrive more than once; deduplicate on `id`.

### Checking the signature

Every delivery is signed with the endpoint's signing secret, shown once when you add the endpoint or roll its secret:

```
RTK-Signature: t=1759233600,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
RTK-Event-Id: evt_3f2b8c1e5d4a4e7b9c1f2a6d8e0b7c45
RTK-Event-Type: license.suspended
RTK-Delivery-Id: 0e3c8f52-7d1b-4b9e-a6f4-2c5d8e1a9b70
RTK-Delivery-Attempt: 1
Content-Type: application/json
```

`t` is the time of this attempt in unix seconds, `v1` the hex HMAC-SHA256 of `t`, a dot and the raw request body. For 24 hours after a secret roll the header carries one `v1` per secret, old and new: accept the delivery when any matches. Refuse a `t` more than five minutes from your clock.

```javascript
import crypto from "node:crypto"

// rawBody: the request body exactly as received, before any JSON parsing.
// secret: the endpoint's signing secret (whsec_...).
function isFromRtkdata(rawBody, signatureHeader, secret) {
  const parts = signatureHeader.split(",").map((part) => part.split("="))
  const timestamp = Number(parts.find(([key]) => key === "t")?.[1])
  if (!timestamp || Math.abs(Date.now() / 1000 - timestamp) > 300) return false

  const expected = crypto.createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest()
  return parts
    .filter(([key]) => key === "v1")
    .map(([, value]) => Buffer.from(value, "hex"))
    .some((given) => given.length === expected.length && crypto.timingSafeEqual(given, expected))
}
```

### Answering and retries

Answer with any 2xx within 10 seconds, do the actual work afterwards. A transport failure or a 5xx is retried with growing pauses for about three days, then the endpoint is marked **failing**, you are notified, and `webhook.failing` is emitted (`webhook.recovered` once a delivery goes through again). A 4xx answer other than 408, 425 or 429 counts as a rejection of that delivery and is not retried. Events keep being collected while an endpoint fails; resend what you missed from the delivery log, or read the feed from your last position. Webhooks are a convenience: the read endpoints are the source of truth.

***

## Sandbox helpers

With a test key you can rehearse the whole life of a license, the events it causes and the bill it would produce. Three calls exist for test keys only (a live key answers `403 test_only`); they need `licenses:provision` and take no idempotency key.

| Call                                                                                 | Purpose                                                                                                                                                                                                                                                         |
| ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST /test/clock` with `licenseId` and `advanceTo`                                  | Moves that license's clock forward and runs everything that became due on the way, in order: reminders, expiry, grace end, removal, each with its event. Answers the license with its `testClock`. Advancing to a time not later than the clock changes nothing |
| `POST /test/sessions` with `licenseId`, `sessionKey`, `startedAt`, `durationSeconds` | Records a connection, so `license.first_connection`, `license.never_connected`, `lastConnectionAt`, the sessions area and the diagnostics can be rehearsed. The same `sessionKey` again changes nothing                                                         |
| `GET /test/bill-preview?period=2026-11`                                              | What the bill for that period would contain, computed from your test grants with the same selection and pricing as a real bill                                                                                                                                  |

A whole customer life in one run: create a trial, record a session and receive `license.first_connection`, advance to the day before the end and receive `license.trial_expiring`, convert, advance to the end of the paid term and receive `license.expiring` and `license.expired`, advance three more days and watch `accessEndsAt` pass, advance 30 more and receive `license.removed`. The portal's **Test data** tab shows everything the rehearsal created.

Purchase times, `from`, `to`, `expiresAt`, reminders and the `occurredAt` of the license's events follow the license's clock. `createdAt`, `updatedAt`, event positions, list order, signatures, retries, rate limits and idempotency follow real time.

***

## Moving from v1

| v1                                                                           | v2                                                                                                                                         |
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `POST /v1/provision` with `product`, `seats`, `term` and `termAmount`        | `POST /v2/licenses` with `kind`, `seats`, and `months`, `days` or `expiresAt`                                                              |
| `product: "ntrip_demo"` with `trialDurationDays`                             | `kind: "trial"` with `trialDays`                                                                                                           |
| A customer matched by `customerEmail`, `customerReference` or `customerName` | `customer.reference` is required and is how your customer is recognised; `email` and `name` ride along                                     |
| Credentials in every license answer                                          | `GET /v2/licenses/{id}/credentials`, scope `credentials:read`                                                                              |
| `POST /licenses/{id}/update` on a trial                                      | `POST /v2/licenses/{id}/convert`                                                                                                           |
| `POST /licenses/{id}/update` with more seats or a longer term                | `POST /v2/licenses/{id}/seats`, `POST /v2/licenses/{id}/extend`                                                                            |
| `POST /licenses/{id}/renew`                                                  | `extend` by the term the customer paid for                                                                                                 |
| `POST /licenses/{id}/cancel` (auto renew off)                                | Stop extending, or `PATCH` with `autoRenew: false` if you switched it on; `end` stops access now                                           |
| `POST /licenses/{id}/auto-renew`                                             | `PATCH /v2/licenses/{id}` with `autoRenew: true`                                                                                           |
| `suspend`, `reactivate`                                                      | The same, now as your hold beside RTKdata's                                                                                                |
| Timestamps with milliseconds, `.000Z`                                        | `YYYY-MM-DDTHH:mm:ssZ`, whole seconds                                                                                                      |
| Errors as HTTP status plus message                                           | One body with a stable `code`, `requestId` and `docUrl`; see the [error catalogue](https://docs.rtkdata.com/reseller-hub/api/v2/errors.md) |
| Webhook body: the v1 license object                                          | Register endpoints with `payloadVersion: "v2"` for the envelope above; existing endpoints keep the v1 body and names                       |
| One key per environment, every call allowed                                  | Keys carry scopes, an expiry, an IP allowlist and a rate limit tier                                                                        |

Your existing v1 keys, webhooks and licenses keep working. Licenses created through v1 are visible in v2 lists and can be managed through v2 as long as they run on RTKdata's own caster; a license on another caster answers `404 license_not_found` in v2 and stays with v1 and the portal. The `Idempotency-Key` header, the test and live key prefixes and the webhook signature scheme are the same in both versions.

***

## Next

* [Error catalogue](https://docs.rtkdata.com/reseller-hub/api/v2/errors.md) - every `code`, its status, and whether it uses up your idempotency key
* [API](https://docs.rtkdata.com/reseller-hub/api.md) - the API area in the Reseller Hub, keys, webhooks and the request history
* [Billing](https://docs.rtkdata.com/reseller-hub/billing.md) - your monthly bill, the tier discount and what happens when a bill is overdue


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rtkdata.com/reseller-hub/api/v2.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
