> For the complete documentation index, see [llms.txt](https://docs.cekat.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cekat.ai/api-documentation/orders/update-an-order.md).

# Update an order

Updates an order's status, payment status, address, notes, or invoice. Send only the fields you want to change. `changed` in the response lists what changed, with old and new values.

Cancelling an order with a pending invoice expires the invoice (and its Xendit payment link). Payment status can't be set by hand for Xendit orders.

```json
{"openapi":"3.0.3","info":{"title":"Cekat Open API","version":"1.0.0"},"tags":[{"name":"Orders","description":"Create and manage orders and their invoices. Each order belongs to a contact; Cekat creates the contact if it doesn't exist yet.\n\n| Payment method | Invoice |\n| --- | --- |\n| `manual` | A PDF invoice with your bank account details. Requires `bank_account_number` of a payment bank account set up in Cekat. |\n| `xendit` | A Xendit payment link and PDF invoice. Requires Xendit to be connected. |\n| `custom` | Your own invoice, given as `custom_invoice_url`. |\n\nOrder statuses are `pending`, `processing`, `shipping`, `cancelled` and `completed`. Payment statuses are `PENDING`, `PAID`, `EXPIRED` and `SETTLED`.\n"}],"servers":[{"url":"https://api.cekat.ai","description":"Production"}],"security":[{"CekatApiKey":[]},{"BearerAuth":[]}],"components":{"securitySchemes":{"CekatApiKey":{"type":"apiKey","in":"header","name":"api_key","description":"Your business's Cekat API key, from **Settings → Developers & API** in the Cekat dashboard (https://chat.cekat.ai/developers?section=apikeys). Available on the Business and Enterprise plans."},"BearerAuth":{"type":"http","scheme":"bearer","description":"The same Cekat API key, sent as `Authorization: Bearer YOUR_API_KEY`. Accepted only by endpoints under `/api/...`."}},"schemas":{"Order":{"type":"object","description":"An order with its contact, products and invoices. Additional fields may be present.","additionalProperties":true,"properties":{"id":{"type":"string","format":"uuid"},"order_number":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"order_status":{"type":"string","enum":["pending","processing","shipping","cancelled","completed"]},"payment_method":{"type":"string","enum":["manual","xendit","custom"]},"subtotal":{"type":"number"},"discount":{"type":"number"},"shipping_fee":{"type":"number"},"vat":{"type":"number"},"grand_total":{"type":"number"},"currency":{"type":"string","nullable":true},"address":{"type":"string","nullable":true},"notes":{"type":"string","nullable":true},"contact_id":{"type":"string","format":"uuid"},"conversation_id":{"type":"string","format":"uuid","nullable":true},"contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"display_name":{"type":"string"},"phone_number":{"type":"string","nullable":true},"email":{"type":"string","nullable":true}}},"cekat_orders_products":{"type":"array","items":{"$ref":"#/components/schemas/OrderProduct"}},"invoices":{"type":"array","description":"The order's invoices, newest first.","items":{"$ref":"#/components/schemas/Invoice"}}}},"OrderProduct":{"type":"object","additionalProperties":true,"properties":{"id":{"type":"string","format":"uuid"},"product_id":{"type":"string","format":"uuid","nullable":true},"product_name":{"type":"string"},"quantity":{"type":"integer"},"price":{"type":"number"}}},"Invoice":{"type":"object","additionalProperties":true,"properties":{"id":{"type":"string"},"status":{"type":"string","enum":["PENDING","PAID","EXPIRED","SETTLED"]},"amount":{"type":"number"},"payment_link":{"type":"string","nullable":true,"description":"Xendit payment link, for `xendit` orders."},"pdf_link":{"type":"string","nullable":true,"description":"Invoice PDF, or your own invoice URL for `custom` orders."},"is_sent":{"type":"boolean","nullable":true},"expiry_date":{"type":"string","nullable":true},"paid_at":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"}}},"ApiError":{"type":"object","description":"Error body returned by the `/api/...` endpoints.","properties":{"success":{"type":"boolean"},"message":{"type":"string"},"statusCode":{"type":"integer"},"error":{"type":"object","properties":{"message":{"type":"string"}}},"correlationId":{"type":"string","description":"Request ID. Include it when contacting Cekat support."}}},"RateLimitError":{"type":"object","properties":{"message":{"type":"string"}}}},"responses":{"ApiUnauthorized":{"description":"The API key is missing or invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"ApiNotFound":{"description":"The resource was not found or does not belong to your business.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"TooManyRequests":{"description":"Rate limit exceeded. Wait and retry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimitError"}}}}}},"paths":{"/api/orders/{id}":{"put":{"tags":["Orders"],"operationId":"UpdateOrder","summary":"Update an order","description":"Updates an order's status, payment status, address, notes, or invoice. Send only the fields you want to change. `changed` in the response lists what changed, with old and new values.\n\nCancelling an order with a pending invoice expires the invoice (and its Xendit payment link). Payment status can't be set by hand for Xendit orders.\n","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"order_status":{"type":"string","enum":["pending","processing","shipping","cancelled","completed"]},"payment_status":{"type":"string","enum":["pending","paid","expired"]},"invoice_is_sent":{"type":"boolean"},"address":{"type":"string"},"notes":{"type":"string"},"custom_invoice_url":{"type":"string","format":"uri","description":"Only for `custom` orders."}}}}}},"responses":{"200":{"description":"Order updated.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"data":{"$ref":"#/components/schemas/Order"},"changed":{"type":"object","description":"Each changed field with `old_value` and `new_value`.","additionalProperties":{"type":"object","properties":{"old_value":{},"new_value":{}}}}}}}}},"400":{"description":"A value is invalid, or the change is not allowed for this payment method.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"$ref":"#/components/responses/ApiUnauthorized"},"404":{"$ref":"#/components/responses/ApiNotFound"},"429":{"$ref":"#/components/responses/TooManyRequests"}}}}}}
```
