# Versioning and deprecation

The API is versioned in its path: `/v1`. Within a version WatchTower15 only **adds**.

## The OpenAPI document

The contract is one file, `https://developer.watchtower15.com/openapi/v1.json`, the document the [reference](https://developer.watchtower15.com/api/reference/) is built from. The ingest API has its own document, `https://developer.watchtower15.com/openapi/ingest.json`. Both are written by one command from the code that serves them, so they cannot drift from it, and both are published under the MIT licence: anyone may generate, adapt and publish a client from them.

The API host serves the same REST document itself, without a key, at `https://rest.watchtower15.com/v1/openapi.json` (with an `ETag`, so a client that sends `If-None-Match` is answered `304` while it has not changed). Every `/v1` answer names the document in a `Link` header, `rel="service-desc"`, beside this site’s index of the Markdown reference, `https://developer.watchtower15.com/llms.txt`, `rel="service-doc"`:

```plaintext
Link: <https://developer.watchtower15.com/openapi/v1.json>; rel="service-desc", <https://developer.watchtower15.com/llms.txt>; rel="service-doc"
```

`info.version` is `1.0.0+sha.` followed by twelve hexadecimal digits: a fingerprint of the document’s content. It changes whenever anything in the document changes, a description included, and it orders nothing: a different fingerprint does not mean a newer or a breaking document, only a different one. Pin the fingerprint to know exactly which contract a client was generated from.

Two things in it are promises a generated client can rely on:

-   **`operationId` is the operation’s name and never changes inside `v1`.** It reads `public.servers.list`, `public.incidents.acknowledge`, and so on, so a client can name its methods after it and keep them across releases.
-   **Every enum is an open set, and says so.** Wherever the document lists the values of a field, the field also carries `x-wt15-open-enum: true`. A generator should keep such a field a plain string (or an enum with a catch-all), never a closed list that fails on a value it does not know, because new values are added.

## Three version numbers

-   **`v1`** is the API’s version. It is in every path and in the badge at the top of this site, and within it the API only grows.
-   **`info.version`** is each document’s fingerprint, `1.0.0+sha.` followed by twelve hexadecimal digits. It changes exactly when the contract does; [Specifications](https://developer.watchtower15.com/specs/) shows each document’s.
-   **Each SDK’s release number** follows Semantic Versioning, independently of both. See [SDKs](https://developer.watchtower15.com/sdks/).

## The marks

Beside the standard OpenAPI fields, the documents carry five marks a generator can read instead of guessing:

-   **`x-wt15-open-enum: true`** on a field that lists values: keep it open, as above.
-   **`x-wt15-instant: true`** on an integer that holds a point in time, in epoch milliseconds, UTC.
-   **`x-wt15-paged: true`** on an operation that answers one page of a list. Its answer says how it pages: by `page` when it has `current_page` (with `per_page`, `last_page` and `total`), by `cursor` when it has `next_cursor`, sent back as `cursor`.
-   **`x-wt15-scopes`** on every operation: the list of scopes the API key needs (empty when none is needed, as on the ingest operations, where the token is the only credential).
-   **`x-wt15-idempotent: true`** on an operation that honours the optional `Idempotency-Key` header.

## What may be added to /v1

-   New operations.
-   New optional parameters.
-   New fields in answers.
-   New values in a field that lists values (an enum).

Write your client to ignore fields it does not know, and to treat an enum as an open set: an unknown value is not an error.

## What is a breaking change

Removing an operation, a field or an enum value, making an optional parameter required, or changing what a field means. WatchTower15 does not make these inside `/v1`. They arrive as a new operation or as `/v2`, and the old one keeps working for a stated period.

The one removal since the launch was WatchTower15’s own decision: the page lists’ `cursor` parameter and `next_cursor` field, replaced by `page` and the page fields (`current_page`, `per_page`, `last_page`, `total`). Log search, a custom metric’s samples and a service’s scans and runs keep `cursor` and `next_cursor`. See [pagination](https://developer.watchtower15.com/api/pagination/).

## Retirement

When an operation or version is to be retired, its answers carry a `Deprecation` header from the day it is announced and a `Sunset` header with the date it stops. Watch for them in your client’s logs.

The [reference](https://developer.watchtower15.com/api/reference/) always shows the current contract.

**Fetch the contract and its fingerprint**

```bash
curl -sO https://developer.watchtower15.com/openapi/v1.json
jq -r '.info.version' v1.json
```

**Output**

```text
1.0.0+sha.3c9e41d07a5b
```

Source: https://developer.watchtower15.com/api/versioning/
