We are using cookies to improve your experience!

By clicking "Allow all", you agree to use of all cookies. Visit our Privacy Policy to learn more.

Update a Quote

Overview

The Update a Quote endpoint modifies an existing quote by its ID. You can update fields like dates, items, discounts, and notes. Partial updates are supported—only provide changed fields. The quote remains in its current status unless explicitly changed.

HTTP Method

PATCH

Endpoint URL

https://api.koteshen.com/api/v1/quotes/{id}

Path Parameters

Parameter Type Required Description
id Integer Yes The unique ID of the quote.

Query Parameters

None.

Request Headers

  • Authorization: Bearer <your_oauth2_token> (handled separately)
  • Content-Type: application/json
  • Accept: application/json

Request Body

A JSON object with the fields to update. Use the same schema as Create, but only include changed fields. For items, use items_attributes with id for updates or omit id for new items.

Example Request Body

{
  "quote": {
    "expires_at": "2025-10-27T10:00:00.000Z",
    "summary": "Updated estimate",
    "items_attributes": [
      {
        "id": 174,
        "quantity": 7,
        "unit_price": 340
      },
      {
        "name": "Additional consulting",
        "quantity": 5,
        "unit_price": 200
      }
    ],
    "discount_value": 15,
    "notes": "Revised terms."
  }
}

Success Response

Status Code

200 OK

Response Body

The updated quote resource.

{
  "id": 1,
  "number": "QT-001",
  "issued_at": "2025-10-12T10:00:00.000Z",
  "expires_at": "2025-10-27T10:00:00.000Z",
  "status": "draft",
  "currency": "USD",
  "customer_id": 13,
  "customer": {
    "id": 13,
    "name": "Texas Ins",
    "email": "procurement@texas.com"
  },
  "summary": "Updated estimate",
  "subtotal": "4780.00",
  "discount_type": "percent",
  "discount_value": 15,
  "discount_amount": "717.00",
  "tax_amount": "0.00",
  "total": "4063.00",
  "notes": "Revised terms.",
  "items": [
    {
      "id": 174,
      "name": "Design and development",
      "quantity": 7,
      "unit_price": "340.00",
      "total": "2380.00"
    },
    {
      "id": 175,
      "name": "Additional consulting",
      "quantity": 5,
      "unit_price": "200.00",
      "total": "1000.00"
    }
  ],
  "url": "https://api.koteshen.com/api/v1/quotes/1",
  "pdf_url": "https://api.koteshen.com/api/v1/quotes/1/pdf",
  "created_at": "2025-10-12T10:00:00.000Z",
  "updated_at": "2025-10-21T14:30:00.000Z"
}

Response Headers

  • Content-Type: application/json

Error Responses

401 Unauthorized

If the token is invalid or expired.

{
  "error": "Unauthorized",
  "message": "Invalid access token"
}

404 Not Found

If the quote ID does not exist.

{
  "error": "Not Found",
  "message": "Quote not found"
}

422 Unprocessable Entity

Validation errors (e.g., invalid item ID).

{
  "error": "Unprocessable Entity",
  "message": "Item ID 999 does not exist",
  "errors": {
    "items_attributes[0].id": ["does not exist"]
  }
}

Example Request (cURL)

curl -X PATCH "https://api.koteshen.com/api/v1/quotes/1" \
  -H "Authorization: Bearer <your_oauth2_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "quote": {
      "expires_at": "2025-10-27T10:00:00.000Z",
      "items_attributes": [
        {
          "id": 174,
          "quantity": 7
        }
      ]
    }
  }'

Example Response (cURL)

See Success Response above.

Usage Notes

  • Updating after sent status may require re-sending the quote.
  • Deletions within items: Send an items_attributes entry with _destroy: true and the item id.
  • Recalculates totals automatically on update.