A Workspace is a group of Sources that you administer and Segment bills together. Workspaces help companies manage access for different users and data Sources and let you collaborate with team members, add permissions, and share Sources across your team using a shared billing account.
When you first log in to your Segment account, you can create a new Workspace, or choose to log into an existing Workspace if your account is part of an existing organization.
As the Segment Public API scopes tokens to a Workspace, all operations within the API are also limited to the Workspace to which that token belongs.
Like the Segment Public API, the Config API has one endpoint to retrieve details about a Workspace. The getWorkspace endpoint returns the following fields:
Config API | Public API |
---|---|
create_time |
Not returned |
display_name |
name |
id |
id |
name |
slug (workspace/ prefix removed) |
To migrate, replace any use of the Config API endpoints with the Segment Public API counterparts, using the field mappings in the table above.
Returns the Workspace associated with the token used to access this resource.
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.workspaces.getWorkspace()) console.log(JSON.stringify(result)) } catch (e) { console.log('ERROR:', e) }
{- "data": {
- "workspace": {
- "id": "9aQ1Lj62S4bomZKLF4DPqW",
- "name": "papi e2e",
- "slug": "papi-e2e"
}
}
}