# Quotes

> List, create, price, win, lose and convert quotes into loads with the Techvia TMS public API (scope loads.rates).

Source: https://techvia.software/docs/tms/guides/quotes/

A quote is money (the rate you offer a customer, and the load it becomes), so **every** quote call needs `loads.rates`; a key
without it gets `403` naming the scope and uses no quota.

| Call | Does |
|---|---|
| `GET /api/public/v1/quotes` | List, newest first. Filters `status` (`Draft`, `Sent`, `Won`, `Lost`, `Expired`, exact case), `customerId`, `search` (quote number, customer, lane city), `page`, `pageSize` (1 to 50) |
| `GET /api/public/v1/quotes/{id}` | One quote with its `rowVersion` |
| `POST /api/public/v1/quotes` | Create a quote (a `Draft`). Takes an `Idempotency-Key` ([Idempotency](/docs/tms/concepts/idempotency/)) |
| `PATCH /api/public/v1/quotes/{id}/status` | Set `Draft`, `Sent`, `Won` or `Lost` |
| `POST /api/public/v1/quotes/{id}/convert` | Turn a `Won` quote into a load |

**Create** body: `customerId`, `originCity`, `originState`, `destCity`, `destState`, `quotedRate` are required. Optional:
`dispatcherId` (left out: the workspace's default dispatcher), `originFacilityId` and `destFacilityId` (your facilities, from
`GET /api/public/v1/facilities`), `equipment` (`DryVan`, `Flatbed`, `Reefer`, `Tanker`, `StepDeck`, `Other`, exact case),
`commodity`, `weightLbs`, `miles`, `pickupDate`, `deliveryDate`, `validUntil` (dates as `YYYY-MM-DD`, 2000 to 2100;
`validUntil` from today on, left out = your workspace's default validity), `notes`. `quotedRate` is USD, 0 to 99,999,999.99, at most
2 decimals. The names (customer, dispatcher, facilities) are taken from your records, never from the request; coordinates,
status, the suggested rate and the margin cannot be sent (they are ignored). A blacklisted or inactive customer, an inactive
dispatcher and an inactive facility are refused with `422` (a person uses them in the TMS app). The answer is `201` with the quote
(its `rowVersion` included); margin floor and the buy-rate basis behind it are never shown.

**Status**: send `status` and the `rowVersion` from your last read (`409` "changed since you read it" when it is no longer current).
`Lost` needs `lostReason`, one of your workspace's lost reasons (for example `Price`, `Capacity`, `Timing`, `NoResponse`), and
may have `lostNotes`; `lostReason` and `lostNotes` with any other status are a `422`. `Expired` is set by the system and a key
cannot set it. A quote already converted to a load keeps its status (`422`). Sending the status it already has changes nothing.

**Convert** runs the app's own idempotent conversion: converting twice is one load. The first call answers `201`
`{ "outcome": "Created", "load": { ... } }`, every later one `200` with `"outcome": "AlreadyConverted"` and the same load.
The load is `Open`, starts as a `Spot` load at the quoted rate and is shown as `GET /api/public/v1/loads/{id}` shows it, but
never with `rate`, `finalRate` or `otherCharges`. The public rules of [Loads](/docs/tms/guides/loads/) apply: the quote must be `Won` and have a pickup or
delivery date (`422` otherwise); a blacklisted or inactive customer or an inactive facility is refused; and both ends of the
lane must be facilities of yours (`originFacilityId` and `destFacilityId` on the quote, or a facility named exactly
"City, ST"). A lane of only a city and state is not looked up or created from a key (no address lookup is taken from your allowance): `422`
on `originCity` / `destCity`, and a person converts it in the TMS app. A quote converted before keeps answering with its load.
