# Segment

Manage Segment: sources, destinations, tracking plans, and events. Exposes **35 actions** covering the full API surface
the agent needs - read and write.

## What it can do

| Method | What it does |
| --- | --- |
| `segment_list_workspaces` | List all workspaces the API token has access to - GET /workspaces. |
| `segment_get_workspace` | Get one workspace by ID - GET /workspaces/&#123;id&#125;. |
| `segment_list_sources` | List all sources in the workspace - GET /sources. |
| `segment_get_source` | Get one source by ID - GET /sources/&#123;id&#125;. |
| `segment_create_source` | Create a new source - POST /sources. |
| `segment_update_source` | Update a source - PATCH /sources/&#123;id&#125;. |
| `segment_delete_source` | Delete a source - DELETE /sources/&#123;id&#125;. |
| `segment_enable_source` | Enable a source - PUT /sources/&#123;id&#125;/enabled. |
| `segment_disable_source` | Disable a source - DELETE /sources/&#123;id&#125;/enabled. |
| `segment_list_destinations` | List all destinations - GET /destinations. |
| `segment_get_destination` | Get one destination by ID - GET /destinations/&#123;id&#125;. |
| `segment_create_destination` | Create a new destination - POST /destinations. |
| `segment_update_destination` | Update a destination - PATCH /destinations/&#123;id&#125;. |
| `segment_delete_destination` | Delete a destination - DELETE /destinations/&#123;id&#125;. |
| `segment_enable_destination` | Enable a destination - PUT /destinations/&#123;id&#125;/enabled. |
| `segment_disable_destination` | Disable a destination - DELETE /destinations/&#123;id&#125;/enabled. |
| `segment_list_tracking_plans` | List all tracking plans - GET /tracking-plans. |
| `segment_get_tracking_plan` | Get one tracking plan by ID - GET /tracking-plans/&#123;id&#125;. |
| `segment_create_tracking_plan` | Create a tracking plan - POST /tracking-plans. |
| `segment_update_tracking_plan` | Update a tracking plan - PATCH /tracking-plans/&#123;id&#125;. |
| `segment_delete_tracking_plan` | Delete a tracking plan - DELETE /tracking-plans/&#123;id&#125;. |
| `segment_list_tracking_plan_rules` | List rules in a tracking plan - GET /tracking-plans/&#123;id&#125;/rules. |
| `segment_add_tracking_plan_rule` | Add a rule to a tracking plan - POST /tracking-plans/&#123;id&#125;/rules. |
| `segment_list_functions` | List all functions - GET /functions. |
| `segment_get_function` | Get one function by ID - GET /functions/&#123;id&#125;. |
| `segment_create_function` | Create a function - POST /functions. |
| `segment_update_function` | Update a function - PATCH /functions/&#123;id&#125;. |
| `segment_delete_function` | Delete a function - DELETE /functions/&#123;id&#125;. |
| `segment_list_subscriptions` | List all subscriptions (webhooks) - GET /subscriptions. |
| `segment_create_subscription` | Create a subscription (webhook) - POST /subscriptions. |
| `segment_delete_subscription` | Delete a subscription - DELETE /subscriptions/&#123;id&#125;. |
| `segment_list_catalog_sources` | List all available source types in the catalog - GET /catalog/sources. |
| `segment_get_catalog_source` | Get metadata for one source type in the catalog - GET /catalog/sources/&#123;catalogName&#125;. |
| `segment_list_catalog_destinations` | List all available destination types in the catalog - GET /catalog/destinations. |
| `segment_get_catalog_destination` | Get metadata for one destination type in the catalog - GET /catalog/destinations/&#123;catalogName&#125;. |

## How to get credentials

This connector uses an **API key / token**. Create one in the provider
dashboard, then paste it into FlyMyAI:

- **`SEGMENT_API_TOKEN`** - Segment - Settings - Workspace - Access management - Tokens. (https://app.segment.com/)

## Fields to fill in FlyMyAI

| FlyMyAI field | Where it comes from |
| --- | --- |
| `SEGMENT_API_TOKEN` | Segment - Settings - Workspace - Access management - Tokens. |

## Troubleshooting

- **`401 Unauthorized` / `403 Forbidden`** - the token is wrong, expired, or missing a required scope - regenerate it.
- **`429 Too Many Requests`** - you hit the provider rate limit; retry after a short backoff.
- **Unexpected `4xx` on writes** - double-check required fields; the agent confirms before write actions.

## Links

- [Segment API documentation](https://docs.segmentapis.com)
