# Recipes

Each recipe walks you through one common integration job, step by step. It
shows only the calls, fields and errors that the job needs. The
[API reference](/docs) has every detail, and each recipe links to it where
you need more.

In the steps, paths such as `GET /companies` are relative to
`https://<host>/api/v1`, and the examples show the full path. Every request
sends your API key in an `Authorization: Bearer <key>` header.

Every `POST` and `PATCH` should also send an `Idempotency-Key` header. Use
a new key for each new request, and send the same key again on every retry
of that request, so that a retry after a timeout doesn't do the work twice.
A `DELETE` doesn't need one. Learn more about
[retrying requests safely](/docs/writing#idempotency).

> **Note:** Most recipes use write operations, which are in beta: they can
> change in any way, at any time, until they're marked stable. Mirroring
> your data and keeping stock levels up to date only read stable
> operations. Exporting invoices, reporting sales against target, matching
> an email, checking supplier invoices and reporting margin only read too,
> but each uses at least one operation in beta. Learn more about
> [beta operations](/docs/compatibility#stable-and-beta-operations).

## Push orders into Omono

Use this recipe when orders arrive somewhere else first, for example in a
web shop, and you want them in Omono as sales orders. You look up a few IDs
once, and then create each order, add its dispatch and activate it.

[Read the recipe](/docs/recipes/push-orders)

## Mirror your data in another system

Use this recipe to keep a copy of your Omono data somewhere else, such as a
business intelligence (BI) tool, a CRM or a data warehouse. You load
everything once, and then check for changes and deleted records every few
minutes. Omono lists deleted records as events, in `GET /events`.
[Keeping in sync](/docs/syncing) explains each rule in more depth.

[Read the recipe](/docs/recipes/mirror-data)

## Ship and invoice a dispatch

Use this recipe to ship a dispatch and raise its invoice from your own
system. In Omono, a sales order ships in one or more dispatches, and each
dispatch moves through your organisation's workflow statuses. The last one
is the final status, which is the status whose type is `final`. Moving a
dispatch to it ships the dispatch and invoices it.

[Read the recipe](/docs/recipes/ship-and-invoice)

## Change a document's line items

Use this recipe to add, change or delete line items on a quote, sales
order, credit note or purchase order that already exists. The example uses
a sales order, which needs the scopes `sales:read` and `sales:write`.

[Read the recipe](/docs/recipes/change-line-items)

## Sync customers and contacts from a CRM

Use this recipe when your customers live in a CRM first. You match each
customer to an Omono company by its account number, create what's missing
and change what's different, and find contacts by email address.

[Read the recipe](/docs/recipes/sync-customers)

## Keep a web shop's stock levels up to date

Use this recipe to show how many of each product you can sell. You work
out the free quantity of normal items, assemblies and never-diminishing
items, and read only the items that changed.

[Read the recipe](/docs/recipes/stock-levels)

## Plan the dispatches for an order

Use this recipe when another system plans how an order ships, for example
in weekly parts. You add dispatches, move their dates and remove the ones
you no longer need, before your staff allocate them.

[Read the recipe](/docs/recipes/plan-dispatches)

## Raise a purchase order from another system

Use this recipe when another system decides what to buy. You create the
purchase order, add the deliveries you expect, and issue it.

[Read the recipe](/docs/recipes/raise-purchase-order)

## Attach a file to a record

Use this recipe to put a drawing, a certificate or another file on a
company, quote, order or stock item, where your staff see it.

[Read the recipe](/docs/recipes/attach-a-file)

## Turn an enquiry into a quote and follow it up

Use this recipe when enquiries arrive somewhere else first. You create the
quote and a follow-up task, then mark the quote as won or lost and
complete the task.

[Read the recipe](/docs/recipes/enquiry-to-quote)

## Export invoices to accounting or BI

Use this recipe to copy the invoices Omono raises into another system,
with the goods on each one.

[Read the recipe](/docs/recipes/export-invoices)

## Report sales against target

Use this recipe to show your sales and output against your targets in
another system, such as a wallboard, with the figures from Omono's
dashboard.

[Read the recipe](/docs/recipes/sales-against-target)

## Match an incoming email to a customer

Use this recipe when an email arrives and you want to show who sent it.
You find the customer from the sender's address, by the exact address,
then by its domain, then by the company's name, and read what they have
open in Omono.

[Read the recipe](/docs/recipes/match-an-email)

## Check supplier invoices

Use this recipe to copy the supplier invoices that your staff record in
Omono into another system, with their values in your base currency and
the state of their sync to Xero.

[Read the recipe](/docs/recipes/check-supplier-invoices)

## Report margin

Use this recipe to report the margin on what you sell, from the cost and
margin on each sales order line item and the cost and profit on each
invoice.

[Read the recipe](/docs/recipes/report-margin)
