# Quotes API

> Quotes, versions and lines; send, accept, reject. Every route, its parameters and fields.

Quotes, versions and lines; send, accept, reject. 13 routes; send a bearer token with each (see [Authentication](/api/authentication.md)).

| Route | What it does |
| --- | --- |
| `GET /v1/quotes` | List quotes |
| `POST /v1/quotes` | Create a quote on a deal |
| `GET /v1/quotes/{id}` | Get a quote |
| `PATCH /v1/quotes/{id}` | Update a quote |
| `DELETE /v1/quotes/{id}` | Delete a quote (soft delete) |
| `POST /v1/quotes/{id}/restore` | Restore a deleted quote |
| `GET /v1/quote-versions/{id}` | Get a quote version with its lines |
| `POST /v1/quotes/{id}/versions` | Make a new version of a sent quote |
| `PUT /v1/quote-versions/{id}/lines` | Replace the lines of a draft version |
| `POST /v1/quotes/{id}/send` | Send a quote: freeze it and store its PDF |
| `POST /v1/quotes/{id}/accept` | Accept a quote: the deal moves to won |
| `POST /v1/quotes/{id}/reject` | Reject a quote |
| `GET /v1/quote-versions/{id}/pdf` | The PDF of a quote version |

## List quotes

`GET https://staging-api.naruskacrm.com/v1/quotes`

Quotes you can see (they follow their deal), newest first. `q` matches the name or the number (Q-1042 or 1042). Each row has the latest version's three totals: subtotal_amount (excluding VAT), vat_amount and total_amount (including VAT).

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `limit` | query | integer |  | 1–200, default `50` |
| `cursor` | query | string |  | next_cursor of the previous page. 1–400 characters |
| `opportunity_id` | query | string (uuid) |  |  |
| `account_id` | query | string (uuid) |  |  |
| `status` | query | string |  | Status api_key or id. At most 63 characters |
| `category` | query | `draft`, `sent`, `accepted`, `rejected`, `expired` |  |  |
| `active` | query | `true`, `false` |  |  |
| `q` | query | string |  | Name or quote number (Q-1042 or 1042). 1–200 characters |
| `sort` | query | `quote_number`, `-quote_number`, `name`, `-name`, `opportunity_name`, `-opportunity_name`, `account_name`, `-account_name`, `status_order`, `-status_order`, `subtotal_amount`, `-subtotal_amount`, `total_amount`, `-total_amount`, `valid_until`, `-valid_until`, `sent_at`, `-sent_at`, `created_at`, `-created_at`, `updated_at`, `-updated_at` |  | Sort by quote_number, name, opportunity_name, account_name, status_order, subtotal_amount, total_amount, valid_until, sent_at, created_at, updated_at; prefix "-" for descending. |
| `updated_since` | query | string (date-time) |  |  |
| `include_deleted` | query | `true`, `false` |  |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [Quote](/api/reference/objects.md#quote) | yes |  |
| `next_cursor` | string or null | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Create a quote on a deal

`POST https://staging-api.naruskacrm.com/v1/quotes`

Starts as a draft with version 1. The currency is the deal's (B5). Lines from a product copy its name, description, unit, VAT and the price valid on the quote date; given values win. A new quote is active when the deal has none; the active quote's total excluding VAT becomes the deal amount.

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `opportunity_id` | string (uuid) | yes |  |
| `name` | string |  | 1–200 characters |
| `contact_id` | string (uuid) or null |  |  |
| `is_active` | boolean |  |  |
| `custom` | object |  |  |
| `source_system` | string or null |  | 1–100 characters |
| `source_id` | string or null |  | 1–500 characters |
| `quote_date` | string (date) |  |  |
| `valid_until` | string (date) or null |  |  |
| `language` | `en`, `fi` |  |  |
| `intro_text` | string or null |  | at most 10000 characters |
| `terms_text` | string or null |  | at most 10000 characters |
| `lines` | array of object |  | at most 200 items |
| `lines[].product_id` | string (uuid) or null |  |  |
| `lines[].name` | string |  | 1–200 characters |
| `lines[].description` | string or null |  | at most 2000 characters |
| `lines[].quantity` | number | yes |  |
| `lines[].unit` | string or null |  | at most 50 characters |
| `lines[].unit_price` | number |  | 0–1000000000000000 |
| `lines[].discount_percent` | number |  | 0–100 |
| `lines[].vat_rate` | number |  | 0–100 |

### Response 201

Returns: [Quote](/api/reference/objects.md#quote).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Get a quote

`GET https://staging-api.naruskacrm.com/v1/quotes/{id}`

With the latest version (lines, three totals, VAT per rate) and the list of versions.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

Returns: [Quote](/api/reference/objects.md#quote).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Update a quote

`PATCH https://staging-api.naruskacrm.com/v1/quotes/{id}`

Quote fields (name, recipient, active, status, custom) and the latest version's dates, language and texts (refused once sent: make a new version). `status` takes an api_key: sending happens only through POST /send, and a sent quote cannot go back to draft.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string |  | 1–200 characters |
| `contact_id` | string (uuid) or null |  |  |
| `is_active` | boolean |  |  |
| `status` | string |  | at most 63 characters |
| `custom` | object |  |  |
| `source_system` | string or null |  | 1–100 characters |
| `source_id` | string or null |  | 1–500 characters |
| `quote_date` | string (date) |  |  |
| `valid_until` | string (date) or null |  |  |
| `language` | `en`, `fi` |  |  |
| `intro_text` | string or null |  | at most 10000 characters |
| `terms_text` | string or null |  | at most 10000 characters |

### Response 200

Returns: [Quote](/api/reference/objects.md#quote).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Delete a quote (soft delete)

`DELETE https://staging-api.naruskacrm.com/v1/quotes/{id}`

Anyone who can edit the deal may delete it (Undo works for 7 days); admins can restore it for 30 days. The deal keeps its last amount.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 204

Done.
No body.

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Restore a deleted quote

`POST https://staging-api.naruskacrm.com/v1/quotes/{id}/restore`

Admins only. Its versions and lines come back with it.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

Returns: [Quote](/api/reference/objects.md#quote).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Get a quote version with its lines

`GET https://staging-api.naruskacrm.com/v1/quote-versions/{id}`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

Returns: [QuoteVersion](/api/reference/objects.md#quoteversion).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Make a new version of a sent quote

`POST https://staging-api.naruskacrm.com/v1/quotes/{id}/versions`

Copies the latest version and its lines, unfrozen; the status goes back to draft. Refused while the latest version is still a draft, and on an accepted quote (reject it or undo the acceptance first).

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `reason` | string |  | at most 2000 characters |

### Response 201

Returns: [Quote](/api/reference/objects.md#quote).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Replace the lines of a draft version

`PUT https://staging-api.naruskacrm.com/v1/quote-versions/{id}/lines`

The lines in this order replace all current ones, in one call; the totals and the deal amount follow. Refused on a sent version.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `lines` | array of object | yes | at most 200 items |
| `lines[].product_id` | string (uuid) or null |  |  |
| `lines[].name` | string |  | 1–200 characters |
| `lines[].description` | string or null |  | at most 2000 characters |
| `lines[].quantity` | number | yes |  |
| `lines[].unit` | string or null |  | at most 50 characters |
| `lines[].unit_price` | number |  | 0–1000000000000000 |
| `lines[].discount_percent` | number |  | 0–100 |
| `lines[].vat_rate` | number |  | 0–100 |

### Response 200

Returns: [QuoteVersion](/api/reference/objects.md#quoteversion).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Send a quote: freeze it and store its PDF

`POST https://staging-api.naruskacrm.com/v1/quotes/{id}/send`

Freezes the latest version, renders its PDF in the version's language, stores it as a document linked to the quote and sets the sent status, in one operation (Undo reverses it all). Nothing is emailed: download the PDF or get a signed link from the document. Counts one quotes.pdf_renders; the PDF counts in storage.bytes.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `reason` | string |  | at most 2000 characters |

### Response 200

Returns: [Quote](/api/reference/objects.md#quote).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Accept a quote: the deal moves to won

`POST https://staging-api.naruskacrm.com/v1/quotes/{id}/accept`

Only a sent quote. Records the accepted version, makes the quote the active one and moves the deal to the first won stage of its pipeline (unless it is already won), in one operation: one Undo moves the deal back. The reply includes the deal's stage.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `reason` | string |  | at most 2000 characters |

### Response 200

Returns: [Quote](/api/reference/objects.md#quote).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Reject a quote

`POST https://staging-api.naruskacrm.com/v1/quotes/{id}/reject`

Changes nothing else; the deal stays where it is.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `reason` | string |  | at most 2000 characters |

### Response 200

Returns: [Quote](/api/reference/objects.md#quote).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## The PDF of a quote version

`GET https://staging-api.naruskacrm.com/v1/quote-versions/{id}/pdf`

A sent version: its stored PDF. A draft (or a sent version whose PDF was removed): rendered now as a preview, not stored, and counted in quotes.pdf_renders.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

The PDF.
Returns `application/pdf` bytes.

Errors are problem details with a stable `code`: see [Errors](/errors.md).

