Segment

Learn how to use Segment with Composio

Overview

SLUG: SEGMENT

Description

Segment is a customer data platform that helps businesses collect, clean, and control their customer data.

Authentication Details

region
stringRequired
generic_api_key
stringRequired

Connecting to Segment

Create an auth config

Use the dashboard to create an auth config for the Segment toolkit. This allows you to connect multiple Segment accounts to Composio for agents to use.

1

Select App

Navigate to Segment.

2

Configure Auth Config Settings

Select among the supported auth schemes of and configure them here.

3

Create and Get auth config ID

Click “Create Segment Auth Config”. After creation, copy the displayed ID starting with ac_. This is your auth config ID. This is not a sensitive ID — you can save it in environment variables or a database. This ID will be used to create connections to the toolkit for a given user.

Connect Your Account

Using API Key

1from composio import Composio
2
3# Replace these with your actual values
4segment_auth_config_id = "ac_YOUR_SEGMENT_CONFIG_ID" # Auth config ID created above
5user_id = "0000-0000-0000" # UUID from database/app
6
7composio = Composio()
8
9def authenticate_toolkit(user_id: str, auth_config_id: str):
10 # Replace this with a method to retrieve an API key from the user.
11 # Or supply your own.
12 user_api_key = input("[!] Enter API key")
13
14 connection_request = composio.connected_accounts.initiate(
15 user_id=user_id,
16 auth_config_id=auth_config_id,
17 config={"auth_scheme": "API_KEY", "val": {"generic_api_key": user_api_key}}
18 )
19
20 # API Key authentication is immediate - no redirect needed
21 print(f"Successfully connected Segment for user {user_id}")
22 print(f"Connection status: {connection_request.status}")
23
24 return connection_request.id
25
26
27connection_id = authenticate_toolkit(user_id, segment_auth_config_id)
28
29# You can verify the connection using:
30connected_account = composio.connected_accounts.get(connection_id)
31print(f"Connected account: {connected_account}")

Tools

Executing tools

To prototype you can execute some tools to see the responses and working on the Segment toolkit’s playground

Python
1from composio import Composio
2from openai import OpenAI
3import json
4
5openai = OpenAI()
6composio = Composio()
7
8# User ID must be a valid UUID format
9user_id = "0000-0000-0000" # Replace with actual user UUID from your database
10
11tools = composio.tools.get(user_id=user_id, toolkits=["SEGMENT"])
12
13print("[!] Tools:")
14print(json.dumps(tools))
15
16def invoke_llm(task = "What can you do?"):
17 completion = openai.chat.completions.create(
18 model="gpt-4o",
19 messages=[
20 {
21 "role": "user",
22 "content": task, # Your task here!
23 },
24 ],
25 tools=tools,
26 )
27
28 # Handle Result from tool call
29 result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
30 print(f"[!] Completion: {completion}")
31 print(f"[!] Tool call result: {result}")
32
33invoke_llm()

Tool List

Tool Name: Add Labels to Source

Description

Tool to add existing labels to a Source. Use when you have the source ID and want to tag it with metadata labels.

Action Parameters

labels
arrayRequired
sourceId
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Segment Alias

Description

Tool to alias a previous user ID to a new user ID. Use when merging anonymous and known identities.

Action Parameters

anonymousId
string
context
object
integrations
object
previousId
stringRequired
timestamp
string
userId
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Batch Segment Analytics Events

Description

Tool to send multiple analytics calls in a single batch request. Use when you want to reduce HTTP overhead by batching Identify/Track/Page/Screen/Group calls into one request.

Action Parameters

batch
arrayRequired
context
object
integrations
object
writeKey
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Source

Description

Tool to delete a Segment Source. Use when you need to permanently remove a Source by its ID after confirmation.

Action Parameters

sourceId
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Daily Per Source API Calls Usage

Description

Tool to fetch daily API call counts per source for a given period. Use when you need daily breakdown of API usage by source after determining the reporting period.

Action Parameters

pagination
object
period
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Destination

Description

Tool to retrieve a Destination by ID. Use when you need to fetch the full configuration of a Segment Destination instance by its unique identifier. Falls back US→EU public API and legacy app endpoint; returns minimal envelope on legacy HTML or parse errors.

Action Parameters

destinationId
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Segment Group

Description

Tool to associate an identified user with a group via Segment HTTP Tracking API. Use when grouping users with traits.

Action Parameters

anonymousId
string
context
object
groupId
stringRequired
integrations
object
timestamp
string
traits
object
userId
string
writeKey
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Segment Identify

Description

Tool to identify a user and set/update traits via Segment HTTP Tracking API.

Action Parameters

anonymousId
string
context
object
integrations
object
messageId
string
timestamp
string
traits
object
userId
string
writeKey
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Connected Warehouses From Source

Description

Tool to list warehouses connected to a Source. Use when you need to retrieve warehouses for a given source ID.

Action Parameters

pagination
objectRequired
sourceId
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Delivery Metrics Summary from Destination

Description

Get an event delivery metrics summary from a Destination. Primary attempt uses Segment Public API; fallback to legacy app host if needed. On HTML fallback responses, returns a minimal valid envelope to maintain contract.

Action Parameters

destinationId
stringRequired
endTime
string
granularity
string
sourceId
stringRequired
startTime
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Schema Settings in Source

Description

Retrieve schema configuration settings for a Source.

Action Parameters

sourceId
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Segment Page View

Description

Tool to record a page view via Segment HTTP Tracking API. Use when sending page views with optional page name and properties.

Action Parameters

anonymousId
string
context
object
integrations
object
messageId
string
name
string
properties
object
timestamp
string
userId
string
writeKey
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Remove Source Write Key

Description

Tool to remove a write key from a Source. Use when you need to revoke an existing write key for security or rotation.

Action Parameters

sourceId
stringRequired
writeKey
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Segment Screen Event

Description

Tool to record a mobile app screen view. Use when tracking screen views in a mobile app via Segment HTTP Tracking API.

Action Parameters

anonymousId
string
context
object
integrations
object
name
string
properties
object
timestamp
string
userId
string
writeKey
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Segment Track Event

Description

Tool to record a custom user event via Segment HTTP Tracking API. Use when sending events to Segment with valid identity.

Action Parameters

anonymousId
string
context
object
event
stringRequired
integrations
object
properties
object
timestamp
string
userId
string
writeKey
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Source

Description

Tool to update a Source's metadata and settings. Use when you need to modify an existing Source after confirming its ID.

Action Parameters

enabled
boolean
name
string
settings
object
slug
string
sourceId
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired