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

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Update Order

> Updates an open [order](entity:Order) by adding, replacing, or deleting fields.

`square.updateOrder` updates an open [order](entity:Order) by adding, replacing, or deleting fields.

## Example

```ts automations/square-update-order.automation.ts theme={null}
import { automation, onDashboardRun } from "automate.ax"
import { square } from "automate.ax/square"

export default automation("Update Square Order", () => {
  onDashboardRun({ title: "Update Square Order" })

  square.updateOrder({
    orderId: "order_id",
    order: {
      locationId: "location_id",
      lineItems: [
        {
          uid: "cookie_uid",
          name: "COOKIE",
          quantity: "2",
          basePriceMoney: {
            amount: BigInt("200"),
            currency: "USD",
          },
        },
      ],
      version: 1,
    },
    fieldsToClear: ["discounts"],
    idempotencyKey: "UNIQUE_STRING",
  })
})
```

## Inputs

Every input accepts a compatible signal. It requires `ORDERS_WRITE`.

| Field            | Type               | Required | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ---------------- | ------------------ | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `orderId`        | `string`           | Yes      | —       | The ID of the order to update.                                                                                                                                                                                                                                                                                                                                                                                                            |
| `order`          | `Square.Order`     | No       | —       | The [sparse order](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders#sparse-order-objects) containing only the fields to update and the version to which the update is being applied.                                                                                                                                                                                                                            |
| `fieldsToClear`  | `string[] \| null` | No       | —       | The [dot notation paths](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders#identifying-fields-to-delete) fields to clear. For example, `line_items[uid].note`. For more information, see [Deleting fields](https://developer.squareup.com/docs/orders-api/manage-orders/update-orders#deleting-fields).                                                                                                          |
| `idempotencyKey` | `string \| null`   | No       | —       | A value you specify that uniquely identifies this update request. If you are unsure whether a particular update was applied to an order successfully, you can reattempt it with the same idempotency key without worrying about creating duplicate updates to the order. The latest order version is returned. For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). |

Use the official [UpdateOrder reference](https://developer.squareup.com/reference/square/orders-api/update-order) for provider field semantics and limits.

## Output

Returns the official `Square.UpdateOrderResponse` response as a codec-safe object. Square integer money amounts remain `bigint` values.
