# Create Order — Dispatch

> Create a new delivery order. See the documentation

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

## Description

Create a new delivery order. [See the documentation](https://api.dispatchit.com/docs/v1)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `pickupBusinessName` | `string` | Yes | Name of the pickup business. |
| `pickupContactName` | `string` | Yes | Name of the pickup contact. |
| `pickupContactPhoneNumber` | `string` | Yes | Phone number of the pickup contact. Required format: 123-123-1234. |
| `pickupAddress1` | `string` | Yes | Pickup address line 1. |
| `pickupAddress2` | `string` | No | Pickup address line 2. |
| `pickupCity` | `string` | Yes | Pickup city. |
| `pickupStateProvinceCode` | `string` | Yes | Pickup state or province code (e.g. MN). |
| `pickupPostalCode` | `string` | Yes | Pickup postal code (e.g. 55431). |
| `pickupNotes` | `string` | No | Notes for the driver about the pickup location. |
| `dropOffBusinessName` | `string` | Yes | Name of the drop-off business. |
| `dropOffContactName` | `string` | Yes | Name of the drop-off contact. |
| `dropOffContactPhoneNumber` | `string` | Yes | Phone number of the drop-off contact. Required format: 123-123-1234. |
| `dropOffAddress1` | `string` | Yes | Drop-off address line 1. |
| `dropOffAddress2` | `string` | No | Drop-off address line 2. |
| `dropOffCity` | `string` | Yes | Drop-off city. |
| `dropOffStateProvinceCode` | `string` | Yes | Drop-off state or province code (e.g. MN). |
| `dropOffPostalCode` | `string` | Yes | Drop-off postal code (e.g. 55431). |
| `dropOffNotes` | `string` | No | Notes for the driver about the drop-off location. |
| `estimatedWeight` | `integer` | No | Estimated weight of the delivery in pounds. |
| `quantityOfPackages` | `integer` | Yes | Number of packages/items in the order. |
| `vehicleType` | `string` | No | Type or size of vehicle needed. If left blank, cargo van will be selected. |
| `serviceType` | `string` | No | Level of service. If left blank, the best option based on times will be selected. |
| `pickupDateTimeUtc` | `string` | No | Desired pickup date/time in ISO 8601 format (e.g. 2019-08-09T13:00:00.000Z). If not provided, items are assumed ready for immediate pickup. |
| `dropOffDateTimeUtc` | `string` | No | Desired drop-off date/time in ISO 8601 format (e.g. 2019-08-09T16:00:00.000Z). If not provided, assumes 5pm at the drop-off location's timezone. |
| `referenceNumber` | `string` | No | External reference or PO number. |
| `billingNotes` | `string` | No | Billing notes for this order. Not visible to the driver. |
| `trackingEmailAddresses` | `string` | No | Email addresses the tracking link will be sent to. May be comma and/or space separated (e.g. aaa@example.com, bbb@example.com). |
| `trackingPhoneNumbers` | `string` | No | Phone numbers that tracking SMS messages will be sent to. May be comma and/or space separated (e.g. 555-111-2222, 555-222-3333). |
| `needsUnloadingAssistance` | `boolean` | No | Indicates if the order requires assistance unloading. |
| `dedicatedVehicle` | `boolean` | No | Whether the order should use a dedicated vehicle. |
| `organizationId` | `integer` | No | Specify which organization the order should be placed under. Leave empty if not a multi-tier organization. Options are loaded from the connected account. |
| `addOns` | `string[]` | No | List of add-on services to include (e.g. dolly, inside_delivery). |

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

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: "dispatch-create-order",
  arguments: {
    pickupBusinessName: "Pickup Business Name",
    pickupContactName: "Pickup Contact Name",
  },
})
```

**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: "dispatch-create-order",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    dispatch: { authProvisionId: "apn_xxxxxxx" },
    pickupBusinessName: "Pickup Business Name",
    pickupContactName: "Pickup Contact Name",
  },
})

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": "dispatch-create-order",
    "configured_props": {
      "dispatch": { "authProvisionId": "apn_xxxxxxx" },
      "pickupBusinessName": "Pickup Business Name",
      "pickupContactName": "Pickup Contact Name"
    }
  }'
```

---

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