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

# Clone Order

> Creates a new order, in the `DRAFT` state, by duplicating an existing order.

`square.cloneOrder` creates a new order, in the `DRAFT` state, by duplicating an existing order.

## Example

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

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

  square.cloneOrder({
    orderId: "ZAISEM52YcpmcWAzERDOyiWS123",
    version: 3,
    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 clone.                                                                                                                                                                                                                                                                                                                                                                                                |
| `version`        | `number`         | No       | —       | An optional order version for concurrency protection. If a version is provided, it must match the latest stored version of the order to clone. If a version is not provided, the API clones the latest version.                                                                                                                                                                                                              |
| `idempotencyKey` | `string \| null` | No       | —       | A value you specify that uniquely identifies this clone request. If you are unsure whether a particular order was cloned successfully, you can reattempt the call with the same idempotency key without worrying about creating duplicate cloned orders. The originally cloned order is returned. For more information, see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency). |

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

## Output

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