# Create Order — SmartRoutes

> Creates a new order in the smartroutes. See the documentation

- Key: `smartroutes-create-order`
- Type: Action (Write)
- Version: 0.0.2
- App: SmartRoutes (`smartroutes`) — https://pipedream.com/apps/smartroutes.md
- This page (HTML): https://pipedream.com/apps/smartroutes/actions/create-order
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/smartroutes/actions/create-order/create-order.mjs

## Description

Creates a new order in the smartroutes. [See the documentation](https://api.smartroutes.io/v2/docs/api/#tag/Orders/paths/~1orders/post)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `orderNumber` | `string` | Yes | The order number |
| `customerAccount` | `string` | Yes | Account number of a customer Options are loaded from the connected account. |
| `type` | `string` | Yes | Type of the order (delivery, pickup, or shipment). |
| `deliveryContactName` | `string` | No | Name of the contact person. |
| `deliveryContactNumber` | `string` | No | Contact number of the person. |
| `deliveryContactEmail` | `string` | No | Email of the contact person. |
| `deliveryAddress` | `string` | No | Delivery address. |
| `deliveryPostcode` | `string` | No | Postcode for delivery address. |
| `deliveryLat` | `string` | No | Latitude of the delivery location. |
| `deliveryLng` | `string` | No | Longitude of the delivery location. |
| `deliveryDuration` | `integer` | No | Duration for order delivery in minutes. |
| `deliveryNotes` | `string` | No | Notes for delivery instructions. |
| `deliveryDate` | `string` | No | Date for order delivery. |
| `pickupAddress` | `string` | No | Address for order pickup. |
| `pickupPostcode` | `string` | No | Postcode for pickup address. |
| `pickupDuration` | `integer` | No | Duration for order pickup in minutes. |
| `pickupLat` | `string` | No | Latitude of the pickup location. |
| `pickupLng` | `string` | No | Longitude of the pickup location. |
| `pickupNotes` | `string` | No | Notes for pickup instructions. |
| `pickupContactName` | `string` | No | Name of the contact person for pickup. |
| `pickupContactNumber` | `string` | No | Contact number of the person for pickup. |
| `pickupContactEmail` | `string` | No | Email of the contact person for pickup. |
| `parts` | `integer` | No | Number of parts in the order. |
| `lineItems` | `string[]` | No | Array of line items in the order. Each line item object must contain product_code, product_name, and product_quantity. |
| `timeWindows` | `string[]` | No | Array of time windows for order delivery or pickup. Each time window object must contain from (Start time of the time window. Ex: "08:00") and to (End time of the time window. Ex: "12:00"). |
| `skills` | `string[]` | No | List of required skills for the order. Skills listed must exist within your Vehicle Settings. |
| `customFields` | `string[]` | No | Custom fields for the order Options are loaded from the connected account. |
| `capacities` | `string[]` | No | Capacities for the order Options are loaded from the connected account. |

## 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": "smartroutes",
      },
    },
  },
)

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: "smartroutes-create-order",
  arguments: {
    orderNumber: "Order Number",
    customerAccount: "Customer Account Number",
  },
})
```

**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: "smartroutes-create-order",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    smartroutes: { authProvisionId: "apn_xxxxxxx" },
    orderNumber: "Order Number",
    customerAccount: "Customer Account Number",
  },
})

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": "smartroutes-create-order",
    "configured_props": {
      "smartroutes": { "authProvisionId": "apn_xxxxxxx" },
      "orderNumber": "Order Number",
      "customerAccount": "Customer Account Number"
    }
  }'
```

---

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