> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modulex.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Segment Integration for AI Agents & Workflows

> Customer data platform for collecting, cleaning, and controlling customer data via the Segment Tracking API

{/* Self-hosted logo — build-time vendored from modulex.json / Iconify (see scripts/lib/logo.js). */}

<img src="https://mintcdn.com/modulexaillc/df8MOr-hXotYLTh5/logos/segment.svg?fit=max&auto=format&n=df8MOr-hXotYLTh5&q=85&s=8cb7ff62b1fedd75dd508f6d05d333f9" alt="Segment logo" width="72" height="72" data-path="logos/segment.svg" />

## Overview

Add **Segment** to any ModuleX agent or workflow. Customer data platform for collecting, cleaning, and controlling customer data via the Segment Tracking API (`api.segment.io/v1`).

<Info>
  **Categories**: Analytics & Data · Analytics · Customer Data Platform · **Auth**: Write Key · **Actions**: 6
</Info>

## Authentication

### Write Key

Authenticate using your Segment source Write Key (used as HTTP Basic Auth)

<Steps>
  <Step title="Step 1">
    Log in to your Segment workspace at [https://app.segment.com](https://app.segment.com)
  </Step>

  <Step title="Step 2">
    Navigate to Connections > Sources and select your source
  </Step>

  <Step title="Step 3">
    Go to the Settings tab and find the Write Key
  </Step>

  <Step title="Step 4">
    Copy the Write Key and paste it below
  </Step>
</Steps>

#### Required Credentials

| Field     | Description                                        | Required | Format                             |
| --------- | -------------------------------------------------- | -------- | ---------------------------------- |
| Write Key | Your Segment source Write Key from app.segment.com | Yes      | `xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx` |

## Available Actions

<AccordionGroup>
  <Accordion title="alias — Associate one user identity with another in Segment">
    ### Parameters

    <ResponseField name="previous_id" type="string" required>
      Previous unique identifier for the user
    </ResponseField>

    <ResponseField name="user_id" type="string">
      Unique identifier for the user in your database
    </ResponseField>

    <ResponseField name="context" type="object">
      Dictionary of extra context about the message such as IP address or locale
    </ResponseField>

    <ResponseField name="integrations" type="object">
      Dictionary of destinations to either enable or disable
    </ResponseField>

    <ResponseField name="timestamp" type="string">
      ISO 8601 timestamp of when the message occurred (e.g. 2022-04-08T17:32:11.318Z)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        }
      },
      "required": [
        "success"
      ],
      "title": "AliasOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="group — Associate an identified user with a group in Segment">
    ### Parameters

    <ResponseField name="group_id" type="string" required>
      Unique identifier for the group in your database
    </ResponseField>

    <ResponseField name="user_id" type="string">
      Unique identifier for the user. Either user\_id or anonymous\_id is required.
    </ResponseField>

    <ResponseField name="anonymous_id" type="string">
      Pseudo-unique substitute for a User ID when no absolute identifier is available
    </ResponseField>

    <ResponseField name="traits" type="object">
      Free-form dictionary of traits of the group such as name or plan
    </ResponseField>

    <ResponseField name="context" type="object">
      Dictionary of extra context about the message such as IP address or locale
    </ResponseField>

    <ResponseField name="integrations" type="object">
      Dictionary of destinations to either enable or disable
    </ResponseField>

    <ResponseField name="timestamp" type="string">
      ISO 8601 timestamp of when the message occurred (e.g. 2022-04-08T17:32:11.318Z)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        }
      },
      "required": [
        "success"
      ],
      "title": "GroupOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="identify — Identify a user and record traits about them in Segment">
    ### Parameters

    <ResponseField name="user_id" type="string">
      Unique identifier for the user. Either user\_id or anonymous\_id is required.
    </ResponseField>

    <ResponseField name="anonymous_id" type="string">
      Pseudo-unique substitute for a User ID when no absolute identifier is available
    </ResponseField>

    <ResponseField name="traits" type="object">
      Free-form dictionary of traits of the user such as email or name
    </ResponseField>

    <ResponseField name="context" type="object">
      Dictionary of extra context about the message such as IP address or locale
    </ResponseField>

    <ResponseField name="integrations" type="object">
      Dictionary of destinations to either enable or disable
    </ResponseField>

    <ResponseField name="timestamp" type="string">
      ISO 8601 timestamp of when the message occurred (e.g. 2022-04-08T17:32:11.318Z)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        }
      },
      "required": [
        "success"
      ],
      "title": "IdentifyOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="page — Record a page view on your website in Segment">
    ### Parameters

    <ResponseField name="user_id" type="string">
      Unique identifier for the user. Either user\_id or anonymous\_id is required.
    </ResponseField>

    <ResponseField name="anonymous_id" type="string">
      Pseudo-unique substitute for a User ID when no absolute identifier is available
    </ResponseField>

    <ResponseField name="name" type="string">
      Name of the page being viewed
    </ResponseField>

    <ResponseField name="properties" type="object">
      Free-form dictionary of properties of the page such as url and referrer
    </ResponseField>

    <ResponseField name="context" type="object">
      Dictionary of extra context about the message such as IP address or locale
    </ResponseField>

    <ResponseField name="integrations" type="object">
      Dictionary of destinations to either enable or disable
    </ResponseField>

    <ResponseField name="timestamp" type="string">
      ISO 8601 timestamp of when the message occurred (e.g. 2022-04-08T17:32:11.318Z)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        }
      },
      "required": [
        "success"
      ],
      "title": "PageOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="screen — Record a screen view in your mobile app in Segment">
    ### Parameters

    <ResponseField name="user_id" type="string">
      Unique identifier for the user. Either user\_id or anonymous\_id is required.
    </ResponseField>

    <ResponseField name="anonymous_id" type="string">
      Pseudo-unique substitute for a User ID when no absolute identifier is available
    </ResponseField>

    <ResponseField name="name" type="string">
      Name of the screen being viewed
    </ResponseField>

    <ResponseField name="properties" type="object">
      Free-form dictionary of properties of the screen
    </ResponseField>

    <ResponseField name="context" type="object">
      Dictionary of extra context about the message such as IP address or locale
    </ResponseField>

    <ResponseField name="integrations" type="object">
      Dictionary of destinations to either enable or disable
    </ResponseField>

    <ResponseField name="timestamp" type="string">
      ISO 8601 timestamp of when the message occurred (e.g. 2022-04-08T17:32:11.318Z)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        }
      },
      "required": [
        "success"
      ],
      "title": "ScreenOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="track — Track an event that a user has performed in Segment">
    ### Parameters

    <ResponseField name="event" type="string" required>
      Name of the action the user has performed
    </ResponseField>

    <ResponseField name="user_id" type="string">
      Unique identifier for the user. Either user\_id or anonymous\_id is required.
    </ResponseField>

    <ResponseField name="anonymous_id" type="string">
      Pseudo-unique substitute for a User ID when no absolute identifier is available
    </ResponseField>

    <ResponseField name="properties" type="object">
      Free-form dictionary of properties of the event such as revenue
    </ResponseField>

    <ResponseField name="context" type="object">
      Dictionary of extra context about the message such as IP address or locale
    </ResponseField>

    <ResponseField name="integrations" type="object">
      Dictionary of destinations to either enable or disable
    </ResponseField>

    <ResponseField name="timestamp" type="string">
      ISO 8601 timestamp of when the message occurred (e.g. 2022-04-08T17:32:11.318Z)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        }
      },
      "required": [
        "success"
      ],
      "title": "TrackOutput",
      "type": "object"
    }
    ```
  </Accordion>
</AccordionGroup>

## Limits & Quotas

* **Rate limits**: Segment does not publish hard per-source rate limits for the
  Tracking API but recommends keeping requests under 500/second per source for
  optimal throughput.
* **Batch size**: Individual calls (`/track`, `/identify`, etc.) accept one
  event per request. Use the `/batch` endpoint for bulk sends (not exposed here).
* **Error model**: Non-2xx responses are caught and returned as
  `success=False` + `error` rather than raising.

## Related integrations

<CardGroup cols={3}>
  <Card title="Databricks" href="/integrations/tools/databricks" />

  <Card title="Google Tag Manager" href="/integrations/tools/google-tag-manager" />

  <Card title="Microsoft Power BI" href="/integrations/tools/microsoft-power-bi" />
</CardGroup>

## Links

* [Segment](https://segment.com)
