# Create Promo Code — Whop

> Creates a new promo code with the given parameters in Whop. See the documentation

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

## Description

Creates a new promo code with the given parameters in Whop. [See the documentation](https://dev.whop.com/api-reference/v2/promo-codes/create-a-promo-code)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `amountOff` | `integer` | Yes | The amount off (percentage or flat amount) for the Promo Code. |
| `baseCurrency` | `string` | Yes | The monetary currency of the Promo Code. |
| `code` | `string` | Yes | The specific code used to apply the Promo Code at checkout. |
| `expirationDatetime` | `integer` | No | The date/time of when the Promo Code expires. |
| `metadata` | `object` | No | The metadata that will be attached to the Membership upon successful purchase. |
| `newUsersOnly` | `boolean` | No | Restricts Promo Code use to users who haven't purchased from the company before. |
| `numberOfIntervals` | `integer` | No | The number of billing cycles the Promo Code is applied for. By default, it is applied forever (0). |
| `planId` | `string[]` | No | The IDs of plans associated with the Promo Code. Options are loaded from the connected account. |
| `promoType` | `string` | Yes | Whether the Promo Code is a percentage or flat amount off. |
| `stock` | `integer` | Yes | The number of total uses remaining for the Promo Code. |
| `unlimitedStock` | `boolean` | Yes | Whether or not the Promo Code has unlimited uses. |

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

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: "whop-create-promo-code",
  arguments: {
    amountOff: 10,
    baseCurrency: "Base Currency",
  },
})
```

**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: "whop-create-promo-code",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    whop: { authProvisionId: "apn_xxxxxxx" },
    amountOff: 10,
    baseCurrency: "Base Currency",
  },
})

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": "whop-create-promo-code",
    "configured_props": {
      "whop": { "authProvisionId": "apn_xxxxxxx" },
      "amountOff": 10,
      "baseCurrency": "Base Currency"
    }
  }'
```

---

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