# Versioning

> How dated API versions pin request, response, and event shapes, what Koil changes within a version, and how long old versions stay supported.

Koil versions its API by date. Every request with an API key names the version it was written against in the `Koil-Version` header, and Koil answers in that version's shapes. The current version is `2026-12-08`:

```bash
curl "https://api.koil.co/v1/publish-requests/sandbox_pub_7GhQ2dLkP0aZ1xYc9VwN" \
  -H "Authorization: Bearer $KOIL_API_KEY" \
  -H "Koil-Version: 2026-12-08"
```

Pin the version in your client's configuration, next to the key, and change it on purpose, after testing against the new version.

-   A request without `Koil-Version` is refused with `validation_error`, with a violation naming the header.
-   A request naming a version Koil does not support (a typo, a future date, a retired version) is refused with `validation_error`; the message lists the supported versions.
-   Keyless routes (platform discovery, hosted connect pages, OAuth callbacks) don't need the header.
-   Every response carries `Koil-Version`: the version it is rendered in. That is the version you sent, or the current version when a request names none Koil supports.

The `/v1` path prefix is not the version. It names the API's generation and marks the public API apart from the other routes on `api.koil.co`; breaking changes ship as new `Koil-Version` dates, never as a new path prefix.

## What a version pins

-   **Requests and responses.** A version fixes every endpoint's request fields, response fields, and their meaning, and the error envelope.
-   **Events, per destination.** An Event Destination keeps the `Koil-Version` of the request that created it as its `apiVersion`, and receives every event rendered in that version. Each event carries its version in the envelope's `apiVersion`. A destination's version never changes: `PATCH` can't set it. To move a destination to a newer version, create a new destination with the newer `Koil-Version`, run both while your consumer switches over, and then delete the old one.

## Changes within a version

Koil makes only backward-compatible changes within a version. Your integration must tolerate all of these:

-   New endpoints and resources.
-   New optional request fields and query parameters, and new optional request headers.
-   New fields in responses, in an error's `meta`, and in an event's `context` and `data`. Koil validates requests strictly against the [OpenAPI document](https://docs.koil.co/openapi.json) and refuses a field it doesn't describe with `unknown_field`, but responses and events may gain fields and enum values within a version. Code generated from the document must still accept fields and values it does not know.
-   New values of response enums: a new `status`, a new platform or collection, a new violation `code`.
-   New event topics, collections, and platforms. A destination subscribed to a family (`content.*`) receives a new topic in that family as soon as Koil emits it.
-   New error codes, only for new failures: a new endpoint's, or a new check's. A failure that already has a code keeps that code and its HTTP status. Handle a code you don't know by its HTTP status and `Retry-After`.
-   New response headers, a different order of fields, and a different format or length of opaque strings: ids, cursors, error messages.

So ignore fields you don't use, handle unknown enum values, topics, and error codes, and never parse ids or messages.

The [OpenAPI document](https://docs.koil.co/openapi.json) states this: request bodies are published with `additionalProperties: false`, response and event schemas without it, and string unions as `enum`. A generated client may not follow these rules: some reject a field or an enum value they don't know, or an event whose `topic` is new. Check that yours accepts all three.

Every other change ships only in a new version. Examples are removing or renaming a field, parameter, or endpoint; changing a field's type, format, or meaning; making an optional request field required; removing an enum value; changing a default; and changing an existing failure's code or status. Requests from older versions keep working as before. Koil converts them to the newest shape and converts responses and events back.

## Support window

A version stays supported for at least 18 months after a newer version is released. The one exception is a platform retiring an API or a capability. Koil can't serve what the platform no longer offers, so the platform's own deadline applies to every version, and Koil announces it as early as the platform does.

When a version is deprecated, every response to a request naming it carries a `Deprecation` header ([RFC 9745](https://www.rfc-editor.org/rfc/rfc9745)) with the date of its deprecation. It also carries a `Sunset` header ([RFC 8594](https://www.rfc-editor.org/rfc/rfc8594)) with the date it stops being accepted. After that date, requests naming it are refused like those naming an unknown version. Watch for these headers in your logs. While only one version exists, Koil sends neither header.
