Skip to content

Segment

Segment sources, destinations, pipeline graph, warehouses, tracking plans, event volume and Reverse ETL as SQL tables

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/segment/index.md to help me query Segment with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Find your most frequent tracked events

Set the time window to the period you want to analyze.

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT event_name, sum(count) AS events
FROM segment.main.event_volume(start_time := TIMESTAMPTZ '2026-11-01', end_time := TIMESTAMPTZ '2026-11-08')
GROUP BY event_name
ORDER BY events DESC
LIMIT 10

Quick start

Choose where to run Segment, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'segment' AS segment (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-segment'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

segment credentials

A Segment Public API token (Bearer) and the workspace's region

Get these credentials β†’
secret.sql
CREATE SECRET segment (
    TYPE segment,
    token    '<SEGMENT_TOKEN>',  -- secret
    region   '<region>',
    base_url '<base_url>'
);
Credential fields and requirements β†’

4. Run a query

query.sql
SELECT event_name, sum(count) AS events
FROM segment.main.event_volume(start_time := TIMESTAMPTZ '2026-11-01', end_time := TIMESTAMPTZ '2026-11-08')
GROUP BY event_name
ORDER BY events DESC
LIMIT 10
More example queries β†’
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'segment' AS segment (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Twilio Segment's control plane as SQL: sources, destinations, the pipeline graph, warehouses and their syncs, tracking plans, event volume, Reverse ETL, Engage and IAM, read-only from the Segment Public API.

Catalog

Everything segment exposes once attached β€” read straight from the worker's released build.

segment 5 schemas
engage 3 tables

Segment Engage / Unify metadata per Profiles space (no profiles).

Schema examples (3)
Examples (3)

All spaces

SELECT slug, name FROM segment.engage.spaces ORDER BY name;

Largest enabled audiences

SELECT name, compute_cadence, size
FROM segment.engage.audiences
WHERE enabled
ORDER BY size DESC NULLS LAST;

Computed traits

SELECT name, key, status FROM segment.engage.computed_traits ORDER BY name;
Tables
audiences 1 example17 cols

Engage audiences per space: definition, size, compute cadence, status

Columns
space_idnot null VARCHAR
Engage space the object lives in (joins spaces.id).
idnot null VARCHAR
Audience id.
name VARCHAR
Audience name.
key VARCHAR
Audience key (the trait name written to profiles).
description VARCHAR
What the audience selects, as written by its author.
enabled BOOLEAN
True when the audience computes.
status VARCHAR
Computation status.
audience_type VARCHAR
USERS, ACCOUNTS or LINKED.
compute_cadence VARCHAR
REALTIME or BATCH.
size BIGINT
Profiles (or accounts) in the audience at the last computation (count).
size_type VARCHAR
What size counts: USERS, ACCOUNTS or ENTITIES.
definition_query VARCHAR
The audience definition query.
target_entity VARCHAR
Target entity for linked audiences.
created_by VARCHAR
Creator id.
updated_by VARCHAR
Last editor id.
created_at TIMESTAMP WITH TIME ZONE
When created.
updated_at TIMESTAMP WITH TIME ZONE
When last changed.
ConstraintsPRIMARY KEY (space_id, id)
Example

Largest enabled audiences

SELECT name, compute_cadence, size
FROM segment.engage.audiences
WHERE enabled
ORDER BY size DESC NULLS LAST;
Link
computed_traits 1 example15 cols

Engage computed traits per space: definition, status, options

Columns
space_idnot null VARCHAR
Engage space the object lives in (joins spaces.id).
idnot null VARCHAR
Computed trait id.
name VARCHAR
Trait name.
key VARCHAR
Trait key written to profiles.
description VARCHAR
What the trait computes, as written by its author.
enabled BOOLEAN
True when the trait computes.
status VARCHAR
Computation status.
definition_type VARCHAR
USERS or ACCOUNTS.
definition_query VARCHAR
The trait definition query.
include_historical_data BOOLEAN
Backfills from historical data.
include_anonymous_users BOOLEAN
Computes for anonymous profiles too.
created_by VARCHAR
Creator id.
updated_by VARCHAR
Last editor id.
created_at TIMESTAMP WITH TIME ZONE
When created.
updated_at TIMESTAMP WITH TIME ZONE
When last changed.
ConstraintsPRIMARY KEY (space_id, id)
Example

Computed traits

SELECT name, key, status FROM segment.engage.computed_traits ORDER BY name;
Link
spaces 1 example3 cols

Engage / Unify spaces (Profiles workspaces)

Columns
idnot null VARCHAR
Space id.
slug VARCHAR
Space slug.
name VARCHAR
Space name.
ConstraintsPRIMARY KEY (id)
Example

All spaces

SELECT slug, name FROM segment.engage.spaces ORDER BY name;
Link
iam 3 tables

Segment workspace users, groups and role grants for access reviews.

Schema examples (3)
Examples (3)

Workspace owners

SELECT email
FROM segment.iam.users
WHERE list_contains(role_names, 'Workspace Owner')
ORDER BY email;

Largest groups

SELECT name, member_count
FROM segment.iam.user_groups
ORDER BY member_count DESC;

All roles

SELECT name, description FROM segment.iam.roles ORDER BY name;
Tables
roles 1 example3 cols

IAM roles available in the workspace

Columns
idnot null VARCHAR
Role id.
name VARCHAR
Role name, e.g. 'Workspace Owner'.
description VARCHAR
What the role allows.
ConstraintsPRIMARY KEY (id)
Example

All roles

SELECT name, description FROM segment.iam.roles ORDER BY name;
Link
user_groups 1 example5 cols

IAM user groups: member count and roles

Columns
idnot null VARCHAR
Group id.
name VARCHAR
Group name.
member_count BIGINT
Members (count).
role_names VARCHAR[]
Distinct role names granted.
permissions JSON
Role grants: [{roleId, roleName, resources: [{id, type, labels}], labels}].
ConstraintsPRIMARY KEY (id)
Example

Largest groups

SELECT name, member_count
FROM segment.iam.user_groups
ORDER BY member_count DESC;
Link
users 1 example5 cols

Workspace users and their roles (IAM)

Columns
idnot null VARCHAR
User id.
name VARCHAR
User name.
email VARCHAR
User email.
role_names VARCHAR[]
Distinct role names granted.
permissions JSON
Role grants: [{roleId, roleName, resources: [{id, type, labels}], labels}].
ConstraintsPRIMARY KEY (id)
Example

Workspace owners

SELECT email
FROM segment.iam.users
WHERE list_contains(role_names, 'Workspace Owner')
ORDER BY email;
Link
main 13 tables Β· 3 functions

Segment control-plane objects and metrics: what collects data, where it goes and how it is loaded.

Schema examples (12)
Examples (12)

Top events in the first week of November

SELECT event_name, sum(count) AS events
FROM segment.main.event_volume(start_time := TIMESTAMPTZ '2026-11-01', end_time := TIMESTAMPTZ '2026-11-08')
GROUP BY event_name
ORDER BY events DESC
LIMIT 10;

Hourly volume of one source over the last day (source filter pushed down)

SELECT time, sum(count) AS events
FROM segment.main.event_volume(granularity := 'HOUR')
WHERE source_id = 'src_web'
GROUP BY time
ORDER BY time;

Why deliveries to a destination failed over the last week

SELECT discard_reason, sum(count) AS events
FROM segment.main.delivery_overview('failed_delivery', 'src_web', destination_id := 'dst_amplitude')
GROUP BY discard_reason
ORDER BY events DESC;

Read one function's code

SELECT display_name, length(code) AS code_chars
FROM segment.main.function_code('dfn_enrich');
8 more examples

Which workspace the token reads

SELECT slug, name FROM segment.main.workspaces;

Sources per type, and how many are enabled

SELECT source_type, count(*) AS sources,
  count(*) FILTER (WHERE enabled) AS enabled
FROM segment.main.sources
GROUP BY source_type
ORDER BY sources DESC;

Production-labelled sources

SELECT name, labels
FROM segment.main.sources
WHERE list_contains(labels, 'environment:prod')
ORDER BY name;

Sources that block unplanned track events

SELECT source_id, source_name
FROM segment.main.source_schema_settings
WHERE NOT track_allow_unplanned_events
ORDER BY source_id;

Enabled destination instances per type

SELECT destination_type, count(*) AS instances
FROM segment.main.destinations
WHERE enabled
GROUP BY destination_type
ORDER BY instances DESC;

Which settings of each destination hold secrets (values are redacted)

SELECT name, masked_settings FROM segment.main.destinations ORDER BY name;

Active Actions mappings and their triggers

SELECT destination_id, name, trigger
FROM segment.main.destination_subscriptions
WHERE enabled
ORDER BY destination_id, name;

The whole pipeline graph

SELECT source_name, target_type, target_name
FROM segment.main.connections
ORDER BY source_name, target_type, target_name;
Tables
audit_events 1 example8 cols

Audit trail: who changed what in the workspace, with time and resource filters pushed down

Columns
idnot null VARCHAR
Audit event id.
timestamp TIMESTAMP WITH TIME ZONE
When it happened.
type VARCHAR
Event type, e.g. 'Destination Modified'.
actor VARCHAR
Who did it (user or token id).
actor_email VARCHAR
The actor's email when it is a user.
resource_id VARCHAR
Id of the changed resource.
resource_type VARCHAR
Type of the changed resource, e.g. 'source', 'destination'.
resource_name VARCHAR
Name of the changed resource.
ConstraintsPRIMARY KEY (id)
Example

Destination changes since November 1 (time and type pushed down)

SELECT timestamp, actor_email, type, resource_name
FROM segment.main.audit_events
WHERE timestamp >= TIMESTAMPTZ '2026-11-01' AND resource_type = 'destination'
ORDER BY timestamp DESC;
Link
connections 2 examples8 cols

The pipeline graph: one edge per source β†’ destination and source β†’ warehouse connection

Columns
source_idnot null VARCHAR
Source the edge starts from (joins sources.id).
source_name VARCHAR
Source name (NULL when the source id was given directly).
source_enabled BOOLEAN
Whether the source is enabled (NULL when the source id was given directly).
target_typenot null VARCHAR
'destination' or 'warehouse'.
target_idnot null VARCHAR
Destination instance id or warehouse id.
target_name VARCHAR
Destination name, or the warehouse's settings name.
target_slug VARCHAR
Catalog slug of the destination or warehouse type.
target_enabled BOOLEAN
Whether the destination or warehouse is enabled.
ConstraintsPRIMARY KEY (source_id, target_type, target_id)
Examples (2)

The whole pipeline graph

SELECT source_name, target_type, target_name
FROM segment.main.connections
ORDER BY source_name, target_type, target_name;

Sources that feed nothing

SELECT s.name
FROM segment.main.sources s ANTI
JOIN segment.main.connections c ON c.source_id = s.id
ORDER BY s.name;
Link
destination_subscriptions 1 example11 cols

Actions destination subscriptions (mappings): action, trigger, enabled, Reverse ETL model

Columns
destination_idnot null VARCHAR
Destination instance id.
idnot null VARCHAR
Subscription id.
name VARCHAR
Subscription (mapping) name.
action_slug VARCHAR
Action slug, e.g. 'trackEvent'.
action_id VARCHAR
Catalog id of the destination action the mapping runs.
enabled BOOLEAN
True when the mapping is active.
trigger VARCHAR
FQL trigger condition, e.g. 'type = "track"'.
model_id VARCHAR
Reverse ETL model id for Reverse ETL mappings, else NULL.
schedule_strategy VARCHAR
Reverse ETL schedule: CRON, DBT_CLOUD, MANUAL, PERIODIC or SPECIFIC_DAYS.
schedule_config JSON
Reverse ETL schedule configuration (interval, days, hours, cron spec).
settings JSON
The field mapping as JSON, secret-looking values redacted.
ConstraintsPRIMARY KEY (destination_id, id)
Example

Active Actions mappings and their triggers

SELECT destination_id, name, trigger
FROM segment.main.destination_subscriptions
WHERE enabled
ORDER BY destination_id, name;
Link
destinations 2 examples11 cols

Every destination instance: type, enabled, feeding source and masked settings

Columns
idnot null VARCHAR
Destination instance id.
name VARCHAR
Destination instance name.
enabled BOOLEAN
True when the destination receives data.
source_id VARCHAR
Id of the source that feeds this destination instance.
destination_type VARCHAR
Catalog slug of the destination, e.g. 'google-analytics-4', 'amplitude', 'webhooks'.
destination_type_name VARCHAR
Catalog name of the destination.
destination_metadata_id VARCHAR
Catalog id of the destination type.
categories VARCHAR[]
Catalog categories, e.g. ['Analytics'].
is_actions BOOLEAN
True for an Actions destination (has action subscriptions; see destination_subscriptions).
settings JSON
Configuration as JSON with every secret-looking value (API keys, passwords, tokens, credentials, private keys, DSN passwords) replaced by '<redacted>'.
masked_settings VARCHAR[]
Dotted paths of the settings keys whose values were redacted.
ConstraintsPRIMARY KEY (id)
Examples (2)

Enabled destination instances per type

SELECT destination_type, count(*) AS instances
FROM segment.main.destinations
WHERE enabled
GROUP BY destination_type
ORDER BY instances DESC;

Which settings of each destination hold secrets (values are redacted)

SELECT name, masked_settings FROM segment.main.destinations ORDER BY name;
Link
functions 1 example8 cols

Source, destination and insert functions (metadata only; see function_code for the code)

Columns
idnot null VARCHAR
Function id.
resource_type VARCHAR
SOURCE, DESTINATION, INSERT_SOURCE, INSERT_DESTINATION or INSERT_TRANSFORMATION.
display_name VARCHAR
Function name.
description VARCHAR
What the function does, as written by its author.
created_at TIMESTAMP WITH TIME ZONE
When the function was created.
created_by VARCHAR
Id of the user who created it.
logo_url VARCHAR
URL of the function's logo image, if one was uploaded.
catalog_id VARCHAR
Catalog id of the function (used when connecting it).
ConstraintsPRIMARY KEY (id)
Example

Functions per type

SELECT resource_type, count(*) AS functions
FROM segment.main.functions
GROUP BY resource_type
ORDER BY resource_type;
Link
labels 1 example3 cols

Workspace labels (key:value pairs used to scope sources and access)

Columns
keynot null VARCHAR
Label key, e.g. 'environment'.
valuenot null VARCHAR
Label value, e.g. 'prod'.
description VARCHAR
What the label is for (free text set in the workspace).
ConstraintsPRIMARY KEY (key, value)
Example

All labels

SELECT key, value FROM segment.main.labels ORDER BY key, value;
Link
reverse_etl_models 1 example7 cols

Reverse ETL models: the warehouse SQL that feeds Reverse ETL mappings

Columns
idnot null VARCHAR
Model id.
source_id VARCHAR
Reverse ETL source (warehouse connection) id.
name VARCHAR
Model name.
description VARCHAR
What the model computes, as written by its author.
enabled BOOLEAN
True when the model is enabled.
query VARCHAR
The SQL the model runs in the warehouse.
query_identifier_column VARCHAR
Column that uniquely identifies a record.
ConstraintsPRIMARY KEY (id)
Example

Enabled Reverse ETL models

SELECT name, query_identifier_column
FROM segment.main.reverse_etl_models
WHERE enabled
ORDER BY name;
Link
reverse_etl_syncs 1 example17 cols

Reverse ETL sync runs per mapping: status, extract and delivery counts, errors

Columns
destination_id VARCHAR
Destination whose mapping ran the sync.
subscription_idnot null VARCHAR
Mapping (subscription) id.
model_idnot null VARCHAR
Reverse ETL model id.
sync_idnot null VARCHAR
Segment's id for this sync run.
source_id VARCHAR
Reverse ETL source id.
status VARCHAR
Sync status: IN_PROGRESS, SUCCESS, PARTIAL_SUCCESS or FAIL.
started_at TIMESTAMP WITH TIME ZONE
When the sync started.
finished_at TIMESTAMP WITH TIME ZONE
When the sync finished (NULL while running).
duration VARCHAR
Duration as Segment reports it.
extract_count BIGINT
Records extracted from the warehouse (count).
added_count BIGINT
New records found (count).
updated_count BIGINT
Changed records found (count).
deleted_count BIGINT
Deleted records found (count).
delivered_count BIGINT
Records delivered successfully (count).
failed_count BIGINT
Records that failed delivery (count).
error VARCHAR
Error message, if any.
error_code VARCHAR
Fatal error code, if any.
ConstraintsPRIMARY KEY (subscription_id, sync_id)
Example

Reverse ETL run outcomes per model

SELECT model_id, status, count(*) AS runs,
  sum(failed_count) AS failed_records
FROM segment.main.reverse_etl_syncs
GROUP BY ALL
ORDER BY model_id, status;
Link
source_schema_settings 1 example15 cols

Per-source Protocols schema settings: unplanned events/traits, violation handling, forwarding

Columns
source_idnot null VARCHAR
Source whose schema controls these are (joins sources.id).
source_name VARCHAR
Source name (NULL when the source id was given directly).
track_allow_unplanned_events BOOLEAN
Allow track events not in the tracking plan.
track_allow_unplanned_event_properties BOOLEAN
Allow track event properties not in the plan.
track_allow_event_on_violations BOOLEAN
Allow track events that have violations.
track_allow_properties_on_violations BOOLEAN
Keep properties that have violations.
track_common_event_on_violations VARCHAR
Common track event policy on violations: ALLOW, BLOCK or OMIT_PROPERTIES.
identify_allow_unplanned_traits BOOLEAN
Allow identify traits not in the plan.
identify_allow_traits_on_violations BOOLEAN
Keep identify traits that have violations.
identify_common_event_on_violations VARCHAR
Identify policy on violations: ALLOW, BLOCK or OMIT_TRAITS.
group_allow_unplanned_traits BOOLEAN
Allow group traits not in the plan.
group_allow_traits_on_violations BOOLEAN
Keep group traits that have violations.
group_common_event_on_violations VARCHAR
Group policy on violations: ALLOW, BLOCK or OMIT_TRAITS.
forwarding_violations_to VARCHAR
Source id that receives violation events.
forwarding_blocked_events_to VARCHAR
Source id that receives blocked events.
ConstraintsPRIMARY KEY (source_id)
Example

Sources that block unplanned track events

SELECT source_id, source_name
FROM segment.main.source_schema_settings
WHERE NOT track_allow_unplanned_events
ORDER BY source_id;
Link
sources 2 examples13 cols

Every source in the workspace: type, enabled, labels and masked settings (never write keys)

Columns
idnot null VARCHAR
Source id.
slug VARCHAR
Source slug (unique within the workspace).
name VARCHAR
Source display name.
workspace_id VARCHAR
Id of the workspace the source belongs to (joins workspaces.id).
enabled BOOLEAN
True when the source accepts data.
source_type VARCHAR
Catalog slug of the source type, e.g. 'javascript', 'ios', 'http-api', 'salesforce'.
source_type_name VARCHAR
Catalog name of the source type, e.g. 'Javascript'.
categories VARCHAR[]
Catalog categories of the source type, e.g. ['Website'].
is_cloud_event_source BOOLEAN
True for cloud-app event sources (e.g. Stripe webhooks) rather than libraries.
write_key_count INTEGER
Number of write keys the source has (count). The write keys themselves are never returned.
labels VARCHAR[]
Labels as 'key:value' strings, e.g. ['environment:prod'].
settings JSON
Configuration as JSON with every secret-looking value (API keys, passwords, tokens, credentials, private keys, DSN passwords) replaced by '<redacted>'.
masked_settings VARCHAR[]
Dotted paths of the settings keys whose values were redacted.
ConstraintsPRIMARY KEY (id)
Examples (2)

Sources per type, and how many are enabled

SELECT source_type, count(*) AS sources,
  count(*) FILTER (WHERE enabled) AS enabled
FROM segment.main.sources
GROUP BY source_type
ORDER BY sources DESC;

Production-labelled sources

SELECT name, labels
FROM segment.main.sources
WHERE list_contains(labels, 'environment:prod')
ORDER BY name;
Link
warehouse_syncs 2 examples11 cols

Warehouse sync history: one row per sync of a source into a warehouse (status, rows, duration)

Columns
warehouse_idnot null VARCHAR
Warehouse the sync loaded into (joins warehouses.id).
warehouse_name VARCHAR
Warehouse name (NULL when the warehouse id was given directly).
source_idnot null VARCHAR
Source loaded by the sync.
started_atnot null TIMESTAMP WITH TIME ZONE
When the sync started.
ended_at TIMESTAMP WITH TIME ZONE
When the sync finished (NULL while it runs).
status VARCHAR
Segment's sync status as reported, e.g. SUCCESS, FAILED, PARTIAL_SUCCESS, RUNNING.
duration_seconds DOUBLE
Duration in seconds (partial while running).
human_duration VARCHAR
Human-readable duration, e.g. '3m 12s'.
rows_synced BIGINT
Rows loaded into the warehouse (count).
notices JSON
Notices raised during the sync: [{level, message, createdAt}].
error_message VARCHAR
Message of the first error-level notice, else NULL.
ConstraintsPRIMARY KEY (warehouse_id, source_id, started_at)
Examples (2)

Sync outcomes and rows loaded per warehouse

SELECT warehouse_id, status, count(*) AS syncs, sum(rows_synced) AS rows
FROM segment.main.warehouse_syncs
GROUP BY ALL
ORDER BY warehouse_id, status;

Failed syncs and why

SELECT warehouse_id, source_id, started_at, error_message
FROM segment.main.warehouse_syncs
WHERE status = 'FAILED'
ORDER BY started_at DESC;
Link
warehouses 1 example9 cols

Every warehouse connection: type, enabled, masked credentials and live connection state

Columns
idnot null VARCHAR
Warehouse id.
name VARCHAR
Warehouse name (settings.name).
workspace_id VARCHAR
Id of the workspace the warehouse belongs to (joins workspaces.id).
enabled BOOLEAN
True when syncs are enabled.
warehouse_type VARCHAR
Catalog slug: snowflake, bigquery, redshift, postgres, databricks …
warehouse_type_name VARCHAR
Catalog name of the warehouse type.
connection_state VARCHAR
CONNECTED or FAILED (GET /warehouses/{id}/connection-state; read only when selected).
settings JSON
Configuration as JSON with every secret-looking value (API keys, passwords, tokens, credentials, private keys, DSN passwords) replaced by '<redacted>'.
masked_settings VARCHAR[]
Dotted paths of the settings keys whose values were redacted.
ConstraintsPRIMARY KEY (id)
Example

Enabled warehouses and whether Segment can reach them

SELECT name, warehouse_type, connection_state
FROM segment.main.warehouses
WHERE enabled
ORDER BY name;
Link
workspaces 1 example3 cols

The Segment workspace the token belongs to (id, slug, name)

Columns
idnot null VARCHAR
Workspace id.
slug VARCHAR
Workspace slug (used in app.segment.com URLs).
name VARCHAR
Workspace display name.
ConstraintsPRIMARY KEY (id)
Example

Which workspace the token reads

SELECT slug, name FROM segment.main.workspaces;
Link
Table functions
delivery_overview (step VARCHAR, source_id VARCHAR, destination_id := VARCHAR, end_time := TIMESTAMP WITH TIME ZONE, granularity := VARCHAR, start_time := TIMESTAMP WITH TIME ZONE) 1 example

Delivery Overview metrics for one pipeline step of a source (and destination) over time

Positional arguments
step VARCHAR
Pipeline step: successfully_received, failed_on_ingest, filtered_at_source, filtered_at_destination, failed_delivery or successful_delivery.
source_id VARCHAR
Source id (from segment.main.sources).
Named arguments
destination_id := VARCHAR
Destination instance id (named); required for the destination steps. Β· default null
end_time := TIMESTAMP WITH TIME ZONE
Window end, exclusive (named). Default: the WHERE time < bound, else now minus one minute. Β· default null
granularity := VARCHAR
Bucket size: 'DAY' (default), 'HOUR' or 'MINUTE'. Longer windows than 30 days / 14 days / 4 hours are split into several requests. Β· default "DAY"
start_time := TIMESTAMP WITH TIME ZONE
Window start, inclusive (named). Default: the WHERE time >= bound, else end_time minus 7 days (DAY), 1 day (HOUR) or 1 hour (MINUTE). Β· default null
Returns columns
step VARCHAR
The pipeline step queried.
time TIMESTAMP WITH TIME ZONE
Bucket start (UTC).
granularity VARCHAR
Bucket size: DAY, HOUR or MINUTE.
event_name VARCHAR
Event name (when grouped).
event_type VARCHAR
Event type (when grouped).
discard_reason VARCHAR
Why events were filtered or failed (when grouped).
app_version VARCHAR
App version (when grouped).
count BIGINT
Events in the bucket (count).
retry_count BIGINT
Delivery retries in the bucket (count).
Example

Why deliveries to a destination failed over the last week

SELECT discard_reason, sum(count) AS events
FROM segment.main.delivery_overview('failed_delivery', 'src_web', destination_id := 'dst_amplitude')
GROUP BY discard_reason
ORDER BY events DESC;
Link
event_volume (end_time := TIMESTAMP WITH TIME ZONE, granularity := VARCHAR, start_time := TIMESTAMP WITH TIME ZONE) 2 examples

Event volume over time from GET /events/volume, grouped by the dimensions you select

Named arguments
end_time := TIMESTAMP WITH TIME ZONE
Window end, exclusive (named). Default: the WHERE time < bound, else now minus one minute. Β· default null
granularity := VARCHAR
Bucket size: 'DAY' (default), 'HOUR' or 'MINUTE'. Longer windows than 30 days / 14 days / 4 hours are split into several requests. Β· default "DAY"
start_time := TIMESTAMP WITH TIME ZONE
Window start, inclusive (named). Default: the WHERE time >= bound, else end_time minus 7 days (DAY), 1 day (HOUR) or 1 hour (MINUTE). Β· default null
Returns columns
time TIMESTAMP WITH TIME ZONE
Bucket start (UTC).
granularity VARCHAR
Bucket size: DAY, HOUR or MINUTE.
source_id VARCHAR
Source id (when grouped by source).
source_name VARCHAR
Source name (when grouped by source).
source_slug VARCHAR
Source slug (when grouped by source).
event_name VARCHAR
Event name (when grouped by event name).
event_type VARCHAR
Event type: track, identify, page, screen, group, alias (when grouped).
count BIGINT
Events received in the bucket (count).
Examples (2)

Top events in the first week of November

SELECT event_name, sum(count) AS events
FROM segment.main.event_volume(start_time := TIMESTAMPTZ '2026-11-01', end_time := TIMESTAMPTZ '2026-11-08')
GROUP BY event_name
ORDER BY events DESC
LIMIT 10;

Hourly volume of one source over the last day (source filter pushed down)

SELECT time, sum(count) AS events
FROM segment.main.event_volume(granularity := 'HOUR')
WHERE source_id = 'src_web'
GROUP BY time
ORDER BY time;
Link
function_code (function_id VARCHAR) 1 example

One function's source code and setting definitions (opt-in: code is never in the functions table)

Arguments
function_id VARCHAR
Function id, from segment.main.functions.
Returns columns
id VARCHAR
Function id.
resource_type VARCHAR
Function type.
display_name VARCHAR
Function name.
code VARCHAR
The function's JavaScript source.
deployed_at TIMESTAMP WITH TIME ZONE
When the code was last deployed.
is_latest_version BOOLEAN
True when the deployed version is the latest.
batch_max_count BIGINT
Maximum batch size for batched handlers.
settings JSON
Setting definitions: [{name, label, description, type, required, sensitive}].
Example

Read one function's code

SELECT display_name, length(code) AS code_chars
FROM segment.main.function_code('dfn_enrich');
Link
tracking 4 tables

Segment Protocols tracking plans, with each rule's JSON Schema flattened to rows.

Schema examples (5)
Examples (5)

Tracking plans by last change

SELECT name, type, updated_at
FROM segment.tracking.plans
ORDER BY updated_at DESC;

Planned track events per plan

SELECT tracking_plan_name, event_name, property_count
FROM segment.tracking.rules
WHERE rule_type = 'TRACK' AND NOT is_deprecated
ORDER BY tracking_plan_name, event_name;

Required event properties and their allowed values

SELECT event_name, property_name, data_type, enum_values
FROM segment.tracking.properties
WHERE is_required AND section = 'properties'
ORDER BY event_name, property_name;

Properties whose type differs between events

SELECT property_name, list(DISTINCT data_type) AS types
FROM segment.tracking.properties
GROUP BY property_name
HAVING count(DISTINCT data_type) > 1;
1 more example

Which sources each plan validates

SELECT tracking_plan_name, source_name
FROM segment.tracking.plan_sources
ORDER BY tracking_plan_name, source_name;
Tables
plan_sources 1 example8 cols

Which sources each tracking plan is connected to

Columns
tracking_plan_idnot null VARCHAR
Tracking plan the row belongs to (joins tracking.plans.id).
tracking_plan_name VARCHAR
Tracking plan name (from the plan list).
plan_type VARCHAR
Tracking plan type (LIVE, TEMPLATE …).
source_idnot null VARCHAR
Connected source id.
source_name VARCHAR
Display name of the connected source.
source_slug VARCHAR
URL slug of the connected source.
source_type VARCHAR
Catalog slug of the source type.
enabled BOOLEAN
Whether the source is enabled.
ConstraintsPRIMARY KEY (tracking_plan_id, source_id)
Example

Which sources each plan validates

SELECT tracking_plan_name, source_name
FROM segment.tracking.plan_sources
ORDER BY tracking_plan_name, source_name;
Link
plans 1 example7 cols

Protocols tracking plans: name, type (LIVE, TEMPLATE, RULE_LIBRARY …), timestamps

Columns
idnot null VARCHAR
Tracking plan id.
name VARCHAR
Plan name.
slug VARCHAR
Plan slug.
description VARCHAR
What the plan covers, as written by its owner.
type VARCHAR
LIVE, TEMPLATE, RULE_LIBRARY, PROPERTY_LIBRARY or ENGAGE.
created_at TIMESTAMP WITH TIME ZONE
When the plan was created.
updated_at TIMESTAMP WITH TIME ZONE
When the plan last changed.
ConstraintsPRIMARY KEY (id)
Example

Tracking plans by last change

SELECT name, type, updated_at
FROM segment.tracking.plans
ORDER BY updated_at DESC;
Link
properties 2 examples23 cols

Tracking plan properties flattened: one row per property/trait with type, required and allowed values

Columns
tracking_plan_idnot null VARCHAR
Tracking plan the row belongs to (joins tracking.plans.id).
tracking_plan_name VARCHAR
Tracking plan name (from the plan list).
plan_type VARCHAR
Tracking plan type (LIVE, TEMPLATE …).
rule_idnot null VARCHAR
The owning rule, '<rule_type>:<key>' (joins tracking.rules.rule_id).
rule_typenot null VARCHAR
TRACK, IDENTIFY, GROUP, PAGE, SCREEN or COMMON.
event_name VARCHAR
Event name for TRACK rules (rule key), else NULL.
sectionnot null VARCHAR
'properties', 'traits' or 'context'.
property_namenot null VARCHAR
Property path, e.g. 'order_id', 'address.city', 'products[].sku'.
depthnot null INTEGER
Nesting depth (0 = top level).
data_type VARCHAR
JSON Schema type(s) excluding null, joined by '|'.
is_requirednot null BOOLEAN
Listed in the parent object's required list.
is_nullablenot null BOOLEAN
null is allowed (or no type is declared).
is_arraynot null BOOLEAN
The property is an array.
item_type VARCHAR
Type of the array items.
enum_values VARCHAR[]
Allowed values (enum/const) as strings; NULL when unrestricted.
pattern VARCHAR
Regex the value must match.
format VARCHAR
JSON Schema format, e.g. 'date-time', 'email'.
minimum DOUBLE
Smallest allowed numeric value, in the property's own units (JSON Schema minimum).
maximum DOUBLE
Largest allowed numeric value, in the property's own units (JSON Schema maximum).
min_length BIGINT
Minimum string length in characters (JSON Schema minLength).
max_length BIGINT
Maximum string length in characters (JSON Schema maxLength).
description VARCHAR
Property description.
json_schema JSON
The property's own JSON Schema.
ConstraintsPRIMARY KEY (tracking_plan_id, rule_id, section, property_name)
Examples (2)

Required event properties and their allowed values

SELECT event_name, property_name, data_type, enum_values
FROM segment.tracking.properties
WHERE is_required AND section = 'properties'
ORDER BY event_name, property_name;

Properties whose type differs between events

SELECT property_name, list(DISTINCT data_type) AS types
FROM segment.tracking.properties
GROUP BY property_name
HAVING count(DISTINCT data_type) > 1;
Link
rules 1 example15 cols

Tracking plan rules: one row per event/identify/group/page rule with its JSON Schema

Columns
tracking_plan_idnot null VARCHAR
Tracking plan the row belongs to (joins tracking.plans.id).
tracking_plan_name VARCHAR
Tracking plan name (from the plan list).
plan_type VARCHAR
Tracking plan type (LIVE, TEMPLATE …).
rule_idnot null VARCHAR
Rule identity within the plan, '<rule_type>:<key>' (Segment rules carry no id), e.g. 'TRACK:Order Completed', 'IDENTIFY:'.
rule_typenot null VARCHAR
TRACK, IDENTIFY, GROUP, PAGE, SCREEN or COMMON.
event_name VARCHAR
Rule key: the event name for TRACK rules (page/screen name for PAGE/SCREEN).
version BIGINT
Rule version number, incremented by Segment on every edit (1 = first).
created_at TIMESTAMP WITH TIME ZONE
When the rule was created.
updated_at TIMESTAMP WITH TIME ZONE
When the rule last changed.
deprecated_at TIMESTAMP WITH TIME ZONE
When the rule was deprecated, else NULL.
is_deprecated BOOLEAN
True when deprecated_at is set.
description VARCHAR
The schema's description.
property_count INTEGER
Number of properties/traits defined (all sections, nested included).
required_properties VARCHAR[]
Required top-level properties/traits.
json_schema JSON
The rule's full JSON Schema.
ConstraintsPRIMARY KEY (tracking_plan_id, rule_id)
Example

Planned track events per plan

SELECT tracking_plan_name, event_name, property_count
FROM segment.tracking.rules
WHERE rule_type = 'TRACK' AND NOT is_deprecated
ORDER BY tracking_plan_name, event_name;
Link
unified 4 tables

Segment data in cross-worker shapes for UNION ALL with other Query.Farm workers.

Schema examples (4)
Examples (4)

Segment run outcomes in the shared shape

SELECT orchestrator, status, count(*) AS runs
FROM segment.unified.runs
GROUP BY ALL
ORDER BY status;

Active planned events

SELECT event_name, description
FROM segment.unified.event_definitions
WHERE is_active
ORDER BY event_name;

Planned properties per scope

SELECT scope, count(*) AS properties
FROM segment.unified.property_definitions
GROUP BY scope
ORDER BY scope;

Audiences by size

SELECT name, size
FROM segment.unified.cohorts
ORDER BY size DESC NULLS LAST;
Tables
cohorts 1 example9 cols

Engage audiences in the shared product-analytics cohorts shape

Columns
toolnot null VARCHAR
The analytics tool the row came from: 'segment'.
idnot null VARCHAR
Audience id.
name VARCHAR
Audience name.
description VARCHAR
What the audience selects, as written by its author.
size BIGINT
Profiles in the audience (count).
created_at TIMESTAMP WITH TIME ZONE
When created.
updated_at TIMESTAMP WITH TIME ZONE
When last changed.
is_archived BOOLEAN
Not applicable to Segment (NULL).
definition JSON
{query, targetEntity, audienceType, computeCadence}.
ConstraintsPRIMARY KEY (id)
Example

Audiences by size

SELECT name, size
FROM segment.unified.cohorts
ORDER BY size DESC NULLS LAST;
Link
event_definitions 1 example9 cols

Planned events from LIVE tracking plans in the shared product-analytics shape

Columns
toolnot null VARCHAR
The analytics tool the row came from: 'segment'.
event_namenot null VARCHAR
Event name as sent in track/page/screen calls (the rule key).
display_name VARCHAR
Display name (Segment has none; NULL).
description VARCHAR
Description from the rule's JSON Schema.
category VARCHAR
Rule type in lower case: track, page or screen.
is_hidden BOOLEAN
Not tracked by Segment (NULL).
is_active BOOLEAN
False when the rule is deprecated.
volume BIGINT
Recent volume (NULL; use main.event_volume).
tags VARCHAR[]
The tracking plan(s) defining the event.
Example

Active planned events

SELECT event_name, description
FROM segment.unified.event_definitions
WHERE is_active
ORDER BY event_name;
Link
property_definitions 1 example10 cols

Planned event properties and user/group traits in the shared product-analytics shape

Columns
toolnot null VARCHAR
The analytics tool the row came from: 'segment'.
property_namenot null VARCHAR
Property or trait name (dotted path for nested).
scopenot null VARCHAR
'event', 'user' or 'group'.
event_name VARCHAR
Event the property belongs to (event scope).
data_type VARCHAR
JSON Schema type(s), joined by '|'.
description VARCHAR
What the property means, from its JSON Schema description.
is_array BOOLEAN
Array-valued.
is_required BOOLEAN
Required.
is_hidden BOOLEAN
Not tracked by Segment (NULL).
enum_values VARCHAR[]
Allowed values.
Example

Planned properties per scope

SELECT scope, count(*) AS properties
FROM segment.unified.property_definitions
GROUP BY scope
ORDER BY scope;
Link
runs 1 example11 cols

Warehouse syncs and Reverse ETL syncs in the cross-orchestrator unified.runs shape

Columns
orchestratornot null VARCHAR
Always 'segment'.
run_idnot null VARCHAR
Reverse ETL sync id; for warehouse syncs (which have no id) 'warehouse:<warehouse_id>:<source_id>:<start>'.
pipeline VARCHAR
'warehouse/<warehouse_id>/<source_id>' for warehouse syncs, 'reverse_etl/<model_id>/<subscription_id>' for Reverse ETL.
statusnot null VARCHAR
queued, running, success, failed, cancelled or skipped.
raw_status VARCHAR
Segment's own status string.
trigger VARCHAR
'schedule' for warehouse syncs; 'schedule' or 'manual' for Reverse ETL (from the mapping's schedule).
queued_at TIMESTAMP WITH TIME ZONE
Not reported by Segment (NULL).
started_at TIMESTAMP WITH TIME ZONE
When the run started.
ended_at TIMESTAMP WITH TIME ZONE
When the run finished (NULL while running).
duration_seconds DOUBLE
Run duration in seconds.
url VARCHAR
Not provided (NULL).
ConstraintsPRIMARY KEY (run_id)
Example

Segment run outcomes in the shared shape

SELECT orchestrator, status, count(*) AS runs
FROM segment.unified.runs
GROUP BY ALL
ORDER BY status;
Link

Credentials

The secret type segment declares, as reported by the worker itself.

segment

How to get these credentials

A Segment Public API token (Bearer) and the workspace's region

secret.sql
CREATE SECRET segment (
    TYPE segment,
    token    '<SEGMENT_TOKEN>',  -- secret
    region   '<region>',
    base_url '<base_url>'
);
Key Type Required Description
token secret VARCHAR β€” Public API token (Workspace settings > Access Management > Tokens); a read-only role is enough.
region VARCHAR β€” Workspace region: 'us' (default, https://api.segmentapis.com) or 'eu' (https://eu1.api.segmentapis.com).
base_url VARCHAR β€” Override the API origin (a proxy or test server); wins over REGION. http:// only for 127.0.0.1/localhost.

The worker doesn't mark which keys are required.

Create the secret in the same session, after attaching segment β€” the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

sources_columns β€” The sources table columns (binds only; create a segment secret and drop LIMIT 0 for rows)

SELECT id, name, enabled, source_type FROM segment.main.sources LIMIT 0;

Uses sources

properties_columns β€” The tracking.properties columns (binds only; create a segment secret and drop LIMIT 0 for rows)

SELECT event_name, property_name, data_type, is_required
FROM segment.tracking.properties
LIMIT 0;

Uses properties

All spaces

SELECT slug, name FROM segment.engage.spaces ORDER BY name

Uses spaces

Largest enabled audiences

SELECT name, compute_cadence, size
FROM segment.engage.audiences
WHERE enabled
ORDER BY size DESC NULLS LAST

Uses audiences

Computed traits

SELECT name, key, status FROM segment.engage.computed_traits ORDER BY name

Uses computed_traits

Workspace owners

SELECT email
FROM segment.iam.users
WHERE list_contains(role_names, 'Workspace Owner')
ORDER BY email

Uses users

31 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • What is the slug of the Segment workspace?
  • List the names of the enabled Segment sources.
  • How many Segment destination instances are there of each destination type?
  • Which destinations and warehouses does the 'Website' source send data to?
  • Which Segment warehouse syncs failed, and what was the error?
  • How many rows were synced into each Segment warehouse in total?

Segment is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.