# Create Distributor Order — Universal API

> Create a new order via the Distributors API on Universal API. Use List Distributor Products to discover valid product identifiers for the order items. See the documentation.

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

## Description

Create a new order via the Distributors API on Universal API. Use **List Distributor Products** to discover valid product identifiers for the order items. [See the documentation](https://docs.universalapi.io/reference/create-order).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `consumerId` | `string` | Yes | The consumer ID. Run List Consumers first to find valid IDs. |
| `contactEmail` | `string` | Yes | Contact email for the order. |
| `customerIdentifier` | `string` | No | Customer identifier for the order. |
| `referenceIdentifier` | `string` | No | Your reference identifier for the order. |
| `comment` | `string` | No | Free-text comment for the order. |
| `shippingAddress` | `object` | Yes | Shipping address object. Keys: companyName, address1, address2, city, postalCode, countryCode, phoneNumber. Example: {"companyName":"Acme","address1":"1 Main St","city":"Oslo","postalCode":"0150","countryCode":"NO","phoneNumber":"+4790000000"}. |
| `billingAddress` | `object` | No | Billing address object with the same keys as shippingAddress. Example: {"companyName":"Acme","address1":"1 Main St","city":"Oslo","postalCode":"0150","countryCode":"NO","phoneNumber":"+4790000000"}. |
| `orderItems` | `string` | Yes | JSON array of order items. Each item: {itemNumber, referenceIdentifier, sku, quantity, vpn, comment}. Example: [{"itemNumber":"ABC123","sku":"SKU1","quantity":2,"vpn":"VPN1"}]. |

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

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: "universal_api-create-distributor-order",
  arguments: {
    consumerId: "Consumer ID",
    contactEmail: "Contact Email",
  },
})
```

**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: "universal_api-create-distributor-order",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    universal_api: { authProvisionId: "apn_xxxxxxx" },
    consumerId: "Consumer ID",
    contactEmail: "Contact Email",
  },
})

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": "universal_api-create-distributor-order",
    "configured_props": {
      "universal_api": { "authProvisionId": "apn_xxxxxxx" },
      "consumerId": "Consumer ID",
      "contactEmail": "Contact Email"
    }
  }'
```

---

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