# Create Purchase Order — Allocadence

> Generates a new purchase order. See the documentation

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

## Description

Generates a new purchase order. [See the documentation](https://docs.allocadence.com/)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `supplierId` | `integer` | No | Id of the supplier that is being ordered from. |
| `supplierName` | `string` | No | Name of the supplier that is being ordered from. Ignored if supplierId is provided. |
| `warehouseId` | `integer` | No | Id of the warehouse the items will be delivered to. If no warehouse parameters are given, then the user's current warehouse will be used. |
| `warehouseName` | `string` | No | Name of the warehouse the items will be delivered to. Ignored if warehouseId is provided. |
| `clientId` | `integer` | No | Id of the client that the purchase order is for. Defaults to the user's client id. |
| `clientName` | `string` | No | Name of the client that the purchase order is for. Ignored if clientId is provided and is nonzero. |
| `orderNumber` | `string` | No | Order number for the purchase order. If blank, one will automatically be generated. |
| `draft` | `boolean` | No | True if the purchase order should be created as a draft to allow future editing. |
| `requiredByDate` | `string` | No | The date of the purchase. Format: YYYY-MM-DD |
| `projectNumber` | `string` | No | The number of the project. |
| `notes` | `string` | No | A note of the purchase. |
| `items` | `string[]` | No | A list of object of ordered items. Example: {"itemId": 123, "sku": "SKU123", "description": "description", "quantity": 1}. See the documentation for further information. |

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

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: "allocadence-create-purchase-order",
  arguments: {
    supplierId: 10,
    supplierName: "Supplier 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: "allocadence-create-purchase-order",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    allocadence: { authProvisionId: "apn_xxxxxxx" },
    supplierId: 10,
    supplierName: "Supplier 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": "allocadence-create-purchase-order",
    "configured_props": {
      "allocadence": { "authProvisionId": "apn_xxxxxxx" },
      "supplierId": 10,
      "supplierName": "Supplier Name"
    }
  }'
```

---

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