# Add Customers to Segment — Customer.io

> Add people to a manual segment by ID. You are limited to 1000 customer IDs per request. See the docs here

- Key: `customer_io-add-customers-to-segment`
- Type: Action (Write)
- Version: 0.0.3
- App: Customer.io (`customer_io`) — https://pipedream.com/apps/customer-io.md
- This page (HTML): https://pipedream.com/apps/customer-io/actions/add-customers-to-segment
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/customer_io/actions/add-customers-to-segment/add-customers-to-segment.mjs

## Description

Add people to a manual segment by ID. You are limited to 1000 customer IDs per request. [See the docs here](https://www.customer.io/docs/api/#operation/add_to_segment)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `customerIds` | `string[]` | Yes | The customer IDs you want to add to the segment. |
| `segmentId` | `string` | Yes | The identifier for a segment. You can find your segment's ID on its page in the dashboard—go to Segments, select your segment, and find the ID under Usage. |
| `idType` | `string` | No | The type of ids you want to use. All of the values in the ids array must be of this type. If you don't provide this parameter, we assume that the ids array contains id values. |

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

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: "customer_io-add-customers-to-segment",
  arguments: {
    customerIds: ["Customer ID"],
    segmentId: "Segment ID",
  },
})
```

**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: "customer_io-add-customers-to-segment",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    customer_io: { authProvisionId: "apn_xxxxxxx" },
    customerIds: ["Customer ID"],
    segmentId: "Segment ID",
  },
})

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": "customer_io-add-customers-to-segment",
    "configured_props": {
      "customer_io": { "authProvisionId": "apn_xxxxxxx" },
      "customerIds": ["Customer ID"],
      "segmentId": "Segment ID"
    }
  }'
```

---

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