Skip to main content
Use Segment through Corsair: one client, typed API calls, and incoming webhooks. Segment has two APIs with two credentials, and this plugin covers both:
  • Public API (workspace management, everything except tracking.*): a Public API token, created by a Workspace Owner under Settings > Workspace settings > Access Management > Tokens (choose the Public API type, not the legacy Config API). Segment offers the Public API on the Team and Business plans only; on the Free plan these calls answer 403.
  • Tracking API (tracking.identify, track, page, screen, group, alias, batch): the write key of a source (the source’s Settings > API Keys). Store it as the account’s write_key, or pass the writeKey option. On the Free plan, connect the write key itself as the key: tracking works and the Public API calls do not.
Things to know before you call:
  • Region. An EU workspace lives on eu1.api.segmentapis.com and takes events on events.eu1.segmentapis.com: set the account’s region to eu (or pass the region option). The US hosts answer an EU token with 403.
  • Tracking answers 200 for almost everything. Segment accepts any call it can parse, then may drop it (a wrong write key, a payload over 32 KB). A 200 means received, not delivered: check the source’s debugger. Events go on to every destination connected to the source and cannot be taken back except through a regulation.
  • Regulations permanently delete data. regulations.create starts a deletion or suppression run over the subject ids you pass; it cannot be cancelled. Poll regulations.get until overallStatus is FINISHED, PARTIAL_SUCCESS or FAILED.
  • Write keys are secrets. Sources embed their writeKeys; sources.createWriteKey mints one and sources.removeWriteKey cuts off every sender using it.
  • Paging. List routes take pagination: { count, cursor } (count up to 200 on most) and return pagination.next; pass it back as cursor. The plugin sends a page size when you pass none.
  • Versions. Each operation is pinned to the newest stable version Segment documents for it (v1 on most; v2 for warehouses; alpha or beta where nothing else exists): alpha routes can change.
  • Webhooks. To receive events, add a Webhooks destination to a source, point it at your Corsair webhook URL and set a Shared Secret. Segment signs each request with an HMAC-SHA1 X-Signature, and the plugin checks it against the same secret: store it as the account’s webhook signing secret (webhook_signature), or pass the webhookSecret option. Requests without a valid signature are refused. Segment signs only the first event of a batched delivery, so keep batching off in the destination: a batch is accepted (as events.batch) only when the signature covers the whole body.
What you get:
  • 207 typed API operations
  • 8 incoming webhook event types

Setup

1

Install

2

Add the plugin

corsair.ts
With multiTenancy: true, scope calls with corsair.withTenant(id). See Quick start for KEK + Hub keys, and Multi-tenancy for account isolation.
3

Choose authentication

4

Connect a tenant

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see Connect / OAuth.

Example API calls

List the workspace sources
Track an event
See the full list on the API page.

Webhooks

This plugin registers 8 webhook event types. Configure the provider to POST to your Corsair HTTP handler, then use webhookHooks on the plugin factory. See Webhooks for every event path and payload shape, and Webhooks concept for routing.

What’s next

API reference

Every segment.api.* operation with input and output types.

Webhooks

Event paths, payloads, and webhookHooks examples.

Connect / OAuth

createLink, Hub delivery, and tenant connect flows.

Use with agents

Expose this plugin’s operations as MCP tools.