> ## 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.

# Create Quote

> Create a quote with pricing for an RFQ.

# Create Quote

Creates a new quote with specific pricing for an existing RFQ. The quote starts in `draft` status and must be sent to the customer via the [Send Quote](/api-reference/b2b/send-quote) endpoint.

## Request Body

<ParamField body="order_id" type="integer" required>
  ID of the RFQ (order) this quote is for.
</ParamField>

<ParamField body="line_items" type="array" required>
  Quoted line items with pricing.

  <Expandable title="Line item fields">
    <ParamField body="product_id" type="integer" required>
      Product ID.
    </ParamField>

    <ParamField body="product_title" type="string" required>
      Product name/title.
    </ParamField>

    <ParamField body="quantity" type="integer" required>
      Quantity being quoted.
    </ParamField>

    <ParamField body="unit_price" type="integer" required>
      Unit price in cents (smallest currency unit).
    </ParamField>

    <ParamField body="lead_time_days" type="integer">
      Lead time in days for this item.
    </ParamField>

    <ParamField body="quantity_breaks" type="array">
      Volume discount tiers.

      <Expandable title="Quantity break fields">
        <ParamField body="min_qty" type="integer">
          Minimum quantity for this tier.
        </ParamField>

        <ParamField body="unit_price" type="integer">
          Unit price in cents at this tier.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

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

<ParamField body="discount_reason" type="string">
  Reason for the discount (e.g., "Volume discount", "Preferred customer").
</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="currency" type="string" default="USD">
  3-letter ISO currency code.
</ParamField>

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

<ParamField body="shipping_terms" type="string">
  Shipping terms (e.g., "FOB Destination", "Ex Works").
</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 to the customer.
</ParamField>

## Response

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

<ResponseField name="data" type="object">
  <Expandable title="Quote fields">
    <ResponseField name="id" type="integer">
      Quote ID.
    </ResponseField>

    <ResponseField name="quote_number" type="string">
      Human-readable reference (e.g., `Q-2024-0001`).
    </ResponseField>

    <ResponseField name="iteration" type="integer">
      Quote version number (1 for first quote, 2+ for revisions).
    </ResponseField>

    <ResponseField name="status" type="string">
      Initial status is `draft`.
    </ResponseField>

    <ResponseField name="subtotal" type="integer">
      Subtotal in cents (sum of line items).
    </ResponseField>

    <ResponseField name="total_amount" type="integer">
      Total amount in cents (after discounts, shipping, tax).
    </ResponseField>

    <ResponseField name="currency" type="string">
      Currency code.
    </ResponseField>
  </Expandable>
</ResponseField>

## Error Codes

| Status | Error            | Fix                                                       |
| ------ | ---------------- | --------------------------------------------------------- |
| `400`  | Validation error | Check required fields and data types                      |
| `401`  | Invalid API key  | Verify your `X-API-Key` header                            |
| `404`  | RFQ not found    | Check that `order_id` exists and belongs to your business |

<RequestExample>
  ```bash Basic quote theme={null}
  curl -X POST https://api.khaime.com/api/v1/partner/quote \
    -H "X-API-Key: pk_sandbox_your_key" \
    -H "Content-Type: application/json" \
    -d '{
      "order_id": 789,
      "line_items": [
        {
          "product_id": 123,
          "product_title": "Widget Pro",
          "quantity": 100,
          "unit_price": 2500
        }
      ],
      "currency": "USD",
      "valid_until": "2024-02-28T23:59:59Z"
    }'
  ```

  ```bash Full quote with discounts and terms theme={null}
  curl -X POST https://api.khaime.com/api/v1/partner/quote \
    -H "X-API-Key: pk_sandbox_your_key" \
    -H "Content-Type: application/json" \
    -d '{
      "order_id": 789,
      "line_items": [
        {
          "product_id": 123,
          "product_title": "Widget Pro",
          "quantity": 100,
          "unit_price": 2500,
          "lead_time_days": 14,
          "quantity_breaks": [
            { "min_qty": 500, "unit_price": 2200 },
            { "min_qty": 1000, "unit_price": 2000 }
          ]
        },
        {
          "product_id": 456,
          "product_title": "Gadget Plus",
          "quantity": 50,
          "unit_price": 5000
        }
      ],
      "discount_amount": 25000,
      "discount_reason": "Volume discount - 10%",
      "shipping_amount": 15000,
      "tax_amount": 20000,
      "currency": "USD",
      "payment_terms": "NET30",
      "shipping_terms": "FOB Destination",
      "valid_until": "2024-02-28T23:59:59Z",
      "supplier_notes": "Thank you for your business! Delivery within 2 weeks of PO."
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "status": "success",
    "message": "Quote created successfully",
    "data": {
      "id": 101,
      "quote_number": "Q-2024-0001",
      "iteration": 1,
      "status": "draft",
      "subtotal": 500000,
      "discount_amount": 25000,
      "shipping_amount": 15000,
      "tax_amount": 20000,
      "total_amount": 510000,
      "currency": "USD",
      "payment_terms": "NET30",
      "valid_until": "2024-02-28T23:59:59Z"
    }
  }
  ```
</ResponseExample>
