# API versioning policy

Source: https://docs.askaniela.com/reference/versioning/

Applies to the public REST API. The version is in the path: `/v1/...`; every `/v1` response has the
`X-API-Version: v1` header.

## Stable within `/v1`
- Paths, methods, input/output field names and types, the error format and codes from [errors.md](https://docs.askaniela.com/reference/errors.md).

## Non-breaking changes (in `/v1`, changelog entry)
- New endpoint, new **optional** input field, new response field, new error code, new rule in the catalog,
  new profile. Clients must ignore unknown response fields.
- Changes to error `message` text and OpenAPI descriptions.

## Breaking changes (only in a new version, e.g. `/v2`)
- Removing/renaming a field or endpoint, type change, new required field, changing the meaning of a `code`,
  changing result semantics (e.g. the `score` scale).
- **Beta exception:** during the closed beta, resource ids changed from integers to opaque public ids
  (`rep_…`, `prj_…`, see [Identifiers](https://docs.askaniela.com/guide/concepts.md#identifiers)) in place, without `/v2`.
- **Beta exception:** the default `strategy` of `POST /v1/audits/site` changed from `newest+stratified`
  to `groups` (pages linked from the home page + newest pages of the current year + random archive; one extra fetch
  of the home page). Requests without `strategy` now pick a different sample. To keep the previous sample, send
  `"strategy": "newest+stratified"` explicitly; the other strategies are unchanged.
- Rule versioning (`ver`) and prompt versioning (`PROMPT_VER`) are separate: they change results, not the contract.
  Reports include these versions, so clients can see what produced them.

## Deprecation
- A deprecated endpoint/version sends `Deprecation` (RFC 9745) and `Sunset` (RFC 8594) headers with the shutdown
  date, and `Link: <…>; rel="deprecation"` to the migration notes.
- Support period: at least **6 months** from the deprecation announcement to `Sunset`; `/vN` and `/vN+1` run in
  parallel during that time.
- Announcement: [What's new](https://docs.askaniela.com/changelog.md).
