Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

Public API


FREE x
TEAM
BUSINESS
ADDON x

The Segment Public API helps you manage your Segment workspaces and its resources. You can use the API to perform CRUD (create, read, update, and delete) operations at no extra charge. This includes working with resources such as Sources, Destinations, Warehouses, Tracking Plans, and the Segment Destinations and Sources Catalogs. The Public API is available to Team and Business Tier customers.

All CRUD endpoints in the API follow REST conventions and use standard HTTP methods. Different URL endpoints represent different resources in a workspace.

Segment Public API Documentation
Research and test the Public API's available endpoints.
(success)

Getting started with the Public API


Config API vs Public API

config-api-vs-public-api page anchor

The Public API includes the following benefits over the Config API:

BenefitDetails
Future EnhancementsFuture improvements will be added to the Public API only.
Improved error handlingThe Public API offers more specific error messages, for faster issue resolution.
VersioningEach endpoint on the Public API can have multiple versions. Stable versions can coexist with beta or alpha versions.
Higher rate limitsThe Public API can offer higher rate limits when needed or different rate limits per endpoint or token.
Improved architectureThe Public API is built with improved security, checks for authentication, authorization, input validation, HTTPS exposed services, auto-scaling, and more in mind.
Cleaner mappingThe Public API uses unique IDs for reference, in place of slugs in the Config API. Unique IDs are, by design, unique.
Available in EuropeThe Public API is accessible to both US and EU-based workspaces.
Increased reliabilityThe Public API features more stable endpoints, and a 99.8% success rate.

Create a Public API token

create-a-public-api-token page anchor
(information)

Only Workspace Owners can create a Public API token

Only users with the Workspace Owner role can create a Public API token. For more information about roles, see Segment's Roles documentation.

To create a Public API token in your Segment workspace:

  1. Navigate to Settings > Workspace settings > Access Management > Tokens.
  2. Click + Create Token.
  3. Create a description for the token and assign it either Workspace Owner or Workspace Member access.
  4. Click Create.
  5. Copy your workspace token somewhere secure and click Done.

To begin sending requests to the Public API, include the Public API Token in your HTTP requests. Configure the Authorization Header as a Bearer Token with the value of the newly generated Public API token.


To enhance API token security, Segment partners with GitHub to prevent fraudulent use of exposed API tokens found in public git repositories. This helps to prevent malicious actors from using exposed tokens to perform unauthorized actions in your Segment workspace.

Within seconds, GitHub scans each commit in public repositories for Public API tokens, and sends detected tokens to Segment. Valid tokens are automatically revoked and workspace owners are notified.

Learn more about GitHub's secret scanning program(link takes you to an external page).


What should I do if I see a notification that my token was exposed?

what-should-i-do-if-i-see-a-notification-that-my-token-was-exposed page anchor

In most cases, identifying and revoking an exposed token takes seconds. We recommend that you check the audit trail to ensure no unauthorized actions were taken with the token.

How did my token get exposed?

how-did-my-token-get-exposed page anchor

Developers can accidentally commit tokens to public repositories, exposing them to the public. This can happen when developers use a token in a local development environment and forget to remove it before committing their code.

Why are exposed tokens automatically revoked?

why-are-exposed-tokens-automatically-revoked page anchor

By automatically revoking the exposed token, Segment helps keep your workspace secure and prevents potential abuse of the token.

How do I enable this feature?

how-do-i-enable-this-feature page anchor

This feature is automatically enabled for all workspaces on Team or Business tier plans.

What should I do when I see a CORS error?

what-should-i-do-when-i-see-a-cors-error page anchor

If you see a CORS error, this means you're attempting to make a request to the Public API on the front-end. The Public API is used for server-side only. To get rid of the error, move all Public API requests to a server.

What User Role / Workspace permissions are required to generate Public API tokens?

what-user-role--workspace-permissions-are-required-to-generate-public-api-tokens page anchor

Only users that have a Workspace Owner role can create Public API Tokens.


The Update Schema Settings in Source endpoint returns an error for fields forwardingViolationsTo and forwardingBlockedEventsTo

the-update-schema-settings-in-source-endpoint-returns-an-error-for-fields-forwardingviolationsto-and-forwardingblockedeventsto page anchor

When you don't have a source to forward violations or blocked events to, then exclude the fields forwardingViolationsTo or forwardingBlockedEventsTo entirely from the request and the setting will be disabled.

PATCH endpoint : https://api.segmentapis.com/sources/{sourceId}/settings

1
{
2
"group": {
3
"allowTraitsOnViolations": false,
4
"allowUnplannedTraits": false,
5
"commonEventOnViolations": "ALLOW"
6
},
7
"identify": {
8
"allowTraitsOnViolations": true,
9
"allowUnplannedTraits": true,
10
"commonEventOnViolations": "Block"
11
},
12
"track": {
13
"allowEventOnViolations": false,
14
"allowPropertiesOnViolations": false,
15
"allowUnplannedEventProperties": false,
16
"allowUnplannedEvents": false,
17
"commonEventOnViolations": "OMIT_PROPERTIES"
18
}
19
}

What is the difference between a destination's Instance ID and Meta ID?

what-is-the-difference-between-a-destinations-instance-id-and-meta-id page anchor

The destination's Instance ID is specific to a single destination within your workspace. The destination's Meta ID, which is returned by the delivery metrics endpoint, identifies which integration you've set up. For example, if you had a dev Mixpanel (Actions) destination and a prod Mixpanel (Actions) destination, they would have the same Meta ID but two different Instance IDs.