The examples use the TEST hosts. In production the API host isapi.segmnt.cloudand the embed host iscdn.segmnt.cloud.
What you need
- A ready segmnt video (
vid_...). - A verified domain: the WordPress site’s own domain, for example
blog.example.comorcourses.example.com. If WordPress is atwww.example.com, verifywww.example.comtoo, because we match the exact host. See Accounts, projects, API keys and domains. - A playback token for that video. Your server makes it; see below.
Step 1: Add a Custom HTML block
- Edit the page in WordPress.
- Click +, search for Custom HTML, and add the block.
- Paste this, and replace
vid_9xR4tLwith your video id andYOUR_PLAYBACK_TOKENwith a real token:
- Preview the page. The video plays on the preview domain only if that domain is verified and the token was made for it.
Step 2: Where the token comes from
A token expires (4 hours by default), so pasting one token into the block is only good for a short test. For a real page, the token must be fresh on each page load. There are two ways.Option A: A quick test (paste a token by hand)
Make a token once from your server with the playback-tokens call, paste it into the block, and preview the page. This is fine to check the setup. It stops playing when the token expires.token value from the answer. See
Create playback tokens on your server.
Option B: A fresh token on every page load (recommended)
WordPress runs on PHP on your server, so it can call our API and print the iframe with a fresh token. Add a small shortcode to your theme or a small plugin, then use[segmnt video="vid_9xR4tL"] in any page (or keep the Custom
HTML block and paste the built HTML).
Keep the API key in wp-config.php, never in a page or the block:
- The shortcode runs in PHP on your server, so the API key never reaches the browser.
- WordPress caches pages. If your site serves cached HTML, keep the token’s
life longer than the cache (for example
expiresInSecondsof 6 hours for a 4-hour page cache), or refresh the cache before the token expires. - If the page is public and long-lived, a short token is safer. Ask for a new token per page load, and do not cache the HTML that holds it.
Common problems
Where to go next
Tested in TEST
Checked on TEST on 15 Oct 2026:- The embed host serves the player:
GET /e/{videoId}with no token →403token_missing;GET /segmnt-player.js→200. - The playback-tokens route is live: with no key it answers
401 unauthorized. - The WordPress shortcode uses the public WordPress HTTP API
(
wp_remote_post), the same call as the cURL example, which is covered byapi/src/playback-tokens.test.ts.