# Create Campaign — CleverTap

> Create a campaign. See the documentation

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

## Description

Create a campaign. [See the documentation](https://developer.clevertap.com/docs/create-campaign-api)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | Yes | The name of your campaign shown in the CleverTap dashboard. |
| `targetMode` | `string` | Yes | The type of campaign to create |
| `where` | `object` | No | Allows you to filter target base on the user events and profile properties. Omit this parameter to target your entire user base. Example: { "event_name": "Charged", "from": 20250101, "to": 20250402 } |
| `content` | `object` | No | Object that defines the content for your message. Web Push Notification Example: { "title": "Hi!", "body": "How are you doing today?", "platform_specific": { "safari": { "deep_link": "https://www.google.com", "ttl": 10 }, "chrome": { "image": "https://www.exampleImage.com", "icon": "https://www.exampleIcon.com", "deep_link": "http://www.example.com", "ttl": 10, "require_interaction": true, "cta_title1": "title", "cta_link1": "http://www.example2.com", "cta_iconlink1": "https://www.exampleIcon2.com" }, "firefox": { "icon": "https://www.exampleIcon.com", "deep_link": "https://www.google.com", "ttl": 10 }, "kaios": { "icon": "https://www.exampleIcon.com", "ttl": 10, "kaiosKV": { "key1": "value1", "key2": "value2" } } } } Mobile Push Notification Example: { "title": "Hi!", "body": "How are you doing today?", "platform_specific": { "ios": { "mutable-content": "true", "deep_link": "example.com", "sound_file": "example.caf", "category": "application category//Books", "badge_count": 1, "Key": "Value_ios" }, "android": { "enable_rendermax": true, "wzrk_cid": "Marketing", "background_image": "http://example.jpg", "default_sound": true, "deep_link": "example.com", "large_icon": "http://example.png", "Key": "Value_android", } } } Email Example: { "subject": "Welcome", "body": "<div>Your HTML content for the email</div>", "sender_name": "CleverTap" } |
| `respectFrequencyCaps` | `boolean` | No | Set to false if you want to override frequency caps and dwell time. Defaults to true. |
| `estimateOnly` | `boolean` | No | If this parameter is set to true, the request returns an estimated reach of the campaign, which is the number of users who receive the notification when you send it out. Setting this parameter to true does not create the campaign. Defaults to false. |
| `conversionGoal` | `object` | No | Checks the end goal of the campaign for conversion tracking. Example: { "event_name": "Charged", "filter_type": { "event_property": [ { "property_name": "Items\|Book name", "operator": "equals", "property_value": "book name" }, { "property_name": "Amount", "operator": "equals", "property_value": 3456 }, { "property_name": "Currency", "operator": "equals", "property_value": "USD" } ], "first_time": "yes", "last_time": "yes", "time_of_day": [["21:00","23:00"],["11:34","12:44"],["13:01","13:40"]], "day_of_week": [1,7], "day_of_month": [1,3,16,31] }, "conversion_time": "1D", "revenue_property": "Amount" } |
| `ttlType` | `string` | No | This allows setting of time to live for push notifications for android and iOS. The type of time to live. Can be absolute or relative. Defaults to absolute. |
| `ttlValue` | `integer` | No | This allows setting of time to live for push notifications for android and iOS. The value of the time to live. Can be a number of days, hours, minutes, or seconds. For relative ttl, the input is an integer in minutes For absolute ttl, the input should be an integer in the yyyyMMddHHmm format. Example: 202207200000 |
| `webhookEndpointName` | `string` | No | The name of the webhook endpoint to use for the campaign. |
| `webhookFields` | `string[]` | No | The fields to include in the webhook payload. Can be profile-attributes, tokens, or identities. |
| `webhookKeyValue` | `object` | No | The key-value pairs to include in the webhook payload. |

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

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: "clevertap-create-campaign",
  arguments: {
    name: "Campaign Name",
    targetMode: "Target Mode",
  },
})
```

**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: "clevertap-create-campaign",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    clevertap: { authProvisionId: "apn_xxxxxxx" },
    name: "Campaign Name",
    targetMode: "Target Mode",
  },
})

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": "clevertap-create-campaign",
    "configured_props": {
      "clevertap": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Campaign Name",
      "targetMode": "Target Mode"
    }
  }'
```

---

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