Never put your API key in a web page. The API key creates tokens, so anyone with the key can play your videos anywhere. Tokens are safe in a page. Keys are not.
The call
POST /v1/projects/{projectId}/videos/{videoId}/playback-tokens
- Auth: your project API key,
Authorization: Bearer sk_.... - Call it from your server, each time you show the video (or per page load).
- The video must be
readyand not held for review. - The
domainmust be a verified domain of the project.
Answer (
201):
playlistUrl for your own hls.js player:
embedUrl in an iframe, or playlistUrl in your own player. See
Embed a video on any website.
cURL
Node.js (18+)
PHP / Laravel
services.segmnt.key in your server environment (.env), never in a Blade
template or a page.
Put the token in the page
Build the iframe on your server and send only the finished HTML:Errors
Errors useapplication/problem+json. Use the code field in your code, not
the text.
Tested in TEST
Checked againsthttps://test-api.segmnt.cloud on 15 Oct 2026:
POST /v1/projects/{projectId}/videos/{videoId}/playback-tokenswith no key →401 unauthorized(the route is live).- The route, the verified-domain check, the token TTL and the held-video
409are covered byapi/src/playback-tokens.test.ts.
Where to go next
- Embed a video on any website
- Add segmnt to WordPress
- How playback protection works
- Accounts, projects, API keys and domains — verify the domain and create the key.