# API Versioning

> What may change within v1, what your code should tolerate, and how a breaking change is introduced.

Source: https://imario.ai/docs/api/versioning

## The version is in the path

Every endpoint starts with `/v1`. The OpenAPI document at `https://api.imario.ai/v1/openapi.json` describes the current state of v1.

## What changes within v1

v1 only grows. iMario may, without a new version:

- add endpoints,
- add fields to objects and to event payloads,
- add optional request parameters,
- add values to a list of values, such as a new kind of study, a new status or a new event type,
- add error codes.

Write your code so these never break it: ignore fields you do not know, treat an unknown value of `status` or `kind` as something to skip or log rather than a crash, and handle an unknown error `code` by its `type`.

## What needs a new version

Removing or renaming a field or an endpoint, changing a field's type or meaning, or making an optional parameter required is a breaking change. A breaking change ships as `/v2`, and `/v1` keeps working for 12 months after `/v2` is released, so you can move at your own pace.

## Where to see what changed

The OpenAPI document and the [API reference](https://imario.ai/docs/api/reference), which is generated from it, always describe v1 as it is now. To see exactly what was added since you last looked, compare a saved copy of `https://api.imario.ai/v1/openapi.json` with the current one.
