Files
unshackle/dev/rest-api/remote-sessions/index.html
T
2026-12-05 03:15:49 +00:00

4373 lines
151 KiB
HTML

<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="Movie, TV, and Music archival software. User guide and REST API reference">
<link rel="canonical" href="https://docs.unshackle.dev/dev/rest-api/remote-sessions/">
<link rel="prev" href="../errors/">
<link rel="next" href="../../../reference/api/service/">
<link rel="icon" href="../../../assets/favicon.svg">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.8.2">
<title>Remote Session Protocol - unshackle</title>
<link rel="stylesheet" href="../../../assets/stylesheets/main.57a0d79d.min.css">
<link rel="stylesheet" href="../../../assets/stylesheets/palette.fb2fffe2.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
<link rel="stylesheet" href="../../../assets/_mkdocstrings.css">
<link rel="stylesheet" href="../../../assets/extra.css">
<script>__md_scope=new URL("../../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
</head>
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="black" data-md-color-accent="indigo">
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#remote-session-protocol" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<header class="md-header" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href="../../.." title="unshackle" class="md-header__button md-logo" aria-label="unshackle" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m800-274-80-80v-206H514l-80-80h166v-80q0-50-34.5-85T481-840q-50 0-84 34.5T363-720v9l-73-73q22-61 75-98.5T481-920q83 0 141 58.5T680-720v80h40q33 0 56.5 23.5T800-560v286Zm20 246-62-62q-11 5-20 7.5T720-80H240q-33 0-56.5-23.5T160-160v-400q0-25 14.5-46t37.5-30L28-820l56-56L876-84l-56 56ZM686-160 539-309q-11 11-25.5 17t-31.5 6q-33 0-56.5-23.5T402-366q0-17 6-31.5t17-25.5L286-560h-46v400h446ZM486-360Zm131-97Z"/></svg>
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
unshackle
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Remote Session Protocol
</span>
</div>
</div>
</div>
<form class="md-header__option" data-md-component="palette">
<input class="md-option" data-md-color-media="(prefers-color-scheme)" data-md-color-scheme="default" data-md-color-primary="black" data-md-color-accent="indigo" aria-label="Switch to light mode" type="radio" name="__palette" id="__palette_0">
<label class="md-header__button md-icon" title="Switch to light mode" for="__palette_1" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7a5 5 0 0 0-5 5 5 5 0 0 0 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1M8 13h8v-2H8zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4a5 5 0 0 0 5-5 5 5 0 0 0-5-5"/></svg>
</label>
<input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="black" data-md-color-accent="indigo" aria-label="Switch to dark mode" type="radio" name="__palette" id="__palette_1">
<label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_2" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17 7H7a5 5 0 0 0-5 5 5 5 0 0 0 5 5h10a5 5 0 0 0 5-5 5 5 0 0 0-5-5m0 8a3 3 0 0 1-3-3 3 3 0 0 1 3-3 3 3 0 0 1 3 3 3 3 0 0 1-3 3"/></svg>
</label>
<input class="md-option" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme="slate" data-md-color-primary="black" data-md-color-accent="indigo" aria-label="Switch to system preference" type="radio" name="__palette" id="__palette_2">
<label class="md-header__button md-icon" title="Switch to system preference" for="__palette_0" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17 7H7a5 5 0 0 0-5 5 5 5 0 0 0 5 5h10a5 5 0 0 0 5-5 5 5 0 0 0-5-5M7 15a3 3 0 0 1-3-3 3 3 0 0 1 3-3 3 3 0 0 1 3 3 3 3 0 0 1-3 3"/></svg>
</label>
</form>
<script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
</label>
<nav class="md-search__options" aria-label="Search">
<a href="javascript:void(0)" class="md-search__icon md-icon" title="Share" aria-label="Share" data-clipboard data-clipboard-text="" data-md-component="search-share" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.15c-.05.21-.08.43-.08.66 0 1.61 1.31 2.91 2.92 2.91s2.92-1.3 2.92-2.91A2.92 2.92 0 0 0 18 16.08"/></svg>
</a>
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
</button>
</nav>
<div class="md-search__suggest" data-md-component="search-suggest"></div>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
</div>
</div>
<div class="md-header__source">
<a href="https://github.com/unshackle-dl/unshackle" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M439.6 236.1 244 40.5c-5.4-5.5-12.8-8.5-20.4-8.5s-15 3-20.4 8.4L162.5 81l51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.3 199v121.9c25.3 12.5 22.3 41.8 9.1 55-6.4 6.4-15.2 10.1-24.3 10.1s-17.8-3.6-24.3-10.1c-17.6-17.6-11.1-46.9 11.2-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1C3 240.6 0 247.9 0 255.5s3 15 8.5 20.4l195.6 195.7c5.4 5.4 12.7 8.4 20.4 8.4s15-3 20.4-8.4l194.7-194.7c5.4-5.4 8.4-12.8 8.4-20.4s-3-15-8.4-20.4"/></svg>
</div>
<div class="md-source__repository">
unshackle-dl/unshackle
</div>
</a>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<nav class="md-tabs" aria-label="Tabs" data-md-component="tabs">
<div class="md-grid">
<ul class="md-tabs__list">
<li class="md-tabs__item">
<a href="../../.." class="md-tabs__link">
Home
</a>
</li>
<li class="md-tabs__item">
<a href="../../../getting-started/installation/" class="md-tabs__link">
Getting Started
</a>
</li>
<li class="md-tabs__item">
<a href="../../../guide/downloading/" class="md-tabs__link">
User Guide
</a>
</li>
<li class="md-tabs__item">
<a href="../../../reference/configuration/" class="md-tabs__link">
Configuration
</a>
</li>
<li class="md-tabs__item md-tabs__item--active">
<a href="../../creating-a-service/" class="md-tabs__link">
Developer
</a>
</li>
</ul>
</div>
</nav>
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary md-nav--lifted" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="../../.." title="unshackle" class="md-nav__button md-logo" aria-label="unshackle" data-md-component="logo">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m800-274-80-80v-206H514l-80-80h166v-80q0-50-34.5-85T481-840q-50 0-84 34.5T363-720v9l-73-73q22-61 75-98.5T481-920q83 0 141 58.5T680-720v80h40q33 0 56.5 23.5T800-560v286Zm20 246-62-62q-11 5-20 7.5T720-80H240q-33 0-56.5-23.5T160-160v-400q0-25 14.5-46t37.5-30L28-820l56-56L876-84l-56 56ZM686-160 539-309q-11 11-25.5 17t-31.5 6q-33 0-56.5-23.5T402-366q0-17 6-31.5t17-25.5L286-560h-46v400h446ZM486-360Zm131-97Z"/></svg>
</a>
unshackle
</label>
<div class="md-nav__source">
<a href="https://github.com/unshackle-dl/unshackle" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2025 Fonticons, Inc.--><path d="M439.6 236.1 244 40.5c-5.4-5.5-12.8-8.5-20.4-8.5s-15 3-20.4 8.4L162.5 81l51.5 51.5c27.1-9.1 52.7 16.8 43.4 43.7l49.7 49.7c34.2-11.8 61.2 31 35.5 56.7-26.5 26.5-70.2-2.9-56-37.3L240.3 199v121.9c25.3 12.5 22.3 41.8 9.1 55-6.4 6.4-15.2 10.1-24.3 10.1s-17.8-3.6-24.3-10.1c-17.6-17.6-11.1-46.9 11.2-56v-123c-20.8-8.5-24.6-30.7-18.6-45L142.6 101 8.5 235.1C3 240.6 0 247.9 0 255.5s3 15 8.5 20.4l195.6 195.7c5.4 5.4 12.7 8.4 20.4 8.4s15-3 20.4-8.4l194.7-194.7c5.4-5.4 8.4-12.8 8.4-20.4s-3-15-8.4-20.4"/></svg>
</div>
<div class="md-source__repository">
unshackle-dl/unshackle
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../.." class="md-nav__link">
<span class="md-ellipsis">
Home
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_2" >
<label class="md-nav__link" for="__nav_2" id="__nav_2_label" tabindex="0">
<span class="md-ellipsis">
Getting Started
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_2">
<span class="md-nav__icon md-icon"></span>
Getting Started
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../../getting-started/installation/" class="md-nav__link">
<span class="md-ellipsis">
Installation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../getting-started/quickstart/" class="md-nav__link">
<span class="md-ellipsis">
Quick Start
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../getting-started/configuration-file/" class="md-nav__link">
<span class="md-ellipsis">
The Configuration File
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3" >
<label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="0">
<span class="md-ellipsis">
User Guide
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_3">
<span class="md-nav__icon md-icon"></span>
User Guide
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../../guide/downloading/" class="md-nav__link">
<span class="md-ellipsis">
Downloading
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../guide/cli-reference/" class="md-nav__link">
<span class="md-ellipsis">
CLI Reference
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../guide/drm-and-cdm/" class="md-nav__link">
<span class="md-ellipsis">
DRM & CDM Setup
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../guide/proxies-and-vpn/" class="md-nav__link">
<span class="md-ellipsis">
Proxies & VPN
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../guide/vaults/" class="md-nav__link">
<span class="md-ellipsis">
Key Vaults
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../guide/output-and-naming/" class="md-nav__link">
<span class="md-ellipsis">
Output & Naming
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../guide/subtitles/" class="md-nav__link">
<span class="md-ellipsis">
Subtitles
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../guide/troubleshooting/" class="md-nav__link">
<span class="md-ellipsis">
Troubleshooting
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3_9" >
<div class="md-nav__link md-nav__container">
<a href="../" class="md-nav__link ">
<span class="md-ellipsis">
Server
</span>
</a>
<label class="md-nav__link " for="__nav_3_9" id="__nav_3_9_label" tabindex="0">
<span class="md-nav__icon md-icon"></span>
</label>
</div>
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_3_9_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_3_9">
<span class="md-nav__icon md-icon"></span>
Server
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../authentication/" class="md-nav__link">
<span class="md-ellipsis">
Authentication
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../dashboard/" class="md-nav__link">
<span class="md-ellipsis">
Dashboard
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../guide/remote-sessions/" class="md-nav__link">
<span class="md-ellipsis">
Remote Sessions
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4" >
<div class="md-nav__link md-nav__container">
<a href="../../../reference/configuration/" class="md-nav__link ">
<span class="md-ellipsis">
Configuration
</span>
</a>
<label class="md-nav__link " for="__nav_4" id="__nav_4_label" tabindex="0">
<span class="md-nav__icon md-icon"></span>
</label>
</div>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_4_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_4">
<span class="md-nav__icon md-icon"></span>
Configuration
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../../reference/configuration/directories/" class="md-nav__link">
<span class="md-ellipsis">
Directories
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/configuration/services/" class="md-nav__link">
<span class="md-ellipsis">
Services & Authentication
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/configuration/download/" class="md-nav__link">
<span class="md-ellipsis">
Download & Processing
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/configuration/output/" class="md-nav__link">
<span class="md-ellipsis">
Output & Naming Options
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/configuration/drm/" class="md-nav__link">
<span class="md-ellipsis">
DRM & CDM
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/configuration/network/" class="md-nav__link">
<span class="md-ellipsis">
Network & Proxy
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/configuration/vaults/" class="md-nav__link">
<span class="md-ellipsis">
Key Vault Options
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/configuration/post-scripts/" class="md-nav__link">
<span class="md-ellipsis">
Post-Scripts
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/configuration/misc/" class="md-nav__link">
<span class="md-ellipsis">
Other Settings
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/configuration/example/" class="md-nav__link">
<span class="md-ellipsis">
Annotated Example
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5" checked>
<label class="md-nav__link" for="__nav_5" id="__nav_5_label" tabindex="">
<span class="md-ellipsis">
Developer
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_5">
<span class="md-nav__icon md-icon"></span>
Developer
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../creating-a-service/" class="md-nav__link">
<span class="md-ellipsis">
Creating a Service
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../service-architecture/" class="md-nav__link">
<span class="md-ellipsis">
Service Architecture
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5_3" checked>
<label class="md-nav__link" for="__nav_5_3" id="__nav_5_3_label" tabindex="">
<span class="md-ellipsis">
REST API
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_5_3_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_5_3">
<span class="md-nav__icon md-icon"></span>
REST API
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../quickstart/" class="md-nav__link">
<span class="md-ellipsis">
REST API Quick Start
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../endpoints/" class="md-nav__link">
<span class="md-ellipsis">
Endpoints
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../job-lifecycle/" class="md-nav__link">
<span class="md-ellipsis">
Job Lifecycle
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../errors/" class="md-nav__link">
<span class="md-ellipsis">
Error Responses
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
<span class="md-ellipsis">
Remote Session Protocol
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
Remote Session Protocol
</span>
</a>
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#routes" class="md-nav__link">
<span class="md-ellipsis">
Routes
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#conventions" class="md-nav__link">
<span class="md-ellipsis">
Conventions
</span>
</a>
<nav class="md-nav" aria-label="Conventions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#slow-responses" class="md-nav__link">
<span class="md-ellipsis">
Slow responses
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#login-states" class="md-nav__link">
<span class="md-ellipsis">
Login states
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#licensing-modes" class="md-nav__link">
<span class="md-ellipsis">
Licensing modes
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#client-presence" class="md-nav__link">
<span class="md-ellipsis">
Client presence
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#remote-session-lifetime" class="md-nav__link">
<span class="md-ellipsis">
Remote session lifetime
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#route-reference" class="md-nav__link">
<span class="md-ellipsis">
Route reference
</span>
</a>
<nav class="md-nav" aria-label="Route reference">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#post-apisessioncreate" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/create
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apitunnel" class="md-nav__link">
<span class="md-ellipsis">
GET /api/tunnel
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apitunnelcheck" class="md-nav__link">
<span class="md-ellipsis">
GET /api/tunnel/check
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apisessionsession_idchannel" class="md-nav__link">
<span class="md-ellipsis">
GET /api/session/{session_id}/channel
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apisessionsession_idprompt" class="md-nav__link">
<span class="md-ellipsis">
GET /api/session/{session_id}/prompt
</span>
</a>
<nav class="md-nav" aria-label="GET /api/session/{session_id}/prompt">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#cdm-calls" class="md-nav__link">
<span class="md-ellipsis">
CDM calls
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idprompt" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/prompt
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apisessionsession_idlogs" class="md-nav__link">
<span class="md-ellipsis">
GET /api/session/{session_id}/logs
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apisessionsession_idtitles" class="md-nav__link">
<span class="md-ellipsis">
GET /api/session/{session_id}/titles
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idtracks" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/tracks
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idsegments" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/segments
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idsegment_filter" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/segment_filter
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idsamples" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/samples
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idlicense" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/license
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idkeys" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/keys
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idkeysbad" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/keys/bad
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apisessionsession_id" class="md-nav__link">
<span class="md-ellipsis">
GET /api/session/{session_id}
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#delete-apisessionsession_id" class="md-nav__link">
<span class="md-ellipsis">
DELETE /api/session/{session_id}
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#cache-files" class="md-nav__link">
<span class="md-ellipsis">
Cache files
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#security-properties" class="md-nav__link">
<span class="md-ellipsis">
Security properties
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5_4" >
<label class="md-nav__link" for="__nav_5_4" id="__nav_5_4_label" tabindex="">
<span class="md-ellipsis">
Python API
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="2" aria-labelledby="__nav_5_4_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_5_4">
<span class="md-nav__icon md-icon"></span>
Python API
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../../reference/api/service/" class="md-nav__link">
<span class="md-ellipsis">
Service
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/api/config/" class="md-nav__link">
<span class="md-ellipsis">
Config
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/api/tracks/" class="md-nav__link">
<span class="md-ellipsis">
Tracks
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/api/titles/" class="md-nav__link">
<span class="md-ellipsis">
Titles
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../../reference/api/drm/" class="md-nav__link">
<span class="md-ellipsis">
DRM
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#routes" class="md-nav__link">
<span class="md-ellipsis">
Routes
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#conventions" class="md-nav__link">
<span class="md-ellipsis">
Conventions
</span>
</a>
<nav class="md-nav" aria-label="Conventions">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#slow-responses" class="md-nav__link">
<span class="md-ellipsis">
Slow responses
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#login-states" class="md-nav__link">
<span class="md-ellipsis">
Login states
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#licensing-modes" class="md-nav__link">
<span class="md-ellipsis">
Licensing modes
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#client-presence" class="md-nav__link">
<span class="md-ellipsis">
Client presence
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#remote-session-lifetime" class="md-nav__link">
<span class="md-ellipsis">
Remote session lifetime
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#route-reference" class="md-nav__link">
<span class="md-ellipsis">
Route reference
</span>
</a>
<nav class="md-nav" aria-label="Route reference">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#post-apisessioncreate" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/create
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apitunnel" class="md-nav__link">
<span class="md-ellipsis">
GET /api/tunnel
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apitunnelcheck" class="md-nav__link">
<span class="md-ellipsis">
GET /api/tunnel/check
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apisessionsession_idchannel" class="md-nav__link">
<span class="md-ellipsis">
GET /api/session/{session_id}/channel
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apisessionsession_idprompt" class="md-nav__link">
<span class="md-ellipsis">
GET /api/session/{session_id}/prompt
</span>
</a>
<nav class="md-nav" aria-label="GET /api/session/{session_id}/prompt">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#cdm-calls" class="md-nav__link">
<span class="md-ellipsis">
CDM calls
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idprompt" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/prompt
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apisessionsession_idlogs" class="md-nav__link">
<span class="md-ellipsis">
GET /api/session/{session_id}/logs
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apisessionsession_idtitles" class="md-nav__link">
<span class="md-ellipsis">
GET /api/session/{session_id}/titles
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idtracks" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/tracks
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idsegments" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/segments
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idsegment_filter" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/segment_filter
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idsamples" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/samples
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idlicense" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/license
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idkeys" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/keys
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#post-apisessionsession_idkeysbad" class="md-nav__link">
<span class="md-ellipsis">
POST /api/session/{session_id}/keys/bad
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#get-apisessionsession_id" class="md-nav__link">
<span class="md-ellipsis">
GET /api/session/{session_id}
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#delete-apisessionsession_id" class="md-nav__link">
<span class="md-ellipsis">
DELETE /api/session/{session_id}
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#cache-files" class="md-nav__link">
<span class="md-ellipsis">
Cache files
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#security-properties" class="md-nav__link">
<span class="md-ellipsis">
Security properties
</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<h1 id="remote-session-protocol">Remote Session Protocol<a class="headerlink" href="#remote-session-protocol" title="Permanent link">&para;</a></h1>
<p>This page lists the routes, login states, error codes and message shapes that a <code>--remote</code> client
and the server share. A remote session keeps an authenticated service on the server between
requests. The client logs in one time, then asks for titles, tracks,
segments and licences in the same remote session. The client downloads, decrypts and muxes.</p>
<p>The record is <code>unshackle/core/remote_protocol.py</code>: both the client (<code>unshackle/core/remote_service.py</code>,
the reference client) and the server (<code>unshackle/core/api/</code>) read it. Titles, tracks and DRM cross
in the wire form of <code>unshackle/core/wire.py</code>. To set up <code>dl --remote</code>, read
<a href="../../../guide/remote-sessions/">Remote sessions</a> in the user guide.</p>
<h2 id="routes">Routes<a class="headerlink" href="#routes" title="Permanent link">&para;</a></h2>
<p><code>unshackle serve</code> mounts these routes in every mode except <code>--cdm-only</code>, which keeps only
<code>/api/health</code>. <code>--remote-only</code> keeps only these routes (and the dashboard routes when <code>serve.dashboard.key</code> is set). Paths use the <code>session_id</code> of the create request.</p>
<table>
<thead>
<tr>
<th>Method</th>
<th>Path</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>GET</code></td>
<td><code>/api/health</code></td>
<td>Version, and the liveness check of a client that waits for a restarted server. See <a href="../endpoints/#get-apihealth">endpoints</a>.</td>
</tr>
<tr>
<td><code>GET</code></td>
<td><code>/api/services</code></td>
<td>The services, their options and <code>client_config</code> keys, and the regions of the server accounts. See <a href="../endpoints/#get-apiservices">endpoints</a>.</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/search</code></td>
<td>Search a service. See <a href="../endpoints/#post-apisearch">endpoints</a>.</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/session/create</code></td>
<td><a href="#post-apisessioncreate">Create a remote session</a> and start its login.</td>
</tr>
<tr>
<td><code>GET</code></td>
<td><code>/api/tunnel</code></td>
<td><a href="#get-apitunnel">The WebSocket of a <code>--local-proxy</code> tunnel</a>.</td>
</tr>
<tr>
<td><code>GET</code></td>
<td><code>/api/tunnel/check</code></td>
<td><a href="#get-apitunnelcheck">The exit IP address through a tunnel</a>.</td>
</tr>
<tr>
<td><code>GET</code></td>
<td><code>/api/session/{session_id}/channel</code></td>
<td><a href="#get-apisessionsession_idchannel">The remote session channel</a>: the messages the server starts, and the client's answers.</td>
</tr>
<tr>
<td><code>GET</code></td>
<td><code>/api/session/{session_id}/prompt</code></td>
<td><a href="#get-apisessionsession_idprompt">The login state and a waiting prompt</a>, the polling fallback of the remote session channel.</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/session/{session_id}/prompt</code></td>
<td><a href="#post-apisessionsession_idprompt">Answer a prompt</a>, the polling fallback.</td>
</tr>
<tr>
<td><code>GET</code></td>
<td><code>/api/session/{session_id}/logs</code></td>
<td><a href="#get-apisessionsession_idlogs">Service log records</a>, the polling fallback.</td>
</tr>
<tr>
<td><code>GET</code></td>
<td><code>/api/session/{session_id}/titles</code></td>
<td><a href="#get-apisessionsession_idtitles">The titles</a>.</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/session/{session_id}/tracks</code></td>
<td><a href="#post-apisessionsession_idtracks">The tracks, chapters and manifests of a title</a>.</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/session/{session_id}/segments</code></td>
<td><a href="#post-apisessionsession_idsegments">The URL, DRM, headers and cookies of the selected tracks</a>.</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/session/{session_id}/segment_filter</code></td>
<td><a href="#post-apisessionsession_idsegment_filter">The HLS segments the service drops</a>.</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/session/{session_id}/samples</code></td>
<td><a href="#post-apisessionsession_idsamples">Decrypt the samples of a track the service decrypts itself</a>.</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/session/{session_id}/license</code></td>
<td><a href="#post-apisessionsession_idlicense">A licence relay, a certificate, or the content keys of the server CDM</a>.</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/session/{session_id}/keys</code></td>
<td><a href="#post-apisessionsession_idkeys">Store the content keys the client proved</a>.</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/session/{session_id}/keys/bad</code></td>
<td><a href="#post-apisessionsession_idkeysbad">Report a server-vault content key that did not decrypt</a>.</td>
</tr>
<tr>
<td><code>GET</code></td>
<td><code>/api/session/{session_id}</code></td>
<td><a href="#get-apisessionsession_id">Remote session info</a>.</td>
</tr>
<tr>
<td><code>DELETE</code></td>
<td><code>/api/session/{session_id}</code></td>
<td><a href="#delete-apisessionsession_id">End the remote session</a> and return the changed cache files.</td>
</tr>
</tbody>
</table>
<p>A client walks a remote session in this order:</p>
<div class="language-text highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a>GET /api/tunnel → only with --local-proxy, before the create
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a>POST /api/session/create → session_id, login state "authenticating", licensing mode
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a>GET /api/session/{id}/channel → WebSocket: prompts, CDM calls, log records, login state, drain
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a>GET /api/session/{id}/titles → after the login state is "authenticated"
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5" href="#__codelineno-0-5"></a>POST /api/session/{id}/tracks → for the title that the user selects
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6" href="#__codelineno-0-6"></a>POST /api/session/{id}/segments → for the selected tracks
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7" href="#__codelineno-0-7"></a>POST /api/session/{id}/license → for each DRM track
</span><span id="__span-0-8"><a id="__codelineno-0-8" name="__codelineno-0-8" href="#__codelineno-0-8"></a>POST /api/session/{id}/keys → the content keys that the client proved
</span><span id="__span-0-9"><a id="__codelineno-0-9" name="__codelineno-0-9" href="#__codelineno-0-9"></a>DELETE /api/session/{id} → the end, with the changed cache files
</span></code></pre></div>
<h2 id="conventions">Conventions<a class="headerlink" href="#conventions" title="Permanent link">&para;</a></h2>
<ul>
<li><strong>API key and owner.</strong> Each request carries the API key in <code>X-Secret-Key</code> (see
<a href="../authentication/">Authentication</a>). A request without a valid API key gets <code>401</code> from the
authentication middleware, in its own error shape. A remote session belongs to the API key and the IP address
that created it. A request from another API key or another IP address gets <code>403 FORBIDDEN</code>. A
remote session that does not exist, or that ended, gets <code>404 SESSION_NOT_FOUND</code>.</li>
<li><strong>Errors.</strong> A failure is the <a href="../errors/#the-standard-error-shape">standard error body</a> with an
<code>error_code</code> from <code>APIErrorCode</code>. The server never answers with a <code>5xx</code> status.</li>
<li><strong>Body size.</strong> The create request and <code>POST /api/search</code> take a body of up to 8 MiB, the
<code>samples</code> route up to 16 MiB, and every other route up to 1 MiB.</li>
<li><strong>A route that the server lacks.</strong> A client counts an optional call (the segment filter, a bad
content key report, the log poll) as empty only when the server answers <code>404</code> with no
<code>error_code</code>. Any other error stops the call.</li>
</ul>
<h3 id="slow-responses">Slow responses<a class="headerlink" href="#slow-responses" title="Permanent link">&para;</a></h3>
<p>The <code>titles</code>, <code>tracks</code>, <code>segments</code> and <code>license</code> routes can take minutes on a large catalogue.
When the answer is not ready after 30 seconds, the route sends status <code>200</code> and the headers. It
then sends a newline every 30 seconds until the JSON body is ready. JSON parsers ignore the leading
newlines. This keeps the connection open through a reverse proxy that closes an idle request, and
the read timeout of the client starts again at each byte.</p>
<p>A failure after the first 30 seconds arrives with status <code>200</code>: see
<a href="../errors/#late-failures-with-status-200">Late failures with status <code>200</code></a>.</p>
<p>A slow response is not gzip-compressed. Gzip output cannot start before the body is ready, and
the newlines must go out at once.</p>
<h2 id="login-states">Login states<a class="headerlink" href="#login-states" title="Permanent link">&para;</a></h2>
<p>The login state (<code>AuthStatus</code>) tells where the login of a remote session stands:</p>
<table>
<thead>
<tr>
<th>Login state</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>authenticating</code></td>
<td>The login runs on the server. The create request answers with this state.</td>
</tr>
<tr>
<td><code>authenticated</code></td>
<td>The login succeeded. The service routes answer.</td>
</tr>
<tr>
<td><code>failed</code></td>
<td>The login failed. <code>error</code> gives the reason, and each service route answers <code>AUTH_FAILED</code>.</td>
</tr>
</tbody>
</table>
<p><code>pending_input</code> is not a login state: the prompt route reports it while a prompt or a CDM call
waits for the client. The login state stays <code>authenticating</code> during that time. Each service route
(<code>titles</code>, <code>tracks</code>, <code>segments</code>, <code>segment_filter</code>, <code>samples</code>, <code>license</code>, <code>keys</code>, <code>keys/bad</code>) answers
<code>400 INVALID_INPUT</code> while the login state is <code>authenticating</code>, and <code>401 AUTH_FAILED</code> after a failed
login.</p>
<p>A prompt waits up to 600 seconds for its answer. When the time ends, the login fails. A prompt after
the login (in the titles, tracks or licence step) goes to the client on an open remote session channel.
Without the channel it fails at once, because the client polls for prompts only during the login.</p>
<p>A CDM call goes to the client in any login state. A call that no client takes within 10 seconds fails,
because no client listens. A call that a client took waits 60 seconds for its answer. An answer to a
CDM call does not change the login state.</p>
<h2 id="licensing-modes">Licensing modes<a class="headerlink" href="#licensing-modes" title="Permanent link">&para;</a></h2>
<p>The licensing mode (<code>LicensingMode</code>) says who licenses a remote session. The server fixes it at the
create request, for the whole remote session:</p>
<table>
<thead>
<tr>
<th>Licensing mode</th>
<th><code>Licensor</code></th>
<th>Who licenses</th>
</tr>
</thead>
<tbody>
<tr>
<td>Server CDM</td>
<td><code>server_cdm</code></td>
<td>The server's device, live, up to the licence cap of the API key. The server vault answers first.</td>
</tr>
<tr>
<td>Client device</td>
<td><code>client_device</code></td>
<td>The client's own device, through the licence relay. The service sees a stand-in for that device. With <code>server_vault</code>, the server vault answers first.</td>
</tr>
<tr>
<td>Lent device</td>
<td><code>lent_device</code></td>
<td>Nobody licenses live: the service runs on the server's device, and the content keys come only from a vault.</td>
</tr>
<tr>
<td>No device</td>
<td><code>no_device</code></td>
<td>No server CDM, and no client device that the service can see: the create had no <code>cdm_type</code>, or no <code>cdm_relay: true</code>. A client with a CDM licenses through the licence relay.</td>
</tr>
</tbody>
</table>
<p>The create response gives the mode in four fields, and the client reads them back:</p>
<table>
<thead>
<tr>
<th>Field</th>
<th>Server CDM</th>
<th>Client device</th>
<th>Lent device</th>
<th>No device</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>server_cdm</code></td>
<td><code>true</code></td>
<td><code>false</code></td>
<td><code>false</code></td>
<td><code>false</code></td>
</tr>
<tr>
<td><code>server_device</code></td>
<td><code>false</code></td>
<td><code>false</code></td>
<td><code>true</code></td>
<td><code>false</code></td>
</tr>
<tr>
<td><code>server_vault</code></td>
<td><code>false</code></td>
<td>the grant</td>
<td>the grant</td>
<td><code>false</code></td>
</tr>
<tr>
<td><code>server_cdm_max_height</code></td>
<td>the licence cap, or <code>null</code></td>
<td>the licence cap, or <code>null</code></td>
<td>the licence cap, or <code>null</code></td>
<td>the licence cap, or <code>null</code></td>
</tr>
</tbody>
</table>
<p>The client reads the no-device mode, and a create response without <code>server_cdm</code> and
<code>server_device</code>, as the client-device mode.</p>
<p>The server picks the server CDM when the API key has the <code>server_cdm</code> grant for the service, unless
the client sends <code>server_cdm: false</code> with a <code>cdm_type</code>, or <code>quality</code> asks for more than the licence
cap with a <code>cdm_type</code>. Above the licence cap without a <code>cdm_type</code>, the server refuses the create
with <code>403 SERVER_CDM_CAPPED</code>. A request that sets one of the service's <code>SERVER_DEVICE_OPTIONS</code> keeps the
server CDM. Without the server CDM, a create with <code>cdm_type</code> and <code>cdm_relay: true</code> (or with a
licence cap) gets the client-device mode, and any other create gets the no-device mode. A service
that calls <code>lend_server_device()</code> turns a client-device mode into the lent-device mode.</p>
<p>The user's view of each mode is in <a href="../../../guide/remote-sessions/#who-licenses-the-tracks">Who licenses the tracks</a>.</p>
<h2 id="client-presence">Client presence<a class="headerlink" href="#client-presence" title="Permanent link">&para;</a></h2>
<p>Source: <code>unshackle/core/api/client_presence.py</code>. The server knows a client by its remote session channel,
its requests and its create request. Each state has a limit for the silence of the client. At the
limit, the server ends the remote session.</p>
<table>
<thead>
<tr>
<th>State</th>
<th>When</th>
<th>Limit</th>
</tr>
</thead>
<tbody>
<tr>
<td>awaited</td>
<td>The client gave the remote session its ID in the create request, and has sent no request and opened no remote session channel since</td>
<td>150s</td>
</tr>
<tr>
<td>polling</td>
<td>The client has had no remote session channel</td>
<td>The TTL rule only</td>
</tr>
<tr>
<td>present</td>
<td>The remote session channel is open</td>
<td>None</td>
</tr>
<tr>
<td>away</td>
<td>The remote session channel closed with any code except 1000, the connection broke, or the server closed the channel</td>
<td>180s, or half of <code>session_ttl</code> when that is more</td>
</tr>
<tr>
<td>left</td>
<td>The client closed the remote session channel with code 1000</td>
<td>90s</td>
</tr>
</tbody>
</table>
<ul>
<li><strong>Sign of life.</strong> A request of the client for the remote session, or a new remote session channel, starts
the time again. The end of a request does not. A request after the state left makes the state away.</li>
<li><strong>Work in progress.</strong> A request that still works for the client does not keep the remote session
past the limit.</li>
<li><strong>Login.</strong> A client that is away or left does not get the 600s of a login. Its login ends with the
remote session.</li>
<li><strong>TTL.</strong> The limit never makes a remote session stay for longer than the TTL rule lets it.</li>
<li><strong>The end request.</strong> The client closes its remote session channel and then sends the <code>DELETE</code>, whose
answer has the login cache. Thus the close does not end the remote session at once.</li>
<li><strong>A silent loss.</strong> A client that the network cuts off sends no close. The server sends a ping after
20s without data, and counts the client as away when no answer comes in 10s.</li>
</ul>
<h2 id="remote-session-lifetime">Remote session lifetime<a class="headerlink" href="#remote-session-lifetime" title="Permanent link">&para;</a></h2>
<p>The server keeps remote sessions in memory. A restart loses them all.</p>
<table>
<thead>
<tr>
<th>Limit</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Idle time</td>
<td><code>serve.session_ttl</code>. Each request and each new remote session channel starts it again. A remote session does not reach it while a request works on it or while its remote session channel is open.</td>
</tr>
<tr>
<td>Idle time during the login</td>
<td>The larger of <code>session_ttl</code> and 600 seconds, unless the client is gone.</td>
</tr>
<tr>
<td>Client presence</td>
<td>See <a href="#client-presence">Client presence</a>.</td>
</tr>
<tr>
<td>Remote sessions at the same time</td>
<td><code>serve.max_sessions</code>. A create at the limit ends one remote session: <a href="../../../reference/configuration/services/#serve"><code>max_sessions</code></a> gives which one.</td>
</tr>
<tr>
<td>Sweep</td>
<td>Every 5 seconds the server ends each expired remote session.</td>
</tr>
</tbody>
</table>
<p><a href="../../../reference/configuration/services/#serve"><code>serve</code></a> in the configuration reference gives
the defaults of <code>session_ttl</code> and <code>max_sessions</code>.</p>
<p>A delete, an expiry, an eviction and a server shutdown end a remote session the same way: the server
cancels each waiting prompt and CDM call, closes the remote session channel with code <code>4404</code> and deletes
the cache directory of the remote session. A request that waits for the remote session then answers
<code>SESSION_NOT_FOUND</code> and starts no service code.</p>
<p>Before a restart the operator can start a drain. A create request then gets <code>409 SERVER_DRAINING</code>,
and the requests of open remote sessions continue. The server tells each client with the <code>drain</code>
message of the remote session channel and the <code>draining</code> field of the info route.</p>
<hr />
<h2 id="route-reference">Route reference<a class="headerlink" href="#route-reference" title="Permanent link">&para;</a></h2>
<h3 id="post-apisessioncreate"><code>POST /api/session/create</code><a class="headerlink" href="#post-apisessioncreate" title="Permanent link">&para;</a></h3>
<p>Create a remote session for a service and title. The server builds the service, starts the login in
the background, and answers at once with the login state <code>authenticating</code>. The body is a
<code>SessionCreate</code> object:</p>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>service</code></td>
<td>Required. The service tag, in any case, or an alias.</td>
</tr>
<tr>
<td><code>title_id</code></td>
<td>Required. The title ID or URL, as for <code>dl</code>.</td>
</tr>
<tr>
<td><code>session_id</code></td>
<td>The ID that the client gives the remote session: the canonical text of a version 4 UUID. Without it, the server makes the ID.</td>
</tr>
<tr>
<td><code>credentials</code></td>
<td><code>{username, password, extra?}</code> for the profile.</td>
</tr>
<tr>
<td><code>cookies</code></td>
<td>The Netscape cookie file of the profile, zlib-compressed and base64-encoded.</td>
</tr>
<tr>
<td><code>cache</code></td>
<td>The cache files of the service: a map of cache key to the zlib-compressed, base64-encoded file. See <a href="#cache-files">Cache files</a>.</td>
</tr>
<tr>
<td><code>profile</code></td>
<td>The credentials profile. At the top level it never means a service's own <code>--profile</code> option.</td>
</tr>
<tr>
<td><code>proxy</code></td>
<td>A full proxy URI, <code>tunnel:&lt;id&gt;</code> for a <code>--local-proxy</code> tunnel, or, with <code>server_proxy</code>, a country code or <code>provider:country</code>.</td>
</tr>
<tr>
<td><code>no_proxy</code></td>
<td><code>true</code> to accept the server's own connection.</td>
</tr>
<tr>
<td><code>client_region</code></td>
<td>The two-letter country code of the client.</td>
</tr>
<tr>
<td><code>proxy_region</code></td>
<td>The country code that the client resolved <code>proxy</code> from. For a server-account service, the server matches it against its own accounts.</td>
</tr>
<tr>
<td><code>server_cdm</code></td>
<td><code>false</code> when the client declines the server CDM.</td>
</tr>
<tr>
<td><code>cdm_type</code></td>
<td>The DRM system of the client's CDM (<code>widevine</code>, <code>playready</code>), or the id of a DRM plugin.</td>
</tr>
<tr>
<td><code>cdm_relay</code></td>
<td><code>true</code> when the client answers CDM calls. A plugin <code>cdm_type</code> gets no relay.</td>
</tr>
<tr>
<td><code>cdm_security_level</code>, <code>cdm_system_id</code>, <code>cdm_device_type</code></td>
<td>The device facts of the client's CDM. <code>cdm_system_id</code> and <code>cdm_device_type</code> are for Widevine only.</td>
</tr>
<tr>
<td><code>service_config</code></td>
<td>The identity config keys that the service lists in <code>client_config</code>, and the client's <code>preferences</code> block. At most 16384 bytes of JSON.</td>
</tr>
<tr>
<td><code>plugins</code></td>
<td>The DRM plugins of the client: id to <code>{version, device?}</code>. <code>device</code> holds the plain values of the device attributes that the plugin names in <code>device_facts</code>. At most 16384 bytes of JSON.</td>
</tr>
<tr>
<td><code>range_</code>, <code>vcodec</code>, <code>quality</code>, <code>best_available</code>, <code>generate_dv</code></td>
<td>The <code>dl</code> track selection, so that the service fetches the right manifests.</td>
</tr>
<tr>
<td><code>dl_params</code></td>
<td>The other <code>dl</code> values that a service reads (see below).</td>
</tr>
<tr>
<td><code>service_params</code></td>
<td>The service's own CLI options, by option name or flag spelling.</td>
</tr>
<tr>
<td><code>client</code></td>
<td>A free object that the dashboard shows as it is. The CLI sends <code>version</code>, <code>code_hash</code>, <code>platform</code> and a redacted <code>argv</code>. The server drops it above 4096 bytes of JSON.</td>
</tr>
</tbody>
</table>
<p><code>session_id</code> lets the client delete the remote session before the create answers. A second create
with the same ID from the same API key and IP address ends the first one if the first one has not
answered, and replaces its remote session when the new one is stored. A second create that fails
leaves that remote session open. A remote session with an ID from the client ends when the client
sends no request for it and opens no remote session channel within 150 seconds of the create.</p>
<p><code>dl_params</code> holds <code>lang</code>, <code>v_lang</code>, <code>a_lang</code> and <code>s_lang</code> (arrays of language strings), <code>acodec</code> (an
array of audio codec names or <code>dl -a</code> aliases such as <code>ddp</code>), and <code>forced_subs</code> and <code>exact_lang</code>
(booleans). The service reads them from <code>ctx.parent.params</code>, never as service options, so a service
option with the same name does not get them. The server uses the <code>dl</code> default for each absent value:
<code>lang</code> is <code>["orig"]</code>, <code>s_lang</code> is <code>["all"]</code>, <code>v_lang</code>, <code>a_lang</code> and <code>acodec</code> are <code>[]</code>, and <code>forced_subs</code> and <code>exact_lang</code> are
<code>false</code>. An empty array is a valid value and stays empty. The server does not get the <code>dl</code> mode flags
(<code>video_only</code>, <code>audio_only</code>, <code>subs_only</code>, <code>chapters_only</code>, <code>list_</code>, <code>skip_dl</code>, <code>sub_format</code>,
<code>no_attachments</code>, <code>audio_description</code>, <code>audio_description_only</code>, <code>forced_subs_only</code>). A service that
reads one of them to skip work fetches more on the server, but the result is the same.</p>
<p>When the body has <code>service_params</code>, the server reads service options only from it, and a flat key
with the same name stays a <code>dl</code> value. Without <code>service_params</code>, the server reads service options
from the flat keys that are not fields of <code>SessionCreate</code>: the table above, plus <code>season</code>,
<code>episode</code>, <code>part</code> and <code>wanted</code>, which the create ignores.</p>
<p>In a remote session that does not use a server account, the service gets the client's <code>profile</code> in
<code>ctx.parent.params</code>, as in a local run with that profile. The profile name keys the token cache of
the service, so the cache files that the client sends and gets back belong to that profile.</p>
<p><strong>The proxy.</strong> Without the <code>server_proxy</code> grant, <code>proxy</code> must be a full proxy URI with an <code>http</code>,
<code>https</code> or <code>socks</code> scheme on a public host that resolves. A Control D resolver,
<code>controld://&lt;resolver&gt;@dns.controld.com</code>, counts as a full proxy URI: the server runs a forwarder for
it. Without <code>server_proxy</code>, the server does not resolve country codes with its own proxy providers,
and it refuses the create with <code>INVALID_PROXY</code> when no <code>proxy</code> is set and <code>client_region</code> differs from
the server's region. A request with no <code>client_region</code> is not blocked. With <code>server_proxy</code>, the
server resolves a country code and picks a proxy for <code>client_region</code> itself. The server accepts
<code>tunnel:&lt;id&gt;</code> only from the API key that opened the tunnel. A server-account service refuses a client
proxy URI, because the server's login would go through it.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a><span class="p">{</span>
</span><span id="__span-1-2"><a id="__codelineno-1-2" name="__codelineno-1-2" href="#__codelineno-1-2"></a><span class="w"> </span><span class="nt">"session_id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"d4e5f6a7-..."</span><span class="p">,</span>
</span><span id="__span-1-3"><a id="__codelineno-1-3" name="__codelineno-1-3" href="#__codelineno-1-3"></a><span class="w"> </span><span class="nt">"service"</span><span class="p">:</span><span class="w"> </span><span class="s2">"EXAMPLE"</span><span class="p">,</span>
</span><span id="__span-1-4"><a id="__codelineno-1-4" name="__codelineno-1-4" href="#__codelineno-1-4"></a><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"authenticating"</span><span class="p">,</span>
</span><span id="__span-1-5"><a id="__codelineno-1-5" name="__codelineno-1-5" href="#__codelineno-1-5"></a><span class="w"> </span><span class="nt">"server_account"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span>
</span><span id="__span-1-6"><a id="__codelineno-1-6" name="__codelineno-1-6" href="#__codelineno-1-6"></a><span class="w"> </span><span class="nt">"server_cdm"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span>
</span><span id="__span-1-7"><a id="__codelineno-1-7" name="__codelineno-1-7" href="#__codelineno-1-7"></a><span class="w"> </span><span class="nt">"server_cdm_max_height"</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="p">,</span>
</span><span id="__span-1-8"><a id="__codelineno-1-8" name="__codelineno-1-8" href="#__codelineno-1-8"></a><span class="w"> </span><span class="nt">"server_vault"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span>
</span><span id="__span-1-9"><a id="__codelineno-1-9" name="__codelineno-1-9" href="#__codelineno-1-9"></a><span class="w"> </span><span class="nt">"server_device"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span>
</span><span id="__span-1-10"><a id="__codelineno-1-10" name="__codelineno-1-10" href="#__codelineno-1-10"></a><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<p><code>server_account</code> is <code>true</code> when the server logs in with one of its own accounts
(<code>serve.server_accounts</code>). Otherwise the server uses only what the client sent, and never its own
credentials. The other four fields give the <a href="#licensing-modes">licensing mode</a>.</p>
<p>When the login succeeds and the remote session uses no server account, the login belongs to the
client: the client gets cookies, auth headers and the cache files back. A remote session on the
server's device (lent-device mode) gives the client its cookies, but no auth headers and no cache
files. A server-account remote session sends no cookies and no auth headers, drops secret-looking
keys from track data, and keeps the cache on the server.</p>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>Remote session created; the login runs.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_INPUT</code></td>
<td>No <code>service</code> or <code>title_id</code>, a <code>session_id</code> that is not the canonical text of a version 4 UUID, a bad <code>cache</code>, <code>plugins</code> or <code>preferences</code> value, or a <code>proxy_region</code> that is not a country code.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_PARAMETERS</code></td>
<td>A bad <code>range_</code>, <code>vcodec</code>, <code>quality</code>, <code>dl_params</code> or service option value.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_PROXY</code></td>
<td>A proxy that the API key may not use, or a region that differs from the server's.</td>
</tr>
<tr>
<td><code>403</code></td>
<td><code>SERVER_CDM_CAPPED</code></td>
<td><code>quality</code> asks for more than the licence cap, and the create has no <code>cdm_type</code>.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_SERVICE</code></td>
<td>An unknown service, or one that the API key may not use.</td>
</tr>
<tr>
<td><code>403</code></td>
<td><code>FORBIDDEN</code></td>
<td>Another API key or another IP address has the <code>session_id</code>.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>A <code>DELETE</code> or a newer create with the same <code>session_id</code> ended this create.</td>
</tr>
<tr>
<td><code>409</code></td>
<td><code>SERVER_DRAINING</code></td>
<td>The server drains before a restart.</td>
</tr>
</tbody>
</table>
<h3 id="get-apitunnel"><code>GET /api/tunnel</code><a class="headerlink" href="#get-apitunnel" title="Permanent link">&para;</a></h3>
<p>A WebSocket that a <code>--local-proxy</code> client holds open before its create request. The server gives the
service a SOCKS5 proxy on loopback and sends each connection of that proxy to the client, which makes
it from its own connection and relays the bytes. Only the client dials: the server ignores a request
of the client to open a connection. TLS stays end to end between the server and the service.</p>
<ul>
<li>The first message is <code>{"id": "&lt;tunnel id&gt;"}</code>. The client then sends <code>proxy: "tunnel:&lt;id&gt;"</code> in its
create request.</li>
<li>Each later message is a binary frame: a 4-byte stream ID and a 1-byte kind (open, ok, data, close)
in network byte order, then the data. Source: <code>unshackle/core/tunnel.py</code>.</li>
<li><code>?id=&lt;tunnel id&gt;</code> attaches the client to its tunnel again after a drop. After any close except
code 1000, the tunnel waits 60 seconds for a reconnect. Code 1000 means that the client has
finished, and frees the tunnel at once.</li>
<li>An API key can have 4 tunnels open at once. On an API key with <code>shared: true</code>, the server counts
them for each <code>X-Client-Id</code> value, which the gateway sets.</li>
</ul>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>101</code></td>
<td>-</td>
<td>WebSocket open.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>NOT_FOUND</code></td>
<td>No open tunnel with this <code>id</code> for this API key.</td>
</tr>
<tr>
<td><code>429</code></td>
<td><code>RATE_LIMITED</code></td>
<td>The API key has the maximum number of tunnels open.</td>
</tr>
</tbody>
</table>
<h3 id="get-apitunnelcheck"><code>GET /api/tunnel/check</code><a class="headerlink" href="#get-apitunnelcheck" title="Permanent link">&para;</a></h3>
<p>Look up the exit IP address through the caller's tunnel <code>?id=&lt;tunnel id&gt;</code>, so that the client can
check the route before a real run. <code>unshackle tunnel-test</code> calls it.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="2:1"><input checked="checked" id="__tabbed_2_1" name="__tabbed_2" type="radio" /><div class="tabbed-labels"><label for="__tabbed_2_1">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-2-1"><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"ip"</span><span class="p">:</span><span class="w"> </span><span class="s2">"203.0.113.7"</span><span class="p">,</span><span class="w"> </span><span class="nt">"country"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ca"</span><span class="p">,</span><span class="w"> </span><span class="nt">"ms"</span><span class="p">:</span><span class="w"> </span><span class="mi">412</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>The exit IP address, its country and the lookup time in ms.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>NOT_FOUND</code></td>
<td>No open tunnel with this <code>id</code> for this API key.</td>
</tr>
<tr>
<td><code>424</code></td>
<td><code>INVALID_PROXY</code></td>
<td>No IP lookup got through the tunnel.</td>
</tr>
</tbody>
</table>
<h3 id="get-apisessionsession_idchannel"><code>GET /api/session/{session_id}/channel</code><a class="headerlink" href="#get-apisessionsession_idchannel" title="Permanent link">&para;</a></h3>
<p>The remote session channel: a WebSocket that carries only the messages the server starts, and the client's
answers. Titles, tracks, licences, samples, the segment filter, content key reports, the create and
the delete stay HTTP requests. Pass <code>since=&lt;seq&gt;</code> to get only the log records after that sequence
number.</p>
<p>Each message is a JSON text frame with a <code>type</code> field (<code>ChannelMessage</code>):</p>
<table>
<thead>
<tr>
<th><code>type</code></th>
<th>From</th>
<th>Fields</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>prompt</code></td>
<td>server</td>
<td><code>id</code>, <code>prompt</code>, <code>qr</code></td>
<td>The service asks the user for input. <code>qr</code>, when present, is the text of a QR code to draw with it.</td>
</tr>
<tr>
<td><code>cdm_call</code></td>
<td>server</td>
<td><code>id</code>, <code>call</code></td>
<td>The service calls the client's CDM. <code>call</code> has the shape of <a href="#cdm-calls"><code>cdm_call</code></a>.</td>
</tr>
<tr>
<td><code>log</code></td>
<td>server</td>
<td><code>seq</code>, <code>level</code>, <code>message</code>, <code>ts</code>, <code>qr</code></td>
<td>One record of the service log, as the logs route gives it. <code>qr</code>, when present, is the text of a QR code to draw under the message.</td>
</tr>
<tr>
<td><code>status</code></td>
<td>server</td>
<td><code>status</code>, <code>error</code></td>
<td>The login state, on attach and at each change.</td>
</tr>
<tr>
<td><code>drain</code></td>
<td>server</td>
<td><code>draining</code></td>
<td>The operator started or stopped a drain before a restart.</td>
</tr>
<tr>
<td><code>answer</code></td>
<td>client</td>
<td><code>id</code>, <code>response</code>, <code>error</code></td>
<td>The answer to the <code>prompt</code> or <code>cdm_call</code> with this <code>id</code>. The answer to a CDM call is its JSON object as a string. <code>error</code> says why the client cannot answer a prompt, and the service stops at once.</td>
</tr>
</tbody>
</table>
<p>When the client attaches, the server first sends the log records after <code>since</code>, the drain state, the
prompts and CDM calls that the client did not answer, and the login state. A log record can arrive
twice after a reconnect: the client skips a <code>seq</code> it already has. Each prompt and CDM call goes to one
path only: the remote session channel, or the prompt route.</p>
<p>The server closes the remote session channel with code <code>4404</code> when the remote session ends. The client then
stops reconnecting, and its next request finds the remote session gone. The server sends a ping after
20 seconds without data.</p>
<p>The client uses the polling fallback (the prompt and logs routes, and a keep-alive request to the info
route at a third of <code>expires_in</code>) in these cases:</p>
<ul>
<li>A gateway in front of the server refuses the WebSocket upgrade, or the connection fails, at the
create. The client then polls for the life of the process.</li>
<li>The remote session channel drops. The client polls until it reconnects, with a backoff from 1 to 30
seconds.</li>
</ul>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>101</code></td>
<td>-</td>
<td>WebSocket open.</td>
</tr>
<tr>
<td><code>403</code></td>
<td><code>FORBIDDEN</code></td>
<td>The remote session belongs to another API key or IP address.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>No such remote session.</td>
</tr>
</tbody>
</table>
<h3 id="get-apisessionsession_idprompt"><code>GET /api/session/{session_id}/prompt</code><a class="headerlink" href="#get-apisessionsession_idprompt" title="Permanent link">&para;</a></h3>
<p>The polling fallback of the remote session channel: the login state, and the prompt or CDM call that waits
for the client (<code>PromptReply</code>). A client without the remote session channel polls it every 2 seconds during
the login, and every 0.5 seconds while one of its requests runs service code, so that it takes each
CDM call within the 10 seconds of the pickup.</p>
<div class="language-json highlight"><pre><span></span><code><span id="__span-3-1"><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"authenticating"</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-2"><a id="__codelineno-3-2" name="__codelineno-3-2" href="#__codelineno-3-2"></a><span class="p">{</span><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"pending_input"</span><span class="p">,</span><span class="w"> </span><span class="nt">"prompt"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Enter code: "</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-3"><a id="__codelineno-3-3" name="__codelineno-3-3" href="#__codelineno-3-3"></a><span class="p">{</span><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"pending_input"</span><span class="p">,</span><span class="w"> </span><span class="nt">"prompt"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Scan the code, then press Enter"</span><span class="p">,</span><span class="w"> </span><span class="nt">"qr"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://login.example/scan"</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-4"><a id="__codelineno-3-4" name="__codelineno-3-4" href="#__codelineno-3-4"></a><span class="p">{</span><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"pending_input"</span><span class="p">,</span><span class="w"> </span><span class="nt">"prompt"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"cdm_call"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"op"</span><span class="p">:</span><span class="w"> </span><span class="s2">"challenge"</span><span class="p">,</span><span class="w"> </span><span class="nt">"drm"</span><span class="p">:</span><span class="w"> </span><span class="s2">"widevine"</span><span class="p">,</span><span class="w"> </span><span class="nt">"init_data"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"license_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"OFFLINE"</span><span class="p">,</span><span class="w"> </span><span class="nt">"privacy_mode"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w"> </span><span class="nt">"service_certificate"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-5"><a id="__codelineno-3-5" name="__codelineno-3-5" href="#__codelineno-3-5"></a><span class="p">{</span><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"authenticated"</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-3-6"><a id="__codelineno-3-6" name="__codelineno-3-6" href="#__codelineno-3-6"></a><span class="p">{</span><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"failed"</span><span class="p">,</span><span class="w"> </span><span class="nt">"error"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Invalid credentials"</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
<h4 id="cdm-calls">CDM calls<a class="headerlink" href="#cdm-calls" title="Permanent link">&para;</a></h4>
<p>A <code>cdm_call</code> comes first, in any login state. Its <code>op</code> is <code>challenge</code>, <code>keys</code> (parse a licence and return its keys) or <code>close</code>. The
client answers it with a JSON object in <code>response</code>: <code>{"session": "...", "challenge": "&lt;base64&gt;"}</code> for
<code>challenge</code>, <code>{"keys": [{"kid", "type", "key", "permissions"}]}</code> for <code>keys</code>, <code>{}</code> for <code>close</code>, or
<code>{"error": "..."}</code> when its CDM refuses. A <code>keys</code> answer holds only the Widevine <code>OPERATOR_SESSION</code> and
<code>SIGNING</code> keys, never a content key, and the client refuses a PlayReady <code>keys</code> call. An answered call
stops waiting at once, so a client that polls again at once does not get it two times.</p>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>The login state, and the waiting prompt or CDM call.</td>
</tr>
<tr>
<td><code>403</code></td>
<td><code>FORBIDDEN</code></td>
<td>The remote session belongs to another API key or IP address.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>No such remote session.</td>
</tr>
</tbody>
</table>
<h3 id="post-apisessionsession_idprompt"><code>POST /api/session/{session_id}/prompt</code><a class="headerlink" href="#post-apisessionsession_idprompt" title="Permanent link">&para;</a></h3>
<p>Answer the waiting prompt or CDM call. Body: <code>{ "response": "..." }</code> (<code>PromptAnswer</code>).</p>
<div class="tabbed-set tabbed-alternate" data-tabs="3:1"><input checked="checked" id="__tabbed_3_1" name="__tabbed_3" type="radio" /><div class="tabbed-labels"><label for="__tabbed_3_1">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-4-1"><a id="__codelineno-4-1" name="__codelineno-4-1" href="#__codelineno-4-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"accepted"</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>Answer accepted.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_INPUT</code></td>
<td>No <code>response</code>, or no prompt waits.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>No such remote session.</td>
</tr>
</tbody>
</table>
<h3 id="get-apisessionsession_idlogs"><code>GET /api/session/{session_id}/logs</code><a class="headerlink" href="#get-apisessionsession_idlogs" title="Permanent link">&para;</a></h3>
<p>The polling fallback of the remote session channel: the records of the service's own log (<code>LogsReply</code>).
Pass <code>since=&lt;seq&gt;</code> to get only the records after the last sequence number. The route answers in each
login state, <code>failed</code> too.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="4:1"><input checked="checked" id="__tabbed_4_1" name="__tabbed_4" type="radio" /><div class="tabbed-labels"><label for="__tabbed_4_1">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-5-1"><a id="__codelineno-5-1" name="__codelineno-5-1" href="#__codelineno-5-1"></a><span class="p">{</span>
</span><span id="__span-5-2"><a id="__codelineno-5-2" name="__codelineno-5-2" href="#__codelineno-5-2"></a><span class="w"> </span><span class="nt">"session_id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"d4e5f6a7-..."</span><span class="p">,</span>
</span><span id="__span-5-3"><a id="__codelineno-5-3" name="__codelineno-5-3" href="#__codelineno-5-3"></a><span class="w"> </span><span class="nt">"logs"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span>
</span><span id="__span-5-4"><a id="__codelineno-5-4" name="__codelineno-5-4" href="#__codelineno-5-4"></a><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"seq"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="nt">"level"</span><span class="p">:</span><span class="w"> </span><span class="s2">"INFO"</span><span class="p">,</span><span class="w"> </span><span class="nt">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Signed in as profile 'Main'"</span><span class="p">,</span><span class="w"> </span><span class="nt">"ts"</span><span class="p">:</span><span class="w"> </span><span class="mf">1724990000.1</span><span class="w"> </span><span class="p">},</span>
</span><span id="__span-5-5"><a id="__codelineno-5-5" name="__codelineno-5-5" href="#__codelineno-5-5"></a><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"seq"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="nt">"level"</span><span class="p">:</span><span class="w"> </span><span class="s2">"WARNING"</span><span class="p">,</span><span class="w"> </span><span class="nt">"message"</span><span class="p">:</span><span class="w"> </span><span class="s2">" - The service returned no streams"</span><span class="p">,</span><span class="w"> </span><span class="nt">"ts"</span><span class="p">:</span><span class="w"> </span><span class="mf">1724990002.7</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-5-6"><a id="__codelineno-5-6" name="__codelineno-5-6" href="#__codelineno-5-6"></a><span class="w"> </span><span class="p">],</span>
</span><span id="__span-5-7"><a id="__codelineno-5-7" name="__codelineno-5-7" href="#__codelineno-5-7"></a><span class="w"> </span><span class="nt">"last_seq"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span>
</span><span id="__span-5-8"><a id="__codelineno-5-8" name="__codelineno-5-8" href="#__codelineno-5-8"></a><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<p>The buffer keeps the newest 500 records. Only the logger of the service is copied: the core loggers
stay on the server, and the HTTP requests that the server makes for the service never reach the
client. A server-account remote session sends no log records, because the output of its login can
carry the identity of the operator's account.</p>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>Records, oldest first (an empty list when nothing is new).</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>No such remote session.</td>
</tr>
</tbody>
</table>
<h3 id="get-apisessionsession_idtitles"><code>GET /api/session/{session_id}/titles</code><a class="headerlink" href="#get-apisessionsession_idtitles" title="Permanent link">&para;</a></h3>
<p>The titles of an authenticated remote session (<code>TitlesReply</code>), each in the wire form. A slow answer
arrives as a <a href="#slow-responses">slow response</a>.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="5:1"><input checked="checked" id="__tabbed_5_1" name="__tabbed_5" type="radio" /><div class="tabbed-labels"><label for="__tabbed_5_1">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-6-1"><a id="__codelineno-6-1" name="__codelineno-6-1" href="#__codelineno-6-1"></a><span class="p">{</span>
</span><span id="__span-6-2"><a id="__codelineno-6-2" name="__codelineno-6-2" href="#__codelineno-6-2"></a><span class="w"> </span><span class="nt">"session_id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"d4e5f6a7-..."</span><span class="p">,</span>
</span><span id="__span-6-3"><a id="__codelineno-6-3" name="__codelineno-6-3" href="#__codelineno-6-3"></a><span class="w"> </span><span class="nt">"titles"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"episode"</span><span class="p">,</span><span class="w"> </span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Pilot"</span><span class="p">,</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ep-1"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">]</span>
</span><span id="__span-6-4"><a id="__codelineno-6-4" name="__codelineno-6-4" href="#__codelineno-6-4"></a><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<p><code>collection</code> is present only when the service returned a music collection. It holds the facts of the
collection itself: <code>kind</code>, <code>title</code>, <code>artist</code>, <code>year</code>, <code>total_tracks</code>, <code>total_discs</code>, <code>artwork_url</code>,
<code>total_duration</code>, <code>owner</code> and <code>description</code>, for example
<code>"collection": { "kind": "playlist", "title": "Example Playlist", "total_tracks": 93 }</code>. A fact that
the collection does not have is absent. The client ignores a field of <code>collection</code> that it does not
know, and stops with an error on a value of the wrong type.</p>
<p>The server applies no <code>title_map</code>: the client renames the titles.</p>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>Titles returned.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_INPUT</code></td>
<td>The login state is still <code>authenticating</code>.</td>
</tr>
<tr>
<td><code>401</code></td>
<td><code>AUTH_FAILED</code></td>
<td>The login failed.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>No such remote session.</td>
</tr>
</tbody>
</table>
<h3 id="post-apisessionsession_idtracks"><code>POST /api/session/{session_id}/tracks</code><a class="headerlink" href="#post-apisessionsession_idtracks" title="Permanent link">&para;</a></h3>
<p>The tracks and chapters of one title. Body: <code>{ "title_id": "..." }</code> (<code>TracksRequest</code>). Unlike
<code>list-tracks</code>, each track object here <strong>includes</strong> its download URL. A track that resolves its URL on
use has <code>resolve_url</code> set to <code>true</code> and no URL. A slow answer arrives as a
<a href="#slow-responses">slow response</a>.</p>
<p>The response repeats the title. A service can rewrite title fields in <code>get_tracks</code>, so the client
takes this copy in place of the one from the title list. Each track carries the full local field set.</p>
<p><code>manifests</code> holds each served DASH or ISM manifest one time. One URL can have more than one entry,
for example when a service merges a second manifest under the same URL. <code>track_ids</code> names the tracks
that each entry restores, and the client matches such a track only in the manifest of that entry. For
DASH, <code>filtered_period_ids</code> names the filtered periods, which the download skips.
<code>track_manifests</code> holds a one-track fragment for each track that the manifest cannot identify, such
as an AdaptationSet that the service built itself. The client parses that fragment in place of the
whole manifest. The fragment starts at the period of the track and keeps the content periods after it.</p>
<p><code>hls_playlists</code> holds the media playlist text of each HLS track that the service holds as text, with
the URL of the track. A <code>file:</code> URL is never sent: such an entry has <code>url</code> set to <code>null</code>. The client
keeps an entry only when it parses as a media playlist whose segment URIs are absolute <code>http</code> or
<code>https</code> URLs, for the same URL as its track. Otherwise it logs <code>Refusing track &lt;id&gt;: its HLS playlist ...</code>
and drops the track.</p>
<p>After the manifest parse, the client lays the JSON-safe part of the <code>track.data</code> that the service set
over the parser's values, so a value of the service wins. An attachment that the service wrote to a
file on the server travels as base64, and the client writes it to its own temp directory.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="6:1"><input checked="checked" id="__tabbed_6_1" name="__tabbed_6" type="radio" /><div class="tabbed-labels"><label for="__tabbed_6_1">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-7-1"><a id="__codelineno-7-1" name="__codelineno-7-1" href="#__codelineno-7-1"></a><span class="p">{</span>
</span><span id="__span-7-2"><a id="__codelineno-7-2" name="__codelineno-7-2" href="#__codelineno-7-2"></a><span class="w"> </span><span class="nt">"title"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"episode"</span><span class="p">,</span><span class="w"> </span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Pilot"</span><span class="p">,</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ep-1"</span><span class="w"> </span><span class="p">},</span>
</span><span id="__span-7-3"><a id="__codelineno-7-3" name="__codelineno-7-3" href="#__codelineno-7-3"></a><span class="w"> </span><span class="nt">"video"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"v-1"</span><span class="p">,</span><span class="w"> </span><span class="nt">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"drm"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">],</span>
</span><span id="__span-7-4"><a id="__codelineno-7-4" name="__codelineno-7-4" href="#__codelineno-7-4"></a><span class="w"> </span><span class="nt">"audio"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"a-1"</span><span class="p">,</span><span class="w"> </span><span class="nt">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://..."</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">],</span>
</span><span id="__span-7-5"><a id="__codelineno-7-5" name="__codelineno-7-5" href="#__codelineno-7-5"></a><span class="w"> </span><span class="nt">"subtitles"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"s-1"</span><span class="p">,</span><span class="w"> </span><span class="nt">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://..."</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">],</span>
</span><span id="__span-7-6"><a id="__codelineno-7-6" name="__codelineno-7-6" href="#__codelineno-7-6"></a><span class="w"> </span><span class="nt">"chapters"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"timestamp"</span><span class="p">:</span><span class="w"> </span><span class="s2">"00:00:00.000"</span><span class="p">,</span><span class="w"> </span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Intro"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">],</span>
</span><span id="__span-7-7"><a id="__codelineno-7-7" name="__codelineno-7-7" href="#__codelineno-7-7"></a><span class="w"> </span><span class="nt">"attachments"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"font.ttf"</span><span class="p">,</span><span class="w"> </span><span class="nt">"mime_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"font/ttf"</span><span class="p">,</span><span class="w"> </span><span class="nt">"description"</span><span class="p">:</span><span class="w"> </span><span class="s2">""</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">],</span>
</span><span id="__span-7-8"><a id="__codelineno-7-8" name="__codelineno-7-8" href="#__codelineno-7-8"></a><span class="w"> </span><span class="nt">"manifests"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"dash"</span><span class="p">,</span><span class="w"> </span><span class="nt">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"data"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;base64 zlib xml&gt;"</span><span class="p">,</span><span class="w"> </span><span class="nt">"track_ids"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="s2">"v-1"</span><span class="p">,</span><span class="w"> </span><span class="s2">"a-1"</span><span class="w"> </span><span class="p">],</span><span class="w"> </span><span class="nt">"filtered_period_ids"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="s2">"ad-1"</span><span class="w"> </span><span class="p">]</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">],</span>
</span><span id="__span-7-9"><a id="__codelineno-7-9" name="__codelineno-7-9" href="#__codelineno-7-9"></a><span class="w"> </span><span class="nt">"track_manifests"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"track_id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"s-1"</span><span class="p">,</span><span class="w"> </span><span class="nt">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"dash"</span><span class="p">,</span><span class="w"> </span><span class="nt">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"data"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;base64 zlib xml&gt;"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">],</span>
</span><span id="__span-7-10"><a id="__codelineno-7-10" name="__codelineno-7-10" href="#__codelineno-7-10"></a><span class="w"> </span><span class="nt">"hls_playlists"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"track_id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"v-1"</span><span class="p">,</span><span class="w"> </span><span class="nt">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"data"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;base64 zlib m3u8&gt;"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">],</span>
</span><span id="__span-7-11"><a id="__codelineno-7-11" name="__codelineno-7-11" href="#__codelineno-7-11"></a><span class="w"> </span><span class="nt">"session_headers"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"User-Agent"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="w"> </span><span class="p">},</span>
</span><span id="__span-7-12"><a id="__codelineno-7-12" name="__codelineno-7-12" href="#__codelineno-7-12"></a><span class="w"> </span><span class="nt">"session_cookies"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"sid"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="w"> </span><span class="p">},</span>
</span><span id="__span-7-13"><a id="__codelineno-7-13" name="__codelineno-7-13" href="#__codelineno-7-13"></a><span class="w"> </span><span class="nt">"session_cookie_jar"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"sid"</span><span class="p">,</span><span class="w"> </span><span class="nt">"value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"domain"</span><span class="p">:</span><span class="w"> </span><span class="s2">".example.com"</span><span class="p">,</span><span class="w"> </span><span class="nt">"path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/"</span><span class="p">,</span><span class="w"> </span><span class="nt">"secure"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">],</span>
</span><span id="__span-7-14"><a id="__codelineno-7-14" name="__codelineno-7-14" href="#__codelineno-7-14"></a><span class="w"> </span><span class="nt">"server_cdm"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span>
</span><span id="__span-7-15"><a id="__codelineno-7-15" name="__codelineno-7-15" href="#__codelineno-7-15"></a><span class="w"> </span><span class="nt">"server_cdm_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"widevine"</span><span class="p">,</span>
</span><span id="__span-7-16"><a id="__codelineno-7-16" name="__codelineno-7-16" href="#__codelineno-7-16"></a><span class="w"> </span><span class="nt">"sample_decrypt_tracks"</span><span class="p">:</span><span class="w"> </span><span class="p">[],</span>
</span><span id="__span-7-17"><a id="__codelineno-7-17" name="__codelineno-7-17" href="#__codelineno-7-17"></a><span class="w"> </span><span class="nt">"fairplay_bridge"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span>
</span><span id="__span-7-18"><a id="__codelineno-7-18" name="__codelineno-7-18" href="#__codelineno-7-18"></a><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<p>The remote session fields (<code>TracksReply</code>):</p>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>session_headers</code></td>
<td>The HTTP headers of the service session, which the client merges into its own. A server login sends no secret-looking header.</td>
</tr>
<tr>
<td><code>session_cookie_jar</code></td>
<td>The cookies of the service session, each with its domain, path and <code>secure</code> flag, so that each cookie goes only to its own hosts.</td>
</tr>
<tr>
<td><code>session_cookies</code></td>
<td>The same cookies as names and values only.</td>
</tr>
<tr>
<td><code>server_cdm</code></td>
<td><code>true</code> in a server-CDM remote session.</td>
</tr>
<tr>
<td><code>server_cdm_type</code></td>
<td>The DRM system that a server-CDM licence takes first for the tracks of this title.</td>
</tr>
<tr>
<td><code>sample_decrypt_tracks</code></td>
<td>The IDs of the tracks that the service decrypts itself, through the <code>samples</code> route.</td>
</tr>
<tr>
<td><code>fairplay_bridge</code></td>
<td><code>true</code> when the service licenses FairPlay-only tracks through a bridge on the server.</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>Tracks returned.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_INPUT</code></td>
<td>No <code>title_id</code>, a <code>title_id</code> that is not in the title list, or the login is not complete.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>No such remote session.</td>
</tr>
<tr>
<td><code>422</code></td>
<td><code>DRM_ERROR</code></td>
<td>A track of the title needs a DRM plugin that the client did not list in <code>plugins</code>, or the client sent no <code>plugins</code>.</td>
</tr>
</tbody>
</table>
<h3 id="post-apisessionsession_idsegments"><code>POST /api/session/{session_id}/segments</code><a class="headerlink" href="#post-apisessionsession_idsegments" title="Permanent link">&para;</a></h3>
<p>The download URL, DRM, headers, cookies and track data of the selected tracks. Body:
<code>{ "track_ids": ["v-1", "a-1"] }</code> (<code>SegmentsRequest</code>). A track that the tracks response sent with
<code>resolve_url</code> gets its URL from the service here. The server makes one service call at a time for each
remote session, so parallel requests wait for each other. A slow answer arrives as a
<a href="#slow-responses">slow response</a>.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="7:1"><input checked="checked" id="__tabbed_7_1" name="__tabbed_7" type="radio" /><div class="tabbed-labels"><label for="__tabbed_7_1">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-8-1"><a id="__codelineno-8-1" name="__codelineno-8-1" href="#__codelineno-8-1"></a><span class="p">{</span>
</span><span id="__span-8-2"><a id="__codelineno-8-2" name="__codelineno-8-2" href="#__codelineno-8-2"></a><span class="w"> </span><span class="nt">"tracks"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-8-3"><a id="__codelineno-8-3" name="__codelineno-8-3" href="#__codelineno-8-3"></a><span class="w"> </span><span class="nt">"v-1"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"descriptor"</span><span class="p">:</span><span class="w"> </span><span class="s2">"DASH"</span><span class="p">,</span><span class="w"> </span><span class="nt">"url"</span><span class="p">:</span><span class="w"> </span><span class="s2">"https://..."</span><span class="p">,</span><span class="w"> </span><span class="nt">"drm"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">],</span><span class="w"> </span><span class="nt">"headers"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="nt">"cookies"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="nt">"cookie_jar"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">],</span><span class="w"> </span><span class="nt">"data"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="err">...</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-8-4"><a id="__codelineno-8-4" name="__codelineno-8-4" href="#__codelineno-8-4"></a><span class="w"> </span><span class="p">}</span>
</span><span id="__span-8-5"><a id="__codelineno-8-5" name="__codelineno-8-5" href="#__codelineno-8-5"></a><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<p><code>data</code> has the form of the track <code>data</code> in <code>list-tracks</code>: the JSON-safe part of the <code>track.data</code> that
the service set, without the <code>hls</code>, <code>dash</code> and <code>ism</code> parser keys. <code>cookies</code> gives names and values
only. <code>cookie_jar</code> gives the same cookies with their domain, path and <code>secure</code> flag, in the form of
<code>session_cookie_jar</code>.</p>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>Track details returned.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_INPUT</code></td>
<td>No <code>track_ids</code>, or a value that is not an array of strings.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>TRACK_NOT_FOUND</code></td>
<td>An unknown track ID.</td>
</tr>
</tbody>
</table>
<h3 id="post-apisessionsession_idsegment_filter"><code>POST /api/session/{session_id}/segment_filter</code><a class="headerlink" href="#post-apisessionsession_idsegment_filter" title="Permanent link">&para;</a></h3>
<p>The HLS segments that a service drops (ads, bumpers, dub cards). The server runs the service's own
segment filter over the media playlist of the track and returns only the URIs, so the client drops
the same segments as the service. Body: <code>{ "track_id": "v-1" }</code> (<code>SegmentFilterRequest</code>).
<code>unwanted</code> is <code>null</code> when the track has no filter (<code>SegmentFilterReply</code>). When the server answers with
an error, the client stops the track download. Only a <code>404</code> with no <code>error_code</code>, from a server
that lacks the route, makes the client keep every segment.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="8:1"><input checked="checked" id="__tabbed_8_1" name="__tabbed_8" type="radio" /><div class="tabbed-labels"><label for="__tabbed_8_1">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-9-1"><a id="__codelineno-9-1" name="__codelineno-9-1" href="#__codelineno-9-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"unwanted"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"https://cdn.example/hls/ad1.ts"</span><span class="p">]</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>Unwanted segment URIs, or <code>null</code>.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_INPUT</code></td>
<td>No <code>track_id</code>.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>TRACK_NOT_FOUND</code></td>
<td>An unknown track ID.</td>
</tr>
<tr>
<td><code>422</code></td>
<td><code>SERVICE_ERROR</code></td>
<td>The playlist request or the filter failed.</td>
</tr>
</tbody>
</table>
<h3 id="post-apisessionsession_idsamples"><code>POST /api/session/{session_id}/samples</code><a class="headerlink" href="#post-apisessionsession_idsamples" title="Permanent link">&para;</a></h3>
<p>Decrypt the samples of a track that the service decrypts itself after the download. The tracks
response lists those track IDs in <code>sample_decrypt_tracks</code>. The client downloads the file, then sends
the samples of each <code>stsd</code> sample entry here, and writes the plaintexts back in place. This is the one
route that carries media bytes. The query string names the track and the 1-based entry:
<code>?track_id=a-1&amp;entry=2</code>.</p>
<ul>
<li>An empty body asks how the entry decrypts. The JSON response is <code>{ "key": "&lt;hex&gt;" }</code>, which the
client then uses itself, or <code>{ "decrypter": true }</code>.</li>
<li>An <code>application/octet-stream</code> body is a sample frame: a big-endian <code>uint32</code> count, one <code>uint32</code>
length for each sample, then the samples. Each sample is a ciphertext cut to whole AES blocks. The
response is a frame of the same shape with the plaintexts in the same order.</li>
</ul>
<p>The client sends at most 8 MiB of samples in one request, and the route accepts a body of up to
16 MiB. The server does not compress the frames. The route needs the <code>server_cdm</code> grant for the
service, whatever the licensing mode, because the decrypter can use a process or an account of the
server.</p>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>The content key, <code>decrypter</code>, or the plaintext frame.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_INPUT</code></td>
<td>No <code>track_id</code>, a bad <code>entry</code>, a malformed frame, or a track that the service does not decrypt.</td>
</tr>
<tr>
<td><code>403</code></td>
<td><code>FORBIDDEN</code></td>
<td>The API key has no <code>server_cdm</code> grant for the service.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>TRACK_NOT_FOUND</code></td>
<td>An unknown track ID.</td>
</tr>
<tr>
<td><code>413</code></td>
<td>-</td>
<td>The body is larger than 16 MiB.</td>
</tr>
<tr>
<td><code>422</code></td>
<td><code>SERVICE_ERROR</code></td>
<td>The decrypter of the service failed.</td>
</tr>
</tbody>
</table>
<h3 id="post-apisessionsession_idlicense"><code>POST /api/session/{session_id}/license</code><a class="headerlink" href="#post-apisessionsession_idlicense" title="Permanent link">&para;</a></h3>
<p>A licence relay, a service certificate, or the content keys of the server CDM (<code>LicenseRequest</code> and
<code>LicenseReply</code>). <code>mode</code> selects one of two modes. A slow answer arrives as a
<a href="#slow-responses">slow response</a>.</p>
<p><strong>Relay mode</strong> (<code>mode: "proxy"</code>, the default) sends the client's CDM <code>challenge</code> to the licence
endpoint of the service and returns the raw licence bytes. A Widevine licence or certificate that the
service returns as Base64 text arrives decoded, as raw bytes in Base64. <code>is_certificate: true</code> asks
for the service certificate in place of a licence.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="9:2"><input checked="checked" id="__tabbed_9_1" name="__tabbed_9" type="radio" /><input id="__tabbed_9_2" name="__tabbed_9" type="radio" /><div class="tabbed-labels"><label for="__tabbed_9_1">Request</label><label for="__tabbed_9_2">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-10-1"><a id="__codelineno-10-1" name="__codelineno-10-1" href="#__codelineno-10-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"track_id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"v-1"</span><span class="p">,</span><span class="w"> </span><span class="nt">"challenge"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;base64 CDM challenge&gt;"</span><span class="p">,</span><span class="w"> </span><span class="nt">"drm_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"widevine"</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
</div>
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-11-1"><a id="__codelineno-11-1" name="__codelineno-11-1" href="#__codelineno-11-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"license"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;base64 licence bytes&gt;"</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<p><strong>Server-CDM mode</strong> (<code>mode: "server_cdm"</code>) licenses on the server with the device of the API key and
returns the content keys. Use <code>track_id</code> for one track or <code>track_ids</code> for a batch. The server vault
answers first. In a client-device or lent-device remote session with <code>server_vault</code>, this mode
answers only from the server vault.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="10:2"><input checked="checked" id="__tabbed_10_1" name="__tabbed_10" type="radio" /><input id="__tabbed_10_2" name="__tabbed_10" type="radio" /><div class="tabbed-labels"><label for="__tabbed_10_1">Single: Response <code>200</code></label><label for="__tabbed_10_2">Batch: Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-12-1"><a id="__codelineno-12-1" name="__codelineno-12-1" href="#__codelineno-12-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"keys"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"&lt;kid_hex&gt;"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;key_hex&gt;"</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="nt">"vault_keys"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"&lt;kid_hex&gt;"</span><span class="p">],</span><span class="w"> </span><span class="nt">"drm_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"widevine"</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
</div>
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-13-1"><a id="__codelineno-13-1" name="__codelineno-13-1" href="#__codelineno-13-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"keys"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"v-1"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"&lt;kid_hex&gt;"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;key_hex&gt;"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="nt">"vault_keys"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"&lt;kid_hex&gt;"</span><span class="p">],</span><span class="w"> </span><span class="nt">"drm_type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"widevine"</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>track_id</code> / <code>track_ids</code></td>
<td>One track, or a batch of tracks.</td>
</tr>
<tr>
<td><code>challenge</code></td>
<td>The base64 CDM challenge (relay mode).</td>
</tr>
<tr>
<td><code>pssh</code></td>
<td>A base64 PSSH. Server-CDM mode licenses this PSSH, but only when its KIDs are KIDs of the track. Relay mode gives it to the licence callback of the service as <code>pssh</code> (Widevine) or <code>pssh_b64</code> (PlayReady), the PSSH of the header that the challenge is for. A relay-mode PSSH that names a KID that the track does not carry goes to no callback.</td>
</tr>
<tr>
<td><code>kid</code></td>
<td>The KID that the client found for the track, for the server vault lookup of a single track.</td>
</tr>
<tr>
<td><code>drm_type</code></td>
<td><code>widevine</code> (default), <code>playready</code>, or the id of a DRM plugin that both peers load. In server-CDM mode the server's <code>cdm</code> mapping for the service decides the DRM system, and the response <code>drm_type</code> names the system that licensed. A mapping with a device for each system takes the system of the device that the remote session loaded. With no mapping, the client's value decides when the track carries that system; else a system that the track carries decides, PlayReady first. A track whose DRM is a whole-file cipher takes <code>clearkeyctr</code> with no <code>pssh</code>: the service on the server licenses it. A track of a DRM plugin that licenses locally takes the plugin id with no <code>pssh</code> and <code>mode</code> <code>server_cdm</code>: the server answers in <code>keys</code> with the content key from a server vault or from a licence of its own plugin device, only in a server-CDM remote session, and only under the licence cap.</td>
</tr>
<tr>
<td><code>mode</code></td>
<td><code>proxy</code> (default) or <code>server_cdm</code>.</td>
</tr>
<tr>
<td><code>is_certificate</code></td>
<td><code>true</code> for a service certificate request (relay mode).</td>
</tr>
<tr>
<td><code>keys</code> (response)</td>
<td>KID to content key for <code>track_id</code>, or track ID to that map for <code>track_ids</code>.</td>
</tr>
<tr>
<td><code>vault_keys</code> (response)</td>
<td>The KIDs whose content key came from a server vault, not the CDM. The client proves such a content key with a decode before it trusts it. Absent when each content key came from the CDM.</td>
</tr>
<tr>
<td><code>capped_tracks</code> (response)</td>
<td>For a batch: the tracks above the licence cap, each with <code>reason</code> and <code>max_height</code>. They get no content keys, and the client licenses them with its own device.</td>
</tr>
<tr>
<td><code>clear_tracks</code> (response)</td>
<td>The requested track IDs that carry no DRM, so they have no keys. Absent when each requested track is encrypted.</td>
</tr>
<tr>
<td><code>file_keys</code> (response)</td>
<td>The content keys of whole-file ciphers, by track ID. Absent when no requested track holds such a cipher.</td>
</tr>
<tr>
<td><code>bridge_kids</code> (response)</td>
<td>For a batch: the KIDs of the init segments of each FairPlay-only track that the server licensed through the FairPlay bridge, by track ID. The client needs the content key of each of these KIDs, or the download of that track stops.</td>
</tr>
<tr>
<td><code>drm_type</code> / <code>drm_types</code> (response)</td>
<td>The DRM system that licensed, for the request or for each track. The client takes it for its next call.</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>Licence or content keys returned.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_INPUT</code></td>
<td>No <code>track_id</code>, no challenge or PSSH, a PSSH that is not a valid PSSH box, or no CDM device for the API key.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_PARAMETERS</code></td>
<td>An unsupported <code>drm_type</code>.</td>
</tr>
<tr>
<td><code>403</code></td>
<td><code>FORBIDDEN</code></td>
<td>Server-CDM mode in a remote session that the server CDM does not license and that cannot read the server vault, or a PSSH with a KID that the track does not carry.</td>
</tr>
<tr>
<td><code>403</code></td>
<td><code>SERVER_CDM_CAPPED</code></td>
<td>A single track that the server does not license live. <code>details.reason</code> is <code>server_cdm_max_height</code> (above the licence cap, with <code>max_height</code>), <code>client_device</code> (a client-device remote session), or <code>server_device</code> (a lent-device remote session, for a track that no vault holds).</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>TRACK_NOT_FOUND</code></td>
<td>An unknown track ID.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>NO_CONTENT</code></td>
<td>The server CDM returned no content keys.</td>
</tr>
<tr>
<td><code>422</code></td>
<td><code>SERVICE_ERROR</code></td>
<td>The service failed during licensing.</td>
</tr>
<tr>
<td><code>422</code></td>
<td><code>DRM_ERROR</code></td>
<td>The server could not license the track.</td>
</tr>
</tbody>
</table>
<h3 id="post-apisessionsession_idkeys"><code>POST /api/session/{session_id}/keys</code><a class="headerlink" href="#post-apisessionsession_idkeys" title="Permanent link">&para;</a></h3>
<p>Store the content keys that the client proved on a track and that the server did not serve to this
remote session (<code>TrackKeys</code>). The server stores a content key only for a KID that a track of the
remote session names and that no local server vault holds a content key for. It never stores a pair
flagged bad, and it never removes a flag. The server answers when its local vaults hold the pairs,
and sends them to its other vaults after the answer. The client sends each content key of a licence when the
licence returns, and each vault key after its decode check passes. A licence key of a FairPlay-only
track that the client licensed through the bridge goes only after its decode check passes, so a client
without FFmpeg does not send it.</p>
<div class="language-json highlight"><pre><span></span><code><span id="__span-14-1"><a id="__codelineno-14-1" name="__codelineno-14-1" href="#__codelineno-14-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"track_id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;track_id&gt;"</span><span class="p">,</span><span class="w"> </span><span class="nt">"keys"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"&lt;kid_hex&gt;"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;key_hex&gt;"</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td><code>{}</code>, whatever the server stored.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>No such remote session.</td>
</tr>
</tbody>
</table>
<h3 id="post-apisessionsession_idkeysbad"><code>POST /api/session/{session_id}/keys/bad</code><a class="headerlink" href="#post-apisessionsession_idkeysbad" title="Permanent link">&para;</a></h3>
<p>Report a content key from <code>vault_keys</code> that did not decrypt the track (<code>BadKeyReport</code>). The server
flags the pair in each local vault that it holds and reports it to the vault that served it, and the
next licence for that KID reaches the CDM. When the CDM returns the same pair, the server removes the
flag, because then the check of the client was wrong. A server with no local SQLite vault cannot store
the flag. The server accepts a report only for a pair that it served to that remote session. The
client never learns the server vault names.</p>
<div class="language-json highlight"><pre><span></span><code><span id="__span-15-1"><a id="__codelineno-15-1" name="__codelineno-15-1" href="#__codelineno-15-1"></a><span class="p">{</span><span class="w"> </span><span class="nt">"kid"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;kid_hex&gt;"</span><span class="p">,</span><span class="w"> </span><span class="nt">"key"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;key_hex&gt;"</span><span class="w"> </span><span class="p">}</span>
</span></code></pre></div>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td><code>{"flagged": true}</code>: the pair is flagged. <code>{"flagged": false}</code>: the CDM licensed the pair, so it is not flagged.</td>
</tr>
<tr>
<td><code>400</code></td>
<td><code>INVALID_INPUT</code></td>
<td>This remote session was not served that pair.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>No such remote session.</td>
</tr>
</tbody>
</table>
<h3 id="get-apisessionsession_id"><code>GET /api/session/{session_id}</code><a class="headerlink" href="#get-apisessionsession_id" title="Permanent link">&para;</a></h3>
<p>Remote session info (<code>SessionInfo</code>). The client also uses it as the keep-alive of the polling
fallback.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="11:1"><input checked="checked" id="__tabbed_11_1" name="__tabbed_11" type="radio" /><div class="tabbed-labels"><label for="__tabbed_11_1">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-16-1"><a id="__codelineno-16-1" name="__codelineno-16-1" href="#__codelineno-16-1"></a><span class="p">{</span>
</span><span id="__span-16-2"><a id="__codelineno-16-2" name="__codelineno-16-2" href="#__codelineno-16-2"></a><span class="w"> </span><span class="nt">"session_id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"d4e5f6a7-..."</span><span class="p">,</span>
</span><span id="__span-16-3"><a id="__codelineno-16-3" name="__codelineno-16-3" href="#__codelineno-16-3"></a><span class="w"> </span><span class="nt">"service"</span><span class="p">:</span><span class="w"> </span><span class="s2">"EXAMPLE"</span><span class="p">,</span>
</span><span id="__span-16-4"><a id="__codelineno-16-4" name="__codelineno-16-4" href="#__codelineno-16-4"></a><span class="w"> </span><span class="nt">"valid"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span>
</span><span id="__span-16-5"><a id="__codelineno-16-5" name="__codelineno-16-5" href="#__codelineno-16-5"></a><span class="w"> </span><span class="nt">"expires_in"</span><span class="p">:</span><span class="w"> </span><span class="mi">300</span><span class="p">,</span>
</span><span id="__span-16-6"><a id="__codelineno-16-6" name="__codelineno-16-6" href="#__codelineno-16-6"></a><span class="w"> </span><span class="nt">"draining"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span>
</span><span id="__span-16-7"><a id="__codelineno-16-7" name="__codelineno-16-7" href="#__codelineno-16-7"></a><span class="w"> </span><span class="nt">"track_count"</span><span class="p">:</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span>
</span><span id="__span-16-8"><a id="__codelineno-16-8" name="__codelineno-16-8" href="#__codelineno-16-8"></a><span class="w"> </span><span class="nt">"title_count"</span><span class="p">:</span><span class="w"> </span><span class="mi">10</span>
</span><span id="__span-16-9"><a id="__codelineno-16-9" name="__codelineno-16-9" href="#__codelineno-16-9"></a><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<p><code>expires_in</code> is the configured <code>session_ttl</code>, not the seconds that remain for this remote session.
<code>draining</code> is <code>true</code> after the operator starts a drain before a restart. The client checks it before
each title.</p>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>Info returned.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>No such remote session, or it expired.</td>
</tr>
</tbody>
</table>
<h3 id="delete-apisessionsession_id"><code>DELETE /api/session/{session_id}</code><a class="headerlink" href="#delete-apisessionsession_id" title="Permanent link">&para;</a></h3>
<p>End a remote session (<code>SessionClosed</code>). The server cancels the waiting prompts and CDM calls, collects
the changed cache files, and deletes the remote session and its cache directory. A create of the same
API key and IP address that still runs under this ID ends too: it makes no remote session and answers
<code>404 SESSION_NOT_FOUND</code>. When the <code>DELETE</code> ends such a create, it answers <code>200</code> with no <code>cache</code>.</p>
<div class="tabbed-set tabbed-alternate" data-tabs="12:1"><input checked="checked" id="__tabbed_12_1" name="__tabbed_12" type="radio" /><div class="tabbed-labels"><label for="__tabbed_12_1">Response <code>200</code></label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="language-json highlight"><pre><span></span><code><span id="__span-17-1"><a id="__codelineno-17-1" name="__codelineno-17-1" href="#__codelineno-17-1"></a><span class="p">{</span>
</span><span id="__span-17-2"><a id="__codelineno-17-2" name="__codelineno-17-2" href="#__codelineno-17-2"></a><span class="w"> </span><span class="nt">"status"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ok"</span><span class="p">,</span>
</span><span id="__span-17-3"><a id="__codelineno-17-3" name="__codelineno-17-3" href="#__codelineno-17-3"></a><span class="w"> </span><span class="nt">"cache"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="nt">"tokens"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;base64 zlib bytes&gt;"</span><span class="p">,</span><span class="w"> </span><span class="nt">"session_web/&lt;sha1&gt;"</span><span class="p">:</span><span class="w"> </span><span class="s2">"&lt;base64 zlib bytes&gt;"</span><span class="w"> </span><span class="p">}</span>
</span><span id="__span-17-4"><a id="__codelineno-17-4" name="__codelineno-17-4" href="#__codelineno-17-4"></a><span class="p">}</span>
</span></code></pre></div>
</div>
</div>
</div>
<p><code>cache</code> is present only when the remote session made cache files and the login belongs to the client
in a remote session that does not run on the server's device. It holds every file of the cache
directory of the remote session except the <code>titles_*</code> files. See <a href="#cache-files">Cache files</a>.</p>
<table>
<thead>
<tr>
<th>Status</th>
<th>Error code</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>200</code></td>
<td>-</td>
<td>Remote session ended.</td>
</tr>
<tr>
<td><code>404</code></td>
<td><code>SESSION_NOT_FOUND</code></td>
<td>No such remote session.</td>
</tr>
</tbody>
</table>
<hr />
<h2 id="cache-files">Cache files<a class="headerlink" href="#cache-files" title="Permanent link">&para;</a></h2>
<p>A cache key is the file path relative to the service cache directory, with <code>/</code> separators and no
<code>.json</code> suffix: the <code>Cacher</code> cache key that the service reads it with. A file in a subdirectory, such as
<code>session_web/&lt;sha1&gt;</code>, keeps its place. The value is the file, zlib-compressed and base64-encoded.</p>
<ul>
<li>Both sides refuse a cache key with a drive letter, a root, a <code>..</code> segment, an empty segment, or more
than 8 segments, before it becomes a path.</li>
<li>Both sides refuse a <code>cache</code> map with more than 256 entries. The server refuses a map whose files
inflate to more than 16 MiB in total with <code>400 INVALID_INPUT</code>, before it writes a file. The client
gives a warning when it has more to send, and stops saving the returned files at 16 MiB.</li>
<li>Both sides refuse a cache file that is not JSON, or that names a type other than a date or time. The
service then logs in again.</li>
<li>The server skips a cache key that it cannot write, such as one that names an existing file as a
directory, and logs a warning.</li>
</ul>
<p>Each remote session gets its own cache directory, named by a hash of the API key and a new UUID, so a
remote session cannot read the cache of another. A create that takes over a <code>session_id</code> never shares
the directory of the one before it. A remote session that uses a server account gets a lasting cache
for each account instead. A service can name the cache files that hold its device identity in
<code>Service.IDENTITY_CACHE</code>. A remote session on the server's device, or of an API key with its own device
config, keeps those files in a directory of the API key, so the server never sends them to a client
and never takes them from one.</p>
<h2 id="security-properties">Security properties<a class="headerlink" href="#security-properties" title="Permanent link">&para;</a></h2>
<p>The API key and owner check is in <a href="#conventions">Conventions</a>, the tunnel rules are in
<a href="#get-apitunnel"><code>GET /api/tunnel</code></a>, and the secrets that stay on the server are in the
<a href="#post-apisessioncreate">create response</a>. In addition:</p>
<ul>
<li><strong>A tunnel proxy needs its own credentials.</strong> The SOCKS5 proxy of a tunnel listens on loopback
only, and needs a username and password for that tunnel, so a raw <code>socks5h://127.0.0.1:&lt;port&gt;</code>
proxy from a client fails.</li>
<li><strong>One log line for each record.</strong> The server strips control characters from each user value
before it logs it, so a client cannot forge a log record.</li>
</ul>
</article>
</div>
<script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
</div>
<button type="button" class="md-top md-icon" data-md-component="top" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg>
Back to top
</button>
</main>
<footer class="md-footer">
<nav class="md-footer__inner md-grid" aria-label="Footer" >
<a href="../errors/" class="md-footer__link md-footer__link--prev" aria-label="Previous: Error Responses">
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
</div>
<div class="md-footer__title">
<span class="md-footer__direction">
Previous
</span>
<div class="md-ellipsis">
Error Responses
</div>
</div>
</a>
<a href="../../../reference/api/service/" class="md-footer__link md-footer__link--next" aria-label="Next: Service">
<div class="md-footer__title">
<span class="md-footer__direction">
Next
</span>
<div class="md-ellipsis">
Service
</div>
</div>
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11z"/></svg>
</div>
</a>
</nav>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"annotate": null, "base": "../../..", "features": ["content.code.annotate", "content.code.copy", "content.tabs.link", "content.tooltips", "navigation.footer", "navigation.indexes", "navigation.sections", "navigation.tabs", "navigation.top", "navigation.tracking", "search.highlight", "search.share", "search.suggest", "toc.follow"], "search": "../../../assets/javascripts/workers/search.a7633da7.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script>
<script src="../../../assets/javascripts/bundle.a5f9d56c.min.js"></script>
</body>
</html>