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

# Search Orders

> Search all orders for one or more locations.

`square.searchOrders` search all orders for one or more locations.

## Example

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

export default automation("Search Square Orders", () => {
  onDashboardRun({ title: "Search Square Orders" })

  square.searchOrders({
    locationIds: ["057P5VYJ4A5X1", "18YC4JDH91E1H"],
    query: {
      filter: {
        stateFilter: {
          states: ["COMPLETED"],
        },
        dateTimeFilter: {
          closedAt: {
            startAt: "2018-03-03T20:00:00+00:00",
            endAt: "2019-03-04T21:54:45+00:00",
          },
        },
      },
      sort: {
        sortField: "CLOSED_AT",
        sortOrder: "DESC",
      },
    },
    limit: 3,
    returnEntries: true,
  })
})
```

## Inputs

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

| Field           | Type                       | Required | Default           | Description                                                                                                                                                                                                                                                                 |
| --------------- | -------------------------- | -------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `locationIds`   | `string[]`                 | No       | —                 | The location IDs for the orders to query. All locations must belong to the same merchant. Max: 10 location IDs.                                                                                                                                                             |
| `cursor`        | `string`                   | No       | —                 | A pagination cursor returned by a previous call to this endpoint. Provide this cursor to retrieve the next set of results for your original query. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). |
| `query`         | `Square.SearchOrdersQuery` | No       | —                 | Query conditions used to filter or sort the results. Note that when retrieving additional pages using a cursor, you must use the original query.                                                                                                                            |
| `limit`         | `number`                   | No       | `500` Max: `1000` | The maximum number of results to be returned in a single page. Default: `500` Max: `1000`                                                                                                                                                                                   |
| `returnEntries` | `boolean`                  | No       | `false`           | A Boolean that controls the format of the search results. If `true`, `SearchOrders` returns OrderEntry objects. If `false`, `SearchOrders` returns complete order objects. Default: `false`.                                                                                |

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

## Output

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