# Create Loyalty Reward — Referrizer

> Adds a new loyalty reward to the Referrizer system. See the documentation

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

## Description

Adds a new loyalty reward to the Referrizer system. [See the documentation](https://api.referrizer.com/static/docs/index.html#loyalty-rewards-create-a-loyalty-reward)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `points` | `integer` | Yes | The number of points required for the reward |
| `quantityTotal` | `integer` | No | The total quantity of the loyalty reward |
| `quantityPerContact` | `integer` | No | The quantity of the loyalty reward per contact |
| `startDate` | `string` | No | The start date of the loyalty reward. Format YYYY-MM-DDTHH:MM:SS.SSSZ |
| `itemId` | `string` | No | The ID of the item associated with the loyalty reward |
| `itemName` | `string` | No | The name of the item associated with the loyalty reward |
| `expires` | `boolean` | No | Whether the loyalty reward expires |
| `type` | `string` | No | The type of the loyalty reward |
| `title` | `string` | Yes | The title of the loyalty reward |

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

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: "referrizer-create-loyalty-reward",
  arguments: {
    points: 10,
    quantityTotal: 10,
  },
})
```

**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: "referrizer-create-loyalty-reward",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    referrizer: { authProvisionId: "apn_xxxxxxx" },
    points: 10,
    quantityTotal: 10,
  },
})

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": "referrizer-create-loyalty-reward",
    "configured_props": {
      "referrizer": { "authProvisionId": "apn_xxxxxxx" },
      "points": 10,
      "quantityTotal": 10
    }
  }'
```

---

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