A Tracking Plan is a data spec outlining the events and properties you intend to collect across your Segment Sources.
The Segment Tracking Plan feature allows you to validate your expected events against the live events that Segment receives. Segment generates violations when an event doesn’t match the spec’d event in the Tracking Plan.
You can store your Tracking Plans in your Workspace, and connect them to one or more Sources.
Using the Segment Public API, you can create, delete, update, list, and connect Tracking Plans and their Rules.
The getTrackingPlan endpoint returns the following fields:
Config API | Public API |
---|---|
display_name |
name |
name |
slug |
updateTime |
updatedAt |
createTime |
createdAt |
To migrate, replace any use of the Config API endpoints with the Segment Public API counterparts, using the field mappings in the table above.
Connects a Source to a Tracking Plan.
• When called, this endpoint may generate the Source Modified
event in the audit trail.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
{- "sourceId": "qQEHquLrjRDN9j1ByrChyn"
}
{- "data": {
- "status": "SUCCESS"
}
}
Lists Sources connected to a Tracking Plan.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
This endpoint requires the user to have at least the following permission(s):
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.trackingPlans.listSourcesFromTrackingPlan('tp_sprout_rVGCC6WdrNxjCf6JpCHP')) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "sources": [
- {
- "id": "qQEHquLrjRDN9j1ByrChyn",
- "slug": "swift",
- "name": "",
- "workspaceId": "9aQ1Lj62S4bomZKLF4DPqW",
- "enabled": true,
- "writeKeys": [
- "bEj5MzDqCkHYRqreZgbPuH"
], - "metadata": {
- "id": "dZeHygTSD4",
- "slug": "swift",
- "name": "Apple",
- "categories": [
- "Mobile"
], - "description": "The hassle-free way to add Segment analytics to your swift app (iOS, macOS, tvOS).",
- "logos": {
}, - "options": [ ],
- "isCloudEventSource": false
}, - "settings": { },
- "labels": [ ]
}
], - "pagination": {
- "current": "MA==",
- "totalEntries": 1
}
}
}
Disconnects a Source from a Tracking Plan.
• When called, this endpoint may generate the Source Modified
event in the audit trail.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.trackingPlans.removeSourceFromTrackingPlan('tp_sprout_rVGCC6WdrNxjCf6JpCHP', 'qQEHquLrjRDN9j1ByrChyn')) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "status": "SUCCESS"
}
}
Creates a Tracking Plan.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
{- "name": "New TP",
- "type": "LIVE"
}
{- "data": {
- "trackingPlan": {
- "id": "tp_sprout_rVGCC6WdrNxjCf6JpCHP",
- "name": "New TP",
- "resourceSchemaId": "rs_1yVwS3zy60dONy9UhCyDqMmVvAE",
- "slug": "",
- "description": "",
- "type": "LIVE",
- "updatedAt": "2006-01-02T15:04:05.000Z",
- "createdAt": "2006-01-02T15:04:05.000Z"
}
}
}
Returns a list of Tracking Plans.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.trackingPlans.listTrackingPlans()) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "trackingPlans": [
- {
- "id": "tp_sprout_rVGCC6WdrNxjCf6JpCHP",
- "name": "New TP",
- "resourceSchemaId": "rs_1yVwS3zy60dONy9UhCyDqMmVvAE",
- "slug": "",
- "description": "",
- "type": "LIVE",
- "updatedAt": "2006-01-02T15:04:05.000Z",
- "createdAt": "2006-01-02T15:04:05.000Z"
}
], - "pagination": {
- "current": "MA=="
}
}
}
Deletes a Tracking Plan.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.trackingPlans.deleteTrackingPlan('tp_sprout_rVGCC6WdrNxjCf6JpCHP')) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "status": "SUCCESS"
}
}
Returns a Tracking Plan.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.trackingPlans.getTrackingPlan('tp_sprout_rVGCC6WdrNxjCf6JpCHP')) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "trackingPlan": {
- "id": "tp_sprout_rVGCC6WdrNxjCf6JpCHP",
- "name": "New TP",
- "resourceSchemaId": "rs_1yVwS3zy60dONy9UhCyDqMmVvAE",
- "slug": "",
- "description": "",
- "type": "LIVE",
- "updatedAt": "2006-01-02T15:04:05.000Z",
- "createdAt": "2006-01-02T15:04:05.000Z"
}
}
}
Updates a Tracking Plan.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
Config API omitted fields:
updateMask
OK
Resource not found
Validation failure
Too many requests
{- "name": "Updated TP"
}
{- "data": {
- "status": "SUCCESS"
}
}
Lists Tracking Plan rules.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
The rate limit for this endpoint is 200 requests per minute, which is lower than the default due to access pattern restrictions. Once reached, this endpoint will respond with the 429 HTTP status code with headers indicating the limit parameters. See Rate Limiting for more information.
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap(api.trackingPlans.listRulesFromTrackingPlan('tp_sprout_rVGCC6WdrNxjCf6JpCHP')) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "rules": [
- {
- "key": "New Tracking Plan Rule",
- "type": "TRACK",
- "version": 1,
- "jsonSchema": {
- "type": "object",
- "properties": {
- "context": {
- "type": "object"
}, - "traits": {
- "type": "object"
}, - "properties": {
- "type": "object"
}
}
}, - "createdAt": "2006-01-02T15:04:05.000Z",
- "updatedAt": "2006-01-02T15:04:05.000Z",
- "deprecatedAt": "2006-01-02T15:04:05.000Z"
}
], - "pagination": {
- "current": "MA=="
}
}
}
Deletes Tracking Plan rules.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
import { configureApis, unwrap } from '@segment/public-api-sdk-typescript' const api = configureApis('/* Insert your Public API token here */') try { const result = await unwrap( api.trackingPlans.removeRulesFromTrackingPlan( 'tp_sprout_rVGCC6WdrNxjCf6JpCHP', 'rules.0.key=New%20Rule&rules.0.type=TRACK&rules.0.version=1' ) ) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "status": "SUCCESS"
}
}
Replaces Tracking Plan rules.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
{- "rules": [
- {
- "key": "New Replaced Rule",
- "type": "TRACK",
- "version": 1,
- "jsonSchema": { }
}
]
}
{- "data": {
- "status": "SUCCESS"
}
}
Updates Tracking Plan rules.
• In order to successfully call this endpoint, the specified Workspace needs to have the Protocols feature enabled. Please reach out to your customer success manager for more information.
OK
Resource not found
Validation failure
Too many requests
{- "rules": [
- {
- "key": "New Rule",
- "type": "TRACK",
- "version": 1,
- "jsonSchema": { }
}
]
}
{- "data": {
- "status": "SUCCESS"
}
}