analytics
Segment CLI for Shell Scripts
Use the Segment CLI for shell scripts with headless JSON commands, schema discovery, credentials, and permission controls.
8 functions 4 read 4 write API token auth
Segment CLI for Shell Scripts
Call integration functions from shell scripts with stable JSON input and output.
Use shell scripts for small local automations that need one or more integration calls. The Segment CLI uses the same integration registry as the TUI, Lua runtime, and MCP gateway, but returns predictable command output for automation.
Command Shape
# Segment CLI for Shell Scripts
kosmokrator integrations:configure segment --set write_key="$SEGMENT_WRITE_KEY" --enable --read allow --write ask --json
kosmo integrations:call segment.segment_identify '{"userId":"example_userId","traits":"example_traits"}' --json Discovery Before Execution
Agents and scripts can inspect Segment docs and schemas before choosing a function.
kosmo integrations:docs segment --json
kosmo integrations:docs segment.segment_identify --json
kosmo integrations:schema segment.segment_identify --json
kosmo integrations:search "Segment" --json
kosmo integrations:list --json Useful Segment CLI Functions
| Function | Type | Parameters | Description |
|---|---|---|---|
segment.segment_identify | Write | userId, traits | Identify a user in Segment with their traits. Links metadata about a user (name, email, plan, etc.) to a known userId so all their events can be attributed correctly. |
segment.segment_track | Write | event, userId, properties | Track a custom event for a user in Segment. Records actions your users perform along with optional properties describing the action. |
segment.segment_page | Write | name, userId, properties | Record a page view in Segment. Tracks when a user views a page, along with optional properties about the page. |
segment.segment_group | Write | groupId, userId, traits | Associate a user with a group (organization, company, account) in Segment. Lets you record group membership along with optional group traits. |
segment.segment_get_workspace | Read | slug | Get details of a Segment workspace by its slug. Requires an API token to be configured. |
segment.segment_list_sources | Read | slug | List all sources in a Segment workspace. Requires an API token to be configured. |
segment.segment_get_source | Read | slug, id | Get details of a specific Segment source by ID. Requires an API token to be configured. |
segment.segment_get_current_user | Read | none | Get the currently authenticated Segment user. Useful for verifying API token credentials are correct. |
Automation Notes
- Use
--jsonfor machine-readable output. - Keep credentials out of argv by using environment variables or stored KosmoKrator configuration.
- Configure read/write policy before unattended runs; use
--forceonly for trusted automation. - Use the MCP gateway instead when the agent needs dynamic tool discovery inside a conversation.