# Search Orders — OptimoRoute

> Search for orders in Optimoroute. See the documentation

- Key: `optimoroute-search-orders`
- Type: Action (Read-only)
- Version: 0.0.2
- App: OptimoRoute (`optimoroute`) — https://pipedream.com/apps/optimoroute.md
- This page (HTML): https://pipedream.com/apps/optimoroute/actions/search-orders
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/optimoroute/actions/search-orders/search-orders.mjs

## Description

Search for orders in Optimoroute. [See the documentation](https://optimoroute.com/api/#search-orders)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `from` | `string` | Yes | From date. YYYY-MM-DD format, for example 2013-12-20. The range can span at most 35 days, i.e. 5 weeks |
| `to` | `string` | Yes | To date. YYYY-MM-DD format, for example 2013-12-20. The range can span at most 35 days, i.e. 5 weeks |
| `includeOrderData` | `boolean` | No | Include order data in the response |
| `includeScheduleInformation` | `boolean` | No | Include schedule information in the response |
| `afterTag` | `string` | No | Specify the after_tag to retrieve the next page of results from a previous call to this endpoint |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "optimoroute",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "optimoroute-search-orders",
  arguments: {
    from: "From",
    to: "To",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "optimoroute-search-orders",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    optimoroute: { authProvisionId: "apn_xxxxxxx" },
    from: "From",
    to: "To",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "optimoroute-search-orders",
    "configured_props": {
      "optimoroute": { "authProvisionId": "apn_xxxxxxx" },
      "from": "From",
      "to": "To"
    }
  }'
```

---

- App: https://pipedream.com/apps/optimoroute.md · All apps: https://pipedream.com/apps
