# Create Order — Orderspace

> Create a new order. See the documentation

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

## Description

Create a new order. [See the documentation](https://apidocs.orderspace.com/#create-an-order)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `customerId` | `string` | Yes | The ID of a customer Options are loaded from the connected account. |
| `shippingAddressLine1` | `string` | Yes | The first line of the shipping address |
| `shippingAddressLine2` | `string` | No | The second line of the shipping address |
| `shippingCity` | `string` | Yes | The city of the shipping address |
| `shippingState` | `string` | Yes | The state of the shipping address |
| `shippingPostalCode` | `string` | Yes | The postal code of the shipping address |
| `shippingCountry` | `string` | Yes | The 2 letter country code of the shipping address |
| `billingAddressLine1` | `string` | Yes | The first line of the billing address |
| `billingAddressLine2` | `string` | No | The second line of the billing address |
| `billingCity` | `string` | Yes | The city of the billing address |
| `billingState` | `string` | Yes | The state of the billing address |
| `billingPostalCode` | `string` | Yes | The postal code of the billing address |
| `billingCountry` | `string` | Yes | The 2 letter country code of the billing address |
| `orderLines` | `string[]` | Yes | The lines of the order. See the documentation for information about line format. |
| `deliveryDate` | `string` | No | The date the order is due (YYYY-MM-DD) |
| `reference` | `string` | No | The reference for the order |
| `internalNote` | `string` | No | An internal note for the order |
| `customerPoNumber` | `string` | No | The customer's purchase order number for this order |
| `customerNote` | `string` | No | The customer's note on this 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": "orderspace",
      },
    },
  },
)

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: "orderspace-create-order",
  arguments: {
    customerId: "Customer ID",
    shippingAddressLine1: "Address Line 1",
  },
})
```

**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: "orderspace-create-order",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    orderspace: { authProvisionId: "apn_xxxxxxx" },
    customerId: "Customer ID",
    shippingAddressLine1: "Address Line 1",
  },
})

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": "orderspace-create-order",
    "configured_props": {
      "orderspace": { "authProvisionId": "apn_xxxxxxx" },
      "customerId": "Customer ID",
      "shippingAddressLine1": "Address Line 1"
    }
  }'
```

---

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