> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khaime.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Quote

> Update a draft quote before sending.

# Update Quote

Updates an existing quote. Only quotes in `draft` status can be updated. Once a quote is sent, use [Revise Quote](/api-reference/b2b/revise-quote) to create a new version.

## Path Parameters

<ParamField path="id" type="integer" required>
  The quote ID.
</ParamField>

## Request Body

All fields are optional. Only include the fields you want to update.

<ParamField body="line_items" type="array">
  Updated line items. Replaces existing line items entirely.
</ParamField>

<ParamField body="discount_amount" type="integer">
  Total discount amount in cents.
</ParamField>

<ParamField body="discount_reason" type="string">
  Reason for the discount.
</ParamField>

<ParamField body="shipping_amount" type="integer">
  Shipping cost in cents.
</ParamField>

<ParamField body="tax_amount" type="integer">
  Tax amount in cents.
</ParamField>

<ParamField body="payment_terms" type="string">
  Payment terms: `upfront`, `NET15`, `NET30`, `NET60`, `50_upfront`.
</ParamField>

<ParamField body="shipping_terms" type="string">
  Shipping terms.
</ParamField>

<ParamField body="valid_until" type="string">
  Quote expiration date in ISO 8601 format.
</ParamField>

<ParamField body="supplier_notes" type="string">
  Notes from the merchant.
</ParamField>

## Response

<ResponseField name="status" type="string">
  `success` on successful update.
</ResponseField>

<ResponseField name="data" type="object">
  The updated quote object.
</ResponseField>

## Error Codes

| Status | Error                            | Fix                                                                 |
| ------ | -------------------------------- | ------------------------------------------------------------------- |
| `400`  | Only draft quotes can be updated | Use [Revise Quote](/api-reference/b2b/revise-quote) for sent quotes |
| `401`  | Invalid API key                  | Verify your `X-API-Key` header                                      |
| `404`  | Quote not found                  | Check that the quote ID exists                                      |

<RequestExample>
  ```bash Update discount theme={null}
  curl -X PATCH https://api.khaime.com/api/v1/partner/quote/101 \
    -H "X-API-Key: pk_sandbox_your_key" \
    -H "Content-Type: application/json" \
    -d '{
      "discount_amount": 50000,
      "discount_reason": "Special promotion - 20% off"
    }'
  ```

  ```bash Update line items and terms theme={null}
  curl -X PATCH https://api.khaime.com/api/v1/partner/quote/101 \
    -H "X-API-Key: pk_sandbox_your_key" \
    -H "Content-Type: application/json" \
    -d '{
      "line_items": [
        { "product_id": 123, "product_title": "Widget Pro", "quantity": 100, "unit_price": 2300 }
      ],
      "payment_terms": "NET15",
      "valid_until": "2024-03-15T23:59:59Z"
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "status": "success",
    "message": "Quote updated successfully",
    "data": {
      "id": 101,
      "quote_number": "Q-2024-0001",
      "status": "draft",
      "discount_amount": 50000,
      "discount_reason": "Special promotion - 20% off",
      "total_amount": 465000,
      "updated_at": "2024-01-16T11:30:00Z"
    }
  }
  ```
</ResponseExample>
