# Create Experiment — Eppo

> Create a new experiment analysis in Eppo. Use List Experiments first to find valid entityId and assignmentSourceId values — these numeric IDs are not available separately and must be copied from an existing experiment. Use List Metrics to…

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

## Description

Create a new experiment analysis in Eppo. Use **List Experiments** first to find valid `entityId` and `assignmentSourceId` values — these numeric IDs are not available separately and must be copied from an existing experiment. Use **List Metrics** to find metric IDs to attach to the experiment. `experimentKey` must be a unique slug matching the assignment logging key in your codebase. IMPORTANT: `variations` is a JSON array where each object requires `variant_key`, `is_active`, and `is_control` fields. Exactly one variation must have `is_control: true`. Example variations: `[{"variant_key": "control", "name": "Control", "is_active": true, "is_control": true}, {"variant_key": "treatment", "name": "Treatment", "is_active": true, "is_control": false}]`. IMPORTANT: `metrics` is a JSON array of objects with `metric_id` (integer) and `is_primary` (boolean) fields. Exactly one metric must have `is_primary: true`. Example metrics: `[{"metric_id": 333870, "is_primary": true}]`. Dates must be ISO 8601 format: `2024-01-01T00:00:00Z`. [See the documentation](https://eppo.cloud/api/docs#/Experiments/createExperiment)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | Yes | A human-readable display name for the experiment. |
| `experimentKey` | `string` | Yes | A unique slug that matches the assignment logging key in your codebase (e.g. welcome-banner-test). |
| `entityId` | `integer` | Yes | The numeric ID of the entity type being randomized (e.g. user, session). Use List Experiments to find this value from an existing experiment's entity_id field. |
| `assignmentSourceId` | `integer` | Yes | The numeric ID of the assignment source (logging integration). Use List Experiments to find this value from an existing experiment's assignment_source_id field. |
| `metrics` | `string` | Yes | JSON array of metric objects. Each requires metric_id (integer) and is_primary (boolean). Exactly one metric must have is_primary: true. Use List Metrics to find IDs. Example: [{"metric_id": 333870, "is_primary": true}, {"metric_id": 333871, "is_primary": false}]. |
| `variations` | `string` | Yes | JSON array of variation objects. Each requires variant_key (slug), is_active (boolean), and is_control (boolean). Exactly one variation must have is_control: true. Do NOT use key — use variant_key. Example: [{"variant_key": "control", "name": "Control", "is_active": true, "is_control": true}, {"variant_key": "treatment", "name": "Treatment", "is_active": true, "is_control": false}]. |
| `assignmentsStartDate` | `string` | No | ISO 8601 date-time for when assignment logging began. Example: 2024-01-01T00:00:00Z. |
| `assignmentsEndDate` | `string` | No | ISO 8601 date-time for when assignment logging ended. Omit for ongoing experiments. |

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

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: "eppo-create-experiment",
  arguments: {
    name: "Name",
    experimentKey: "Experiment Key",
  },
})
```

**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: "eppo-create-experiment",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    eppo: { authProvisionId: "apn_xxxxxxx" },
    name: "Name",
    experimentKey: "Experiment Key",
  },
})

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": "eppo-create-experiment",
    "configured_props": {
      "eppo": { "authProvisionId": "apn_xxxxxxx" },
      "name": "Name",
      "experimentKey": "Experiment Key"
    }
  }'
```

---

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