# Turn an enquiry into a quote and follow it up

Use this recipe when enquiries arrive somewhere else first, for example
through a web form or a CRM, and you want each one in Omono as a quote,
with a task to follow it up. When the customer decides, you mark the quote
as won or lost, and close the task.

Every request in this recipe sends your API key in an
`Authorization: Bearer <key>` header, and every `POST` and `PATCH` also sends
an `Idempotency-Key`. Paths are relative to `https://<host>/api/v1`, and the
examples show the full path.

> **Note:** The quote and task write operations are in beta. Learn more
> about [beta operations](/docs/compatibility#stable-and-beta-operations).

You need the scopes `sales:read`, `sales:write`, `tasks:read`,
`tasks:write`, `companies:read` and `reference:read`. To price the lines
from the customer's price list, your key also needs `pricing:read`.

## Steps

1. **Find the customer and contact.** Match the enquiry's email address
   with `GET /api/v1/contacts?email=<address>`. The contact's `companyId`
   is the customer. If there's no match, look for the company by name, as
   [Match an incoming email to a customer](/docs/recipes/match-an-email)
   shows. If it isn't in Omono, create it first, as
   [Sync customers and contacts from a CRM](/docs/recipes/sync-customers)
   shows.

2. **Create the quote with its line items.**

   ```http
   POST /api/v1/quotes
   Idempotency-Key: enquiry-7731
   Content-Type: application/json

   {
     "companyId": "…",
     "contactId": "…",
     "addressId": "…",
     "salesPersonId": "…",
     "validityId": "…",
     "exchangeRate": 1,
     "refNo": "Web enquiry 7731",
     "enquiryReceivedDate": "2026-10-03",
     "chaseBy": "2026-10-10",
     "lineItems": [
       { "stockItemId": "…", "quantity": 20, "price": 209 }
     ]
   }
   ```

   For the `price` Omono would fill in from the customer's price list or
   the stock item's sell price, call `GET /companies/{id}/price`, as
   [Price a line](/docs/writing#pricing-a-line) explains. Take
   `validityId` from `GET /quote-validities`. Your organisation can
   require `chaseBy` and `expectedAwardDate`: `quotes.chaseByRequired`
   and `quotes.expectedAwardDateRequired` in `GET /settings` tell you
   whether it does. The quote starts as a Draft.

3. **Activate the quote** when you send it to the customer:
   `POST /api/v1/quotes/{id}/activate` with no body. Omono does the same
   when someone emails, downloads or prints a quote.

4. **Add a follow-up task** for the sales person, linked to the quote:

   ```http
   POST /api/v1/tasks
   Idempotency-Key: enquiry-7731-chase
   Content-Type: application/json

   {
     "subject": "Chase web enquiry 7731",
     "taskTypeId": "…",
     "taskPriorityId": "…",
     "taskStatusId": "…",
     "ownerId": "…",
     "isAllDay": true,
     "allDayDate": "2026-10-10",
     "linkedEntityType": "quote",
     "linkedEntityId": "…"
   }
   ```

   Take the type, priority and an open status (`isClosedStatus: false`)
   from `GET /task-types`, `GET /task-priorities` and `GET /task-statuses`.

5. **Record the customer's decision.**

   - **Won:** `POST /api/v1/quotes/{id}/mark-won`, with the customer's
     order reference in `customerOrderNo` if you have it. Omono creates a
     Draft sales order from the quote, and the quote's `salesOrderId` names
     it. Add the order's dispatches and activate it, as
     [Push orders into Omono](/docs/recipes/push-orders) shows from step 3.
   - **Lost:** `POST /api/v1/quotes/{id}/mark-lost` with the reason in
     `lostReasonId`, from `GET /lost-quote-reasons`. If the customer comes
     back, `POST /api/v1/quotes/{id}/reactivate` makes the quote Active
     again.

   Both close the quote's automatic follow-up tasks in Omono.

6. **Complete your task:** `POST /api/v1/tasks/{id}/complete`. Send
   `taskStatusId` to choose the closed status, or leave it out to use your
   first one.

## Log a call against the quote

When someone talks to the customer about the quote, record it as a note,
so that staff see it in the quote's notes in Omono:
`POST /api/v1/quotes/{id}/notes` with the text in `text`, such as
`{ "text": "Called Priya: she expects the order next week." }`. Staff see
your key's name as the note's author. A note can have up to 2,000
characters and 50 lines. It can't be changed or deleted through the API,
and it doesn't change the quote's `updated` time. Read the
quote's history, newest first, with `GET /api/v1/quotes/{id}/notes`. Learn
more about [adding notes](/docs/writing#notes).

## Errors to handle

| Status   | Code                                                                                                           | What to do                                                                                                                                                     |
| -------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 409      | [`quote-not-active`](/docs/errors/quote-not-active)                                                            | You marked a Draft quote as won or lost. Activate it first.                                                                                                    |
| 409      | [`quote-locked`](/docs/errors/quote-locked)                                                                    | The quote is already won or lost, maybe by your staff in Omono. Read it again to see which.                                                                    |
| 422      | [`missing-required-field`](/docs/errors/missing-required-field)                                                | A field your organisation requires is missing, and `errors[].field` names it, for example `chaseBy` on the quote or `customerOrderNo` when you mark it as won. |
| 422      | [`validation-failed`](/docs/errors/validation-failed), [`invalid-reference`](/docs/errors/invalid-reference)   | A value is wrong, and `errors[].field` names it. For example, a `taskStatusId` on `/complete` must be a closed status.                                         |
| 412      | [`precondition-failed`](/docs/errors/precondition-failed)                                                      | The record changed since you read it. Read it again and retry with the new `ETag`.                                                                             |
| 429, 503 | [`rate-limited`](/docs/errors/rate-limited), [`temporarily-unavailable`](/docs/errors/temporarily-unavailable) | Retry the same request, with the same `Idempotency-Key`, after the number of seconds in `Retry-After`.                                                         |
