CSV Export
The admin CSV export provides a configurable, streaming download of global topics with selectable fields, optional filters, and efficient query optimization for large catalogs. Super admins can export the entire global catalog or filtered subsets for analysis, platform onboarding, or compliance audits.
This guide covers the export API, available fields, filtering options, and strategies for handling large datasets.
Export Endpoint
API: GET /api/admin/topics/export
Authentication: Requires super admin access (requireSuperAdmin).
Response: Returns a CSV file download with the filename format taxonomy-export-YYYY-MM-DD.csv.
Required Parameters
| Parameter | Type | Description |
|---|---|---|
fields | string (comma-separated) | List of field keys to include in the export, in order |
Optional Filter Parameters
| Parameter | Type | Description |
|---|---|---|
search | string | Case-insensitive substring match on topic name |
parentCategory | string | Filter by parent category (one of 41 types) |
segmentType | string | Filter by segment type (B2B, B2C, B2B2C, B2E, B2G) |
Example Request
GET /api/admin/topics/export?fields=topic_name,parent_category,segment_type,segment_name_tradedesk&parentCategory=Business%20Technology
Available Export Fields
Core Fields
| Field Key | DB Column | Description |
|---|---|---|
topic_id | id | Unique topic identifier |
topic_name | topic_name | Topic name |
parent_category | taxonomy_type | Parent category (41 types, e.g., "Business Technology") |
taxonomy_type | parent_category | Taxonomy type group (13 groups, e.g., "Technology & Telecom") |
subcategory | subcategory | Subcategory classification |
segment_type | segment_type | B2B / B2C / B2B2C / B2E / B2G |
audience_type | audience_type | Audience type (e.g., "In-Market Buyers") |
intent_type | intent_type | Primary intent type |
keywords | keywords | Classification keywords (semicolon-separated) |
iab_code | iab_code | IAB content taxonomy code |
engine_version | engine_version | Classification engine version |
taxonomy_hash | taxonomy_hash | Taxonomy definition hash for staleness detection |
source | source | Topic origin (e.g., "classify", "import", "sync") |
external_id | external_id | External system identifier |
performance_score | performance_score | Performance metric |
created_at | created_at | Creation timestamp |
updated_at | updated_at | Last update timestamp |
Note that the export field parent_category reads from DB column taxonomy_type, and the export field taxonomy_type reads from DB column parent_category. The export route handles this swap in its field extractor map, so the exported CSV has the correct TS-perspective column names.
Platform Name Fields
| Field Key | DB Column | Description |
|---|---|---|
segment_name_tradedesk | segment_name_tradedesk | Trade Desk segment name |
segment_name_liveramp | segment_name_liveramp | LiveRamp segment name |
segment_name_internal | segment_name_internal | Internal segment name |
Platform Description Fields
| Field Key | DB Column | Description |
|---|---|---|
segment_desc_liveramp | segment_desc_liveramp | LiveRamp segment description |
segment_desc_tradedesk | segment_desc_tradedesk | Trade Desk segment description |
internal_description | internal_description | Internal description |
Classification Layer Fields
These fields are extracted from the classification JSONB column:
| Field Key | Source Path | Description |
|---|---|---|
sensitivity | classification.layer5_sensitivity | Sensitivity classification |
buyer_journey | classification.layer6_buyer_journey.label | Buyer journey stage label |
intent_score | classification.layer7_composite.score | Composite intent score (0--100) |
intensity | classification.layer2_intensity | Intensity level label |
awareness | classification.layer3_awareness | Awareness stage label |
journey_stage | classification.layer3_awareness | Journey stage (maps to awareness) |
funnel_stage | classification.layer7_composite.funnel_stage | Funnel stage |
The classification layer fields (sensitivity, buyer_journey, intent_score, etc.) are stored in a JSONB column. When any of these fields are requested, the export includes the full classification column in the SQL query. For very large exports, this increases memory usage -- consider omitting these fields if you only need basic topic data.
Query Optimization
The export route uses intelligent query optimization to handle large datasets:
Minimal SELECT List
Rather than selecting all columns with SELECT *, the export builds a minimal column list based on the requested fields. This is critical for avoiding Neon's 64 MB response limit:
- The
classificationJSONB column (~2 KB per row) is only included when classification layer fields are requested - Each requested field is mapped to its source DB column via
FIELD_TO_COLUMN - The
idandcreated_atcolumns are always included (for ordering)
Row Limit
The export query includes a LIMIT 50000 to prevent runaway queries. If you need more than 50,000 topics, use filter parameters to export in batches by parent category or segment type.
Filters Applied at Query Level
All filters (search, parentCategory, segmentType) are applied in the SQL WHERE clause, not post-query. Combined with the standard exclusions (merged_into IS NULL, archived_at IS NULL), this ensures only relevant data is fetched.
CSV Format
Escaping
The export uses standard CSV escaping:
- Fields containing commas, double quotes, or newlines are wrapped in double quotes
- Double quotes within fields are escaped as
""(doubled) - The
escapeCSV()function handles all edge cases
Keywords
The keywords field (stored as a PostgreSQL text array) is exported as a semicolon-separated string:
"Cloud Computing; SaaS; Enterprise; CRM"
Timestamps
Date fields (created_at, updated_at) are exported as ISO 8601 strings directly from the database.
Step-by-Step Export Procedure
Exporting All Topics
- Navigate to the admin export interface (or use the API directly)
- Select the fields you want to include
- Leave filters empty for a full export
- Download the CSV
curl -H "Authorization: Bearer $TOKEN" \
"https://app.example.com/api/admin/topics/export?fields=topic_id,topic_name,parent_category,taxonomy_type,subcategory,segment_type,segment_name_tradedesk,segment_name_liveramp,created_at"
Exporting a Filtered Subset
# Only B2B topics in Business Technology
curl -H "Authorization: Bearer $TOKEN" \
"https://app.example.com/api/admin/topics/export?fields=topic_name,segment_type,segment_name_tradedesk&parentCategory=Business%20Technology&segmentType=B2B"
Exporting with Classification Layers
# Include 7-layer classification details
curl -H "Authorization: Bearer $TOKEN" \
"https://app.example.com/api/admin/topics/export?fields=topic_name,parent_category,segment_type,sensitivity,buyer_journey,intent_score,intensity,awareness,funnel_stage"
Requesting classification layer fields significantly increases the response size because the entire classification JSONB must be fetched for each row. For catalogs with 20,000+ topics, consider splitting the export into multiple requests filtered by parent category.
Error Handling
| Error | Cause | Resolution |
|---|---|---|
Missing 'fields' query parameter | No fields param in URL | Add comma-separated field keys |
No valid fields specified | Empty fields list | Specify at least one valid field key |
Unknown fields: xyz | Invalid field key | Check the available fields table above |
500 Internal Server Error | Query timeout or memory limit | Reduce field count (especially remove classification layers) or add filters |
Admin vs Org Export
The admin export route (/api/admin/topics/export) exports global topics from the topics table. This is distinct from org-level topic management:
| Aspect | Admin Export | Org Library |
|---|---|---|
| Scope | All global topics | Only topics adopted by an org |
| Authentication | Super admin only | Org member with topics:read |
| Table | topics | org_topics (with JOIN to topics) |
| Use case | Catalog auditing, platform onboarding | Org-specific segment lists |
For org-specific exports, use the org library's export functionality. The admin export is for system-wide catalog management and should be used for tasks like platform onboarding (sending the full catalog to Trade Desk or LiveRamp) or compliance audits.
Next Steps
- Global Topics -- Browse topics before exporting
- Output Templates -- Configure the platform names included in exports
- Background Jobs -- Regenerate platform outputs before exporting