# Segment — Pipedream Connect

> Customer data platform

- API slug: `segment` (use in MCP headers and tool keys)
- Auth: API key (Pipedream-managed)
- Categories: Data Analytics
- Website: https://segment.com
- This page (HTML): https://pipedream.com/apps/segment
- Tools: 7 actions · 1 trigger

## Connect via MCP (recommended)

- Endpoint: `https://remote.mcp.pipedream.net/v3`
- Headers: `Authorization: Bearer <token>` · `x-pd-project-id` · `x-pd-environment` · `x-pd-external-user-id` · `x-pd-app-slug: segment`

```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": "segment",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// e.g. run Associate an identified user with a group:
const result = await mcp.callTool({
  name: "segment-group",
  arguments: {
    anonymousId: "Anonymous ID",
    context: "Context",
  },
})
```

Docs: [MCP guide](https://pipedream.com/docs/connect/mcp/developers.md)

## API proxy

For a Segment endpoint with no pre-built tool, the proxy forwards your request with the connected user's credentials attached.

```bash
# The path segment is the target URL, URL-safe base64 encoded:
# https://api.segment.io/v1/track

curl "https://api.pipedream.com/v1/connect/{project_id}/proxy/aHR0cHM6Ly9hcGkuc2VnbWVudC5pby92MS90cmFjaw?external_user_id={external_user_id}&account_id=apn_xxxxxxx" \
  -H "Authorization: Bearer {access_token}" \
  -H "x-pd-environment: production"
```

Docs: [API proxy guide](https://pipedream.com/docs/connect/api-proxy.md)

## SDK

```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: "segment-group",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    segment: { authProvisionId: "apn_xxxxxxx" },
    anonymousId: "Anonymous ID",
    context: "Context",
  },
})
```

Docs: [Managed auth guide](https://pipedream.com/docs/connect/managed-auth/quickstart.md) · [Tools guide](https://pipedream.com/docs/connect/components.md)

## Actions (7)

### `segment-group` — Associate an identified user with a group (Write)

Group lets you associate an identified user with a group (note requires userId or anonymousId). See the docs here

Full schema: https://pipedream.com/apps/segment/actions/group.md

### `segment-alias` — Associate one identity with another (Write)

Alias is how you associate one identity with another. See the docs here

Full schema: https://pipedream.com/apps/segment/actions/alias.md

### `segment-identify` — Identify a user, tie them to their actions and record traits about them (Write)

Identify lets you tie a user to their actions and record traits about them. It includes a unique User ID and any optional traits you know about them (note requires userId or anonymousId). See the docs here

Full schema: https://pipedream.com/apps/segment/actions/identify.md

### `segment-list-workspace-options` — List Workspace Options (Read-only)

Retrieves available options for the Workspace field.

Full schema: https://pipedream.com/apps/segment/actions/list-workspace-options.md

### `segment-page` — Record page views on your website (Write)

The page method lets you record page views on your website, along with optional extra information about the page being viewed (note requires userId or anonymousId). See the docs here

Full schema: https://pipedream.com/apps/segment/actions/page.md

### `segment-screen` — Record whenever a user sees a screen (Write)

The screen method let you record whenever a user sees a screen of your mobile app (note requires userId or anonymousId). See the docs here

Full schema: https://pipedream.com/apps/segment/actions/screen.md

### `segment-track` — Track actions your users perform (Write)

Track lets you record the actions your users perform (note requires userId or anonymousId). See the docs here

Full schema: https://pipedream.com/apps/segment/actions/track.md

## Triggers (1)

### `segment-webhook-destination` — Webhook Destination (Instant) (Instant)

Send events to a webhook. Requires a Team or Business account.

Full schema: https://pipedream.com/apps/segment/triggers/webhook-destination.md

---

- All apps: https://pipedream.com/apps — index: https://pipedream.com/llms.txt
- Pipedream docs for agents: https://pipedream.com/docs/llms.txt
