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.

Authentication


(success)

The Segment Public API is available

Segment's Public API is available for Team and Business tier customers to use. You can use the Public API and Config APIs in parallel, but moving forward any API updates will come to the Public API exclusively. Please contact your account team or friends@segment.com with any questions.

You can access the Config API programmatically using access tokens. When you authenticate with an access token, you have access to any resource and permission assigned to the token.


Create an access token

create-an-access-token page anchor

As a workspace owner, you can create access tokens from the Access Management page in Admin settings. You can assign the same granularity of permissions as you can for a logged-in user. As best practice, tokens should be assigned the least permissions needed to perform a required API action. All tokens must have a description.

(warning)

Secret Token

You can not retrieve the plain-text token later, so you should save it in a secret manager. If you lose the token you can generate a new one.


Now that you have an access token, you can use this token to access the Config API by setting it in the Authorization header of your requests, for example:

1
$ ACCESS_TOKEN=qiTgISif4zprgBb_5j4hXfp3qhDbxrntWwwOaHgAMr8.gg9ok4Bk7sWlP67rFyXeH3ABBsXyWqNuoXbXZPv1y2g
2
3
$ curl \
4
-X GET \
5
-H "Authorization: Bearer $ACCESS_TOKEN" \
6
https://platform.segmentapis.com/v1beta/workspaces

Example response:

1
{
2
"workspaces": [
3
{
4
"name": "myworkspace",
5
"display_name": "My Space",
6
"id": "e5bdb0902b",
7
"create_time": "2018-08-08T13:24:02.651Z"
8
}
9
]
10
}

You cannot use access tokens created with the workspace:read scope to create or update resources. If you do so, you'll get the following error:

1
{
2
"error": "insufficient scope",
3
"code": 7
4
}

See Config API Errors for error codes.