# Create Freight Order — Deftship

> Initializes a new parcel order within Deftship. See the documentation

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

## Description

Initializes a new parcel order within Deftship. [See the documentation](https://developer.deftship.com/freight/create-order)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `pickupDate` | `string` | Yes | Proposed pickup date, in Y-m-d |
| `fromOpeningTime` | `string` | Yes | Opening time of pickup address, in H:i |
| `fromClosingTime` | `string` | Yes | Closing time of pickup address, in H:i |
| `fromName` | `string` | Yes | The name in the sender address |
| `fromStreet` | `string` | Yes | The street address of the sender |
| `fromCity` | `string` | Yes | The city address of the sender |
| `fromState` | `string` | Yes | The state code of the sender |
| `fromZip` | `string` | Yes | The zip code of the sender |
| `fromCountry` | `string` | Yes | The country code of the sender |
| `fromTelephone` | `string` | Yes | The telephone number of the sender. (must be a number 10-15 digits) |
| `toOpeningTime` | `string` | Yes | Opening time of delivery address, in H:i |
| `toClosingTime` | `string` | Yes | Closing time of delivery address, in H:i |
| `toName` | `string` | Yes | The name in the receiver address |
| `toStreet` | `string` | Yes | The street address of the receiver |
| `toCity` | `string` | Yes | The city address of the receiver |
| `toState` | `string` | Yes | The state code of the receiver |
| `toZip` | `string` | Yes | The zip code of the receiver |
| `toCountry` | `string` | Yes | The country code of the receiver |
| `toTelephone` | `string` | Yes | The telephone number of the sender. (must be a number 10-15 digits) |
| `packageType` | `string` | Yes | The type of package |
| `itemCount` | `integer` | Yes | Pieces count |
| `length` | `string` | Yes | Length (IN) |
| `width` | `string` | Yes | Width (IN) |
| `height` | `string` | Yes | Height (IN) |
| `weight` | `string` | Yes | Weight (LBS) |
| `description` | `string` | Yes | Description of the item |
| `price` | `string` | No | Price (Commodity Value) of the item |
| `sku` | `string` | No | PO number of the shipment |
| `additionalFields` | `object` | No | An object of key/value pairs containing additional fields to add to the order |

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

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: "deftship-create-freight-order",
  arguments: {
    pickupDate: "Pickup Date",
    fromOpeningTime: "From Opening Time",
  },
})
```

**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: "deftship-create-freight-order",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    deftship: { authProvisionId: "apn_xxxxxxx" },
    pickupDate: "Pickup Date",
    fromOpeningTime: "From Opening Time",
  },
})

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": "deftship-create-freight-order",
    "configured_props": {
      "deftship": { "authProvisionId": "apn_xxxxxxx" },
      "pickupDate": "Pickup Date",
      "fromOpeningTime": "From Opening Time"
    }
  }'
```

---

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