# Compatibility policy

The Omono API has its major version in the URL: every path starts with
`/api/v1`. This policy explains which changes Omono can make within version
1, and how to build an integration that keeps working as the API grows. The
[changelog](/docs/changelog) lists every change to the API, whether or not
it's breaking. A change takes effect when the changelog lists it: Omono
doesn't give notice in advance, so check the changelog regularly.

Each section of the changelog has the date its changes were first released.
Omono updates its hosts one after another, so a change can reach the host
you use after that date. The changelog on each host, at
`https://<host>/docs/changelog`, lists a change once it has reached that
host, and that's when the change takes effect there.

## While the API is in beta

The Omono API is in beta until it becomes generally available. Omono will
announce general availability in the changelog.

Until then, any part of the API can change, including in ways this policy
would otherwise call breaking. That covers the shape of requests and
responses, how an operation behaves, its status codes and error codes, and
the limits. In beta, stable operations can change too, but Omono expects
them to change less than beta operations, as
[Stable and beta operations](/docs/compatibility#stable-and-beta-operations) explains.

Changes that an integration makes through the API are real and take effect
immediately. So test a new integration on a
[sandbox organisation](/docs/getting-started#sandbox) first. To get one, ask
Omono through the in-app chat. Don't make a critical process depend on the
API alone yet. If you find a problem, report it through the in-app chat.

## Urgent fixes

Once the API is generally available, a breaking change to a stable
operation needs a new major version, as
[Breaking changes](/docs/compatibility#breaking-changes) explains. There's one exception: if
Omono has to fix a security problem, or a problem that could damage your
data, the fix can break version 1. Like any other change, it takes effect
when the changelog lists it.

## Breaking changes

Once the API is generally available, a breaking change to a stable
operation needs a new major version, `/v2`. These changes are breaking:

- Removing or renaming a field, an endpoint, a query parameter or an error
  code.
- Renaming an operation's `operationId`, a schema that it uses, or the tag
  it's listed under. A client that you generate from the OpenAPI document
  takes its method and type names from these, so a rename would break your
  code the next time you generate the client.
- Changing a field's type, or giving a number more decimal places than its
  description allows.
- Adding a required field or parameter to a request, or tightening the
  checks on the shape of a request, such as a lower maximum length for a
  text field, so that a request that was accepted before is now refused.
- Changing the status code or the error code that's returned for an
  existing condition.
- Removing a value that a request accepts, from a field or a filter that
  takes a value from a list.
- Changing how pagination works, which means the list envelope and the
  `cursor` and `limit` parameters. The contents of a cursor aren't part of
  this, as [Opaque values](/docs/compatibility#opaque-values) explains.
- Narrowing a scope.

When `/v2` opens, Omono keeps supporting `/v1` for 12 months.

## Changes that aren't breaking

These changes can ship within version 1 at any time, and each one comes with
a changelog entry:

- New endpoints, fields, optional parameters and error codes.
- New values in a list of values that a response can hold, such as a new
  status, a new `blockedBy` code or a new kind of event.
- New response headers.
- Looser checks on requests.
- Changes to the text of an error, which means its `title`, its `detail`
  and each `errors[].message`, and to the order of the items in `errors[]`.
- A number with fewer decimal places than its field allows.
- Changes to the OpenAPI document that don't change how the API behaves or
  the names in it, such as a clearer description or a new example.

## Business rules and behaviour

The API follows the same business rules as Omono itself, and those rules
change as Omono grows. These changes aren't breaking, and each one comes
with a changelog entry:

- A new refusal that depends on the state of a record, such as a new reason
  a dispatch can't ship. The request fails with a `409` error and a new
  code, and a new reason a dispatch can't ship also appears as a new code
  in `blockedBy`.
- A changed default, such as a different value that Omono fills in when you
  leave a field out.
- A change to the work Omono does after a request, such as the notes and
  activity it records, or what it sends to your accounting software.

A new check on the shape of a request, such as a new required field or a
lower maximum length for a text field, is different: that's a breaking
change.

One promise stays firm. Omono won't start to email your customers or
suppliers because of an API request, unless an admin switches that email on
in Omono or the request asks for it.

## Limits

Rate limits and the other limits protect the platform, so they can change
within version 1. The limits are the allowances in
[Rate limits](/docs/limits), how much each kind of request counts against
them, and the most that one request can send or return: the number of line
items in one request, the number of related records a page can include, the
page size and the size of a request body. They also include the number of
refused requests a key can send in a minute. These limits aren't checks on
the shape of a request, so a change to one of them isn't a breaking change,
even when Omono then refuses a request it accepted before.

A change to a limit can take effect at once, while the API is in beta and
after it becomes generally available, and the changelog lists it. That
includes a change that tightens what your integration can do, such as:

- A lower allowance, such as fewer requests or writes a minute.
- A higher cost for a kind of request, such as a read that includes related
  records counting as more than 1.
- A lower maximum, such as fewer line items in one request, fewer related
  records in a page, a smaller page size, a smaller request body, or fewer
  refused requests a minute.
- A new limit.

Read your remaining allowance from the `RateLimit-*` headers, rather than
building today's numbers into your code.

## Stable and beta operations

Every operation has a stability tier in its `x-stability` field, either
`stable` or `beta`, and the API reference marks every beta operation with a
badge. Most operations that read data are released as `stable`, and
operations that write data are released as `beta`. A few newer reads, such
as `GET /invoices`, are released as `beta` too, so check each operation's
tier.

- **A stable operation** follows the rules on this page. Once the API is
  generally available, a breaking change to it needs `/v2`.
- **A beta operation** can change in any way, at any time, until it becomes
  stable. That includes its request, its response, its behaviour, its
  status codes and its error codes. The changelog lists each change, and
  records when the operation becomes stable.

## Handle what you don't recognise

The API grows by adding things, so write your integration to cope with
things it hasn't seen before:

- **Ignore fields you don't recognise.**
- **Accept values you don't recognise.** Every list of values in a
  response is open, which means a response can hold a value that isn't in
  the list today. In the OpenAPI document, each of these fields accepts any
  string, and its known values are in a schema whose name starts with
  `Known`, such as `KnownOrderStatus`. Requests still accept only the known
  values.
- **Don't build on an allow-list of today's values.** For example, to
  leave out cancelled orders, skip the orders whose status is `cancelled`,
  rather than keeping the orders whose status is one of today's other
  values. Otherwise an order with a new status would drop out.
- **Handle error codes you don't recognise by their status.** A `4xx`
  status means the request needs to change, and a `5xx` status means
  something went wrong on Omono's side.
- **Act only on events whose `op` is `deleted`.** If Omono adds a new kind
  of event, you'll get it only if you ask for it with the `op` filter.

## Which names and text you can rely on

Build your code on these, which follow the rules on this page:

- error `code` values
- field names and query parameter names, including the field paths in
  `errors[].field`
- the values in lists of values, such as `on_order`
- header names, and the `type` URI of an error
- the `operationId` of each stable operation, and the names of the schemas
  and tags that stable operations use, which become the method and type
  names of a client you generate from the OpenAPI document

A beta operation's `operationId`, and the name of a schema or a tag that
only beta operations use, can change, like the rest of a beta operation.
When that happens, a client you generate again gets new method or type
names for it.

These are written for people, and they can change at any time: the `title`
and `detail` of an error, each `errors[].message`, and the descriptions in
the API reference.

## Opaque values

IDs, cursors and ETags are opaque. Use each one only as Omono gives it to
you: store an ID as it is, send a `nextCursor` back as `cursor`, and send an
`ETag` back in `If-Match`. Don't read them, compare them to put them in
order, or build your own, because Omono can change how they're made at any
time, and that isn't a breaking change.

A cursor doesn't expire, but it's meant for paging straight through a list,
not for storing. After an update to Omono, a cursor you saved earlier can
fail with a `422` error. To carry on a sync later, save the highest
`updated` time you've read, or the `nextSince` from the events list, as
[Keeping in sync](/docs/syncing) explains.

## Deprecating a field or an endpoint

Omono can deprecate a field or an endpoint within version 1. The changelog
has an entry for it, and the OpenAPI document marks it `deprecated: true`.
On a stable operation, once the API is generally available, removing a
deprecated field or endpoint still needs `/v2`.

While the API is in beta, and on a beta operation at any time, Omono can
remove a field or an endpoint without deprecating it first. The removal
takes effect when the changelog lists it.

A deprecated endpoint also sends these headers. When `/v2` opens, every
`/v1` endpoint sends them.

- `Deprecation`, as defined in RFC 9745. Its value is the time the endpoint
  was deprecated, as a Unix timestamp after an `@`, for example
  `Deprecation: @1788220800`.
- `Link`, with `rel="deprecation"`, which points to the changelog entry.
- `Sunset`, as defined in RFC 8594, which gives the date the endpoint will
  be removed, once that date is set.

A deprecated field doesn't add these headers to the operations that return
it. Watch the changelog for those.

## Rate-limit headers

`RateLimit-Policy` and `RateLimit` follow the syntax of the current draft
of the IETF rate-limit headers work, draft-ietf-httpapi-ratelimit-headers-12.
The draft isn't final. The other three rate-limit headers,
`RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`, come from
an earlier draft, and they stay. They describe the limit with the fewest
requests left, as they always have, and as
[Watch your remaining allowance](/docs/limits#headers) describes. If Omono
changes these headers, for example to follow a later draft, the changelog
announces it.

## Error type URIs

The `type` URI in an error response is a stable identifier, not a link that
changes with the environment. It's always
`https://api.omono.co/docs/errors/<code>`, on every environment.
