Short answerSet how many episodes are free (for all titles or per title), in the console under Player, Episode access, or with the API. Later episodes show a lock screen with an "Unlock in <your platform>" button, and the player sends your page a dawnwood:locked message. When your user pays with your coins or VIP, your server signs a short unlock token (HS256, at most 24 hours) with your platform's signing secret and your page passes it to the player. Dawnwood never touches the payment. Nothing is locked until you set free episodes.
{type: "dawnwood:locked", wid, ep}, and when the viewer taps the button it also sends {type: "dawnwood:unlock_request", wid, ep}.dawnwood:locked or when the viewer taps the button. Dawnwood is not involved in the payment, and every coin or VIP dollar is yours.A locked episode that nobody unlocks is not counted as a play and does not count toward your plan. On the free plan, an episode you unlock still carries our ad break like any other episode. On a paid plan there are no Dawnwood ads at all.
In the console, open Player, then Episode access: turn on "Lock episodes after the free ones", set the number of free episodes, add per-series overrides if you want them, and press Save. Or use the API with your console sign-in or an API token:
PUT /v1/player/partner/access
{"free_episodes": 3, "titles": {"rejected_by_the_alpha": 5, "dead_bride": "all"}}
free_episodes applies to every title: episodes 1 to 3 are free, episode 4 onwards is locked. titles overrides it for single series. "all" means all free, and 0 locks the whole series. Each PUT replaces the whole setting. GET /v1/player/partner/access reads it back.
Create it in the console (Episode access, Signing key) or with POST /v1/player/partner/access/secret. The response holds the secret (it starts dwps_) and its key id kid. The secret is shown only this once. Store it on your server, never in a page or an app.
Rotating. Calling the same endpoint again (or pressing Rotate key) makes a new secret. The old one keeps working for 24 hours, so you can deploy the new secret to your servers without locking out viewers who hold a token signed with the old one. During those 24 hours both secrets verify; a token whose header names the old kid is checked against the old secret. After 24 hours the old secret stops working. Rotate again within the 24 hours and the secret before the old one stops at once (only one old secret is kept).
Revoking. If the old secret may have leaked, end the grace period at once with Revoke old key now, or POST /v1/player/partner/access/secret/revoke-previous. Every token signed with the old secret stops working immediately. When there is no old secret in its grace period, this returns 409 with code: "no_previous_key".
GET /v1/player/partner/access shows the current kid, when it was created (rotated_at), and previous: {kid, valid_until} while an old secret is still in its grace period (otherwise null). It never shows a secret.
A JSON Web Token signed with HMAC-SHA256, using your whole secret (UTF-8 bytes) as the key:
| Part | Content |
|---|---|
| Header | {"alg": "HS256", "typ": "JWT", "kid": "<your kid>"}. kid is optional. |
wid | The series id. |
eps | A list of episode numbers, such as [4, 5, 6], or "all". |
sub | Your own user id. Send a hash, not an email address. |
iat, exp | Unix seconds. exp may be at most 24 hours after iat. |
Any standard JWT library works. In Node.js:
const jwt = require("jsonwebtoken");
const token = jwt.sign({ wid: "dead_bride", eps: [4, 5, 6], sub: sha256(userId) },
process.env.DAWNWOOD_PLAYER_SECRET,
{ algorithm: "HS256", expiresIn: "2h", keyid: process.env.DAWNWOOD_PLAYER_KID });
A token only works with your own embed code. An expired, altered or wrong-series token simply leaves the episode locked; the dawnwood:locked message then carries a reason such as expired, out_of_range or bad_signature.
To check your integration, paste a token into Check your setup on the Episode access page, or POST /v1/player/partner/access/test-token with {"token": "...", "ep": 4}. It tells you whether the token is valid and whether it unlocks that episode. A valid token also comes back with a summary, for example "Valid. Unlocks The Alpha's Dead Bride, episodes 9 to 12, for 23 more hours.", and summary.old_key is true when it was signed with an old secret that is still in its grace period. With {"wid": "dead_bride", "eps": [4]} instead, it signs a test token for you that lasts up to an hour.
The player only accepts commands from the locations registered for your platform, and only sends its messages to the page that embeds it.
<iframe id="dw" src="https://play.dawnwood.ai/public/embed/YOUR_KEY?wid=dead_bride" allow="autoplay; fullscreen"></iframe>
<script>
const player = document.getElementById("dw").contentWindow;
const DW = "https://play.dawnwood.ai";
window.addEventListener("message", async (e) => {
if (e.origin !== DW || !e.data || !e.data.type) return;
if (e.data.type === "dawnwood:ready") player.postMessage({ type: "dawnwood:hello" }, DW); // tells the lock screen you are listening
if (e.data.type === "dawnwood:unlock_request") { // or start on "dawnwood:locked" to show your paywall right away
const paid = await showMyCoinScreen(e.data.wid, e.data.ep); // your own UI
if (!paid) return;
const r = await fetch("/api/dawnwood-unlock", { method: "POST", // your server signs the token
headers: { "content-type": "application/json" },
body: JSON.stringify({ wid: e.data.wid, ep: e.data.ep }) });
const { token } = await r.json();
player.postMessage({ type: "dawnwood:unlock", token }, DW);
}
if (e.data.type === "dawnwood:ended") console.log("next episode", e.data.next);
});
</script>
You can also put a token straight on the player address with &t=<token>, for example when the viewer already has VIP.
Say hello. Until your page has sent the player a message, the lock screen button reads "Open <your platform> to unlock", because the player cannot tell whether anything is listening. Send {type: "dawnwood:hello"} once you are listening (the example above does it on dawnwood:ready) and the button reads "Unlock in <your platform>". Any other command you send (dawnwood:unlock, dawnwood:load, dawnwood:play, dawnwood:pause) counts as a hello too. Either way the button sends dawnwood:unlock_request. The platform name on the button is the name you gave your platform in the console.
Load the player address top level in the WebView. Pass tokens in with evaluateJavascript, and receive the player's messages through a JavaScript interface named DawnwoodBridge:
webView.settings.javaScriptEnabled = true
webView.addJavascriptInterface(object {
@JavascriptInterface fun postMessage(json: String) {
val msg = JSONObject(json)
when (msg.getString("type")) {
"dawnwood:ready" -> webView.post { webView.evaluateJavascript("window.postMessage({type:'dawnwood:hello'},'*')", null) }
"dawnwood:unlock_request" -> showCoinScreen(msg.getString("wid"), msg.getInt("ep"))
}
}
}, "DawnwoodBridge")
webView.loadUrl("https://play.dawnwood.ai/public/embed/YOUR_KEY?wid=dead_bride")
// after your server returns a token
fun unlock(token: String) = webView.evaluateJavascript(
"window.postMessage({type:'dawnwood:unlock',token:" + JSONObject.quote(token) + "},'*')", null)
On iOS, add a WKScriptMessageHandler named dawnwood and call evaluateJavaScript the same way.
| From the player | Data |
|---|---|
dawnwood:ready | The player is listening for commands. |
dawnwood:play | wid, ep: an episode started playing. |
dawnwood:progress | wid, ep, t, duration: at most every 5 seconds while playing. |
dawnwood:ended | wid, ep, next (the next episode number, or null). |
dawnwood:locked | wid, ep, free_episodes, and reason when a token was sent but did not work. |
dawnwood:unlock_request | wid, ep: the viewer tapped the unlock button on the lock screen. Show your paywall. |
| To the player | Data |
|---|---|
dawnwood:hello | No data. Tells the player your page is listening, so the lock screen says "Unlock in <your platform>". |
dawnwood:unlock | token. If an episode is locked on screen, the player tries it again. |
dawnwood:load | wid, ep: open a series at an episode. |
dawnwood:play / dawnwood:pause | No data. Browsers may block playback that the viewer did not start. |
You may not draw over the player or restyle it, and you may not reward viewers for watching videos or ads inside the player. Coins that unlock an episode are not a reward for watching; how viewers earn coins on your own pages is up to you, as long as no rewarded ad runs inside our frame.
Still stuck? Email support@dawnwood.ai with your account email, the series, the episode and the segment or group. See what to include.