# Conventions

This page explains the conventions that apply across the whole Omono API,
so that you can read any record correctly. It covers how IDs, timestamps
and dates look, how empty values are shown, how text length is counted, how
money and exchange rates work, and how a document's status changes.

## IDs, timestamps and empty values

Here is part of a sales order, to show the conventions below:

```json
{
  "id": "aK3nMh2PqXwYbTzWc",
  "orderNo": "1042",
  "companyId": "b2FpLmNvbXBhbnkQQ",
  "customerOrderNo": null,
  "created": "2026-09-18T10:15:30.123Z",
  "updated": "2026-09-18T10:15:30.123Z"
}
```

- **IDs.** Every record has an `id`, a string that identifies it. A field
  that points to another record ends in `Id`, such as `companyId`. Treat IDs
  as opaque strings: don't parse them, and don't rely on their length or
  the characters they use. An ID that you send in a request can be at most
  64 characters, which is longer than any ID that Omono creates.
- **Timestamps.** Most records have a `created` time and an `updated` time,
  which say when they were created and when they last changed. They're in
  UTC, with milliseconds, for example `2026-09-18T10:15:30.123Z`. Reference
  lists, events, `GET /settings` and `GET /organisation` don't have them.
- **Empty values.** Every field is always present in a record. A value that
  isn't set is `null`, and a field is never left out. A list field is never
  `null`: an empty list is `[]`. Related records that you ask for with
  `include` are different: they aren't there at all when you don't ask for
  them, as [Include related records](/docs/reading#include) explains.
- **Document numbers.** Quote, sales order, purchase order, credit note and
  invoice numbers (`quoteNo`, `orderNo`, `purchaseOrderNo`, `creditNoteNo`
  and `invoiceNo`) are strings, not numbers. Omono shows a prefix in front
  of some of them, but the API leaves it out: sales order SO-1042 has the
  `orderNo` `"1042"`. The prefixes are `SQ-` for quotes, `SO-` for sales
  orders, `PO-` for purchase orders, `CN-` for credit notes and `INV-` for
  invoices, and they're the same in every organisation.

## Field names

Fields that point to sales orders, purchase orders, stock items and line
items use the resource names from the API reference: `salesOrderId`,
`purchaseOrderId`, `stockItemId`, `salesOrderLineItemId` and
`purchaseOrderLineItemId`. Some add a word in front that says how the
records are related, as in `linkedSalesOrderId`.

Fields that point to your users are named after the user's role instead,
such as `salesPersonId` or `buyerId`. `GET /users` lists your users.

The end of a name tells you what kind of value a field holds:

- A name ending in `Id` holds the ID of another record, such as
  `companyId`.
- A name ending in `At` holds an exact moment in UTC, such as a task's
  `dueAt` or a stock item's `lastCostUpdatedAt`. So do `created` and
  `updated`.
- A name ending in `Date` holds a calendar day, such as a dispatch's
  `invoiceDate`, as [Dates and time zones](/docs/conventions#dates) explains.

EORI numbers, the registration numbers that customs use, come in two
fields. `eoriNumberId` on a quote, sales order or purchase order is the ID
of one of your own organisation's EORI numbers, from
`GET /eori-numbers`. `eoriNumber` on a company or an address is the
customer's own EORI number, as free text.

The related records that `include` adds to a record always belong to it,
and each one appears under its own plural name, such as `lineItems` or
`contacts`. If Omono ever lets you expand a reference into the record it
points to, the record will appear in a new field beside the ID, and the
field that ends in `Id` will still hold the ID.

## Dates and time zones

Business dates, such as a dispatch date, an invoice date, an invoice's due
date or a quote's dates, are calendar days in the form `YYYY-MM-DD`, for
example `2026-09-18`. Their names end in `Date`. Omono keeps them exactly as
they were entered and never converts them between time zones. This is
different from `created`, `updated` and the fields whose names end in
`At`, such as a task's `dueAt`, which are exact moments in UTC.

When the API chooses "today" for you, for example as the default invoice date
when a dispatch ships, it uses your organisation's time zone. You can read
that time zone from the `timeZone` field of your organisation, in the
[Organisation](/docs#tag/organisation) section of the API reference.

## Text

Descriptions are plain text in the API, with one line for each paragraph.
Staff can add formatting to some descriptions in Omono, but the API doesn't
include it. If you send the same text back, the formatting stays. If you
send different text, it replaces the formatted description, and the new
description has no formatting.

Length limits count UTF-16 code units. Most characters count as one, but
most emoji count as two. For example, a 60-character name that contains
two emoji counts as 62. So text with emoji in it can be refused a little
below its stated limit. In a JSON body, text that's too long fails with a
`422` error and the code `validation-failed`, and `errors[].field` names
the field.

Names and descriptions can't contain the invisible characters that change
the direction text is shown in: U+200E and U+200F, the characters from
U+202A to U+202E and from U+2066 to U+2069, and U+FEFF. They can be used to
make one name look like another. The rule covers the names of companies,
contacts, addresses, stock items (their `title`) and tasks (their
`subject`), the descriptions of line items and stock items, the text of a
note you add, and a document's name when you upload or rename it. Zero-width spaces and joiners
(U+200B to U+200D) are allowed, because some names already stored in Omono
contain them. A value that breaks the rule fails with a `422` error and the
code `validation-failed`.

Omono removes spaces from the start and end of some values when it saves
them, such as a stock item's part number and a task's subject. The
`partNo` and `customerOrderNo` filters also ignore spaces at the start and
end of the value you send.

## Money and exchange rates

Every quote, sales order, credit note and purchase order has an
`exchangeRate`. It's the number of units of the document's currency that
equal one unit of your organisation's base currency.

For example, if your base currency is GBP and a sales order is in USD at
£1 = $1.25, the order's `exchangeRate` is `1.25`. To convert an amount on
the order into your base currency, divide it by the exchange rate:
$500 divided by 1.25 is £400.

- When you send an exchange rate, it must be greater than 0 and no more
  than 1,000,000, with at most 5 decimal places.
- A document in your base currency always has an exchange rate of 1. When
  you create or update a document in your base currency, Omono stores 1
  whatever rate you send.
- A `PATCH` that leaves out `exchangeRate`, or sends back the value you
  read, leaves the rate exactly as it is.
- Your organisation's current rates are in the
  [Tax and currency](/docs#tag/tax-and-currency) section of the API
  reference, under currency rates (`GET /currency-rates`).

Amounts, quantities and rates are JSON numbers. Parse them into a decimal
type, such as `Decimal` in Python or `BigDecimal` in Java, rather than a
binary floating-point number, so that your sums and comparisons are exact.
Don't assume a fixed number of decimal places, either: a number can have
fewer places than its field allows, and the number it has can change, for
example when your organisation changes its Unit Pricing setting.

| Kind of number                                                         | Decimal places                                                                                                                                                                           |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Quantities, including stock levels                                     | Up to 4.                                                                                                                                                                                 |
| Totals and tax, such as `totalValue`, `totalTax` and `totalWithTax`    | Up to 2, in every currency.                                                                                                                                                              |
| Prices and costs, such as `price`, `unitPrice`, `cost` and `sellPrice` | No fixed number. A price you send is saved with at most your Unit Pricing precision, which is 2 or 4. A price saved earlier, for example before a change to that setting, can have more. |
| Exchange rates                                                         | Up to 5 when you send one. A rate you read can have up to 15.                                                                                                                            |

Quantities, prices and costs that you send can be at most 1,000,000,000.
Omono rounds a price or cost you send to your organisation's Unit Pricing
precision. Sales prices and purchase prices each have their own setting,
and you can read both from `unitPricing` in [your settings](/docs#tag/organisation/GET/settings).
For example, with 2 decimal places, a price you send as `19.1234` is saved
as `19.12`. Halves round up, so `19.125` is saved as `19.13`. A line item
price that you send back exactly as you read it isn't a change, so Omono
keeps the saved value, even when it has more decimal places.

Omono works out a document's totals from its line items in this way:

1. Each line item's total is its quantity multiplied by its price, rounded
   to 2 decimal places, with halves rounded up. On a quote or sales order,
   the price is the line item's `unitPrice`, which is the price after any
   discount. On a credit note or purchase order, it's the line item's
   `price`.
2. The document's `totalValue` is the sum of those rounded line totals.
3. Each line item's tax is its rounded total multiplied by its tax rate,
   also rounded to 2 decimal places, and `totalTax` is the sum of those.
   A line item for a tax-exempt stock item has no tax.
4. A dispatch's `totalWithTax` is its `totalValue` plus its `totalTax`.

Totals are rounded to 2 decimal places in every currency, including
currencies that normally use none or three. To match Omono's totals exactly,
round each line item before you add them up.

## Document statuses

Quotes, sales orders, purchase orders and credit notes each have a
`status`, which says where the document is in its life. A status is a
lower-case word from a list, such as `draft` or `on_order`. Other fields
that take a value from a list work the same way, for example a stock item's
`kind` or a workflow status's `type`, and the words are the same in
every organisation. The [Enums](/docs/enums) page lists the values known
today and explains what each one means. The one exception is how a task
repeats: its `frequency` and `byDay` use the standard iCalendar codes, such
as `WEEKLY` and `MO`.

Omono can add a value to any of these lists, so a record you read can hold
a value you haven't seen before. Make sure your code copes with one, and
don't build logic on a list of today's values. For example, to leave out
cancelled orders, skip the orders whose status is `cancelled`, rather than
keeping only the orders whose status is one of the others below.

These are the statuses today:

| Document                       | Statuses                                                                     |
| ------------------------------ | ---------------------------------------------------------------------------- |
| Quote                          | `draft`, `active`, `won`, `lost`                                             |
| Sales order and purchase order | `draft`, `on_order`, `complete`, `cancelled`, `on_hold`, `on_order_call_off` |
| Credit note                    | `draft`, `complete`                                                          |

Every new document starts with the status `draft`. The `status` filter on
each list takes the same words. For example, on the list of sales orders,
`status=draft,on_order` returns the orders that are Draft or On Order.

You can't change a status by writing the `status` field. Instead, you use
the record's actions, so that every check Omono makes on the change also
runs for your request:

| Record         | Actions                                                                                   |
| -------------- | ----------------------------------------------------------------------------------------- |
| Quote          | `/activate`, `/mark-won`, `/mark-lost`                                                    |
| Sales order    | `/activate`, and `/transitions`, which moves the order's dispatches through your workflow |
| Purchase order | `/issue`, `/cancel`                                                                       |
| Credit note    | `/complete`                                                                               |
| Task           | `/complete`, which closes the task, or the current occurrence of a repeating task         |

The one field that moves a status is `callOff` on sales orders and purchase
orders. A call-off order is a blanket order that's delivered in several
parts over time. On an order whose status is `on_order`, setting `callOff`
moves it to `on_order_call_off`, and clearing it moves it back. On any other
status, the status doesn't change, but Omono uses `callOff` later to choose
between those two. So when you activate a draft sales order, or issue a
draft purchase order, that has `callOff` set, it goes straight to
`on_order_call_off` instead of `on_order`. The same happens when an order
comes off hold, and when a complete purchase order reopens.

A task's status works a little differently. It's one of your
organisation's own task statuses, in `taskStatusId`, rather than a word
from a list. A `PATCH` can move a task to another open status, but only
the task's `/complete` action closes it.
[Move a record through its lifecycle](/docs/writing#lifecycle-actions)
explains each action.
