# Upgrade and provisioning


The Soundtrack Player Library is provisioned by our build systems. This allows for controlled and staggered rollouts, ensuring stability and targeted updates.

During the integration process, our team will provide you with a unique API endpoint for your platform. We refer to this endpoint as a **release channel**. This channel provides the versioning information and a download link for the Player Library built for your toolchain.

## Automatic update requirements

To comply with our [6-month support lifecycle](/sdk/concepts/release-management), your application must implement an automatic updater that performs the following:

- **Poll for updates periodically**: Your application **must poll** the release channel every 15 minutes to check for new versions.

- **Verify and apply updates**: The updater must download the new Player Library, verify its checksum and have a strategy to replace the old library.

## Release channel response

A successful request will return a JSON object with the following structure:

```json
{
  "id": "...",
  "version": "48.17-308",
  "link": "https://download.link.com/...",
  "checksum": "9e12bb0ded21711ea1c666dc776b2751febcc01f",
  "platform": "splayer-x86_64"
}
```

- The `version` field indicates the latest available version string.

- The `link` field provides a URL to download the Player Library.

- The `checksum` is a SHA-1 hash of the file from the link. You must verify that the checksum of your downloaded file matches this value to ensure its integrity.

The remaining fields can be ignored by the implemented updater.

:::note
The version corresponds to our quarterly release schedule; for more information, see [Release management](/sdk/concepts/release-management).
:::

## Implementation steps

The [reference app](/sdk/reference-app#automatic-updater) in the SDK package includes an updater we wrote in C, `src/updater.c`, which you are free to use and modify. The reference app page also lists what you need to add to it before it meets every requirement on this page. In general, your updater should work as follows:

1. **Query the release channel**: Send an HTTP `GET` request to your release channel with the required headers.

2. **Compare versions**: Parse the `version` from the JSON response and compare it with the version of the currently running library. If they are the same, no action is needed.

3. **Download**: If the versions differ, download the Player Library from the link provided.

4. **Verify checksum**: After downloading, calculate the SHA-1 hash of the file and confirm it matches the checksum from the JSON response. This step is mandatory. If the checksums do not match, discard the file.

5. **Apply update**: If the checksum is valid, the new library file should replace the old one. To avoid disrupting active playback, this process must be handled gracefully. The application should signal the SDK to quit at the end of the current track by calling `request_exit` with the value `SPLAYER_EXIT_UPGRADE` from the `splayer_exit_t` enum. Once the application has exited, apply the update by replacing the library file, and restart. After restarting, playback should resume as normal.

6. **Restore state and fall back**: Certification also requires that the restarted player restores the playback state it had before the update (playing or paused), and that the updater falls back to the previous library version if installation fails. See tests 3.3 and 3.4 in [SDK certification](/sdk/certification/certification#30-automatic-updater). To start a player paused, use `set_initially_paused` from the options API (see the [changelog](/sdk/changelog)).

### Required HTTP headers

Your request must include the following headers:

- `X-Device-Key-0`: always with value `eth0`.
- `X-Device-Id-0`: Device ID. Every device is assigned one once it has been [connected](/sdk/concepts/pairing) to a sound zone.
  In the example below the Device ID is `28cfe91fcc6d`. If the device is not connected, you can omit this header.

```
X-Device-Key-0:eth0
X-Device-Id-0:28cfe91fcc6d
```

### Example of adding HTTP headers with cURL

```c
char buf[1024];
snprintf(buf, sizeof(buf), "X-Device-Id-0:%s", device_id);

struct curl_slist *chunk = NULL;
chunk = curl_slist_append(chunk, "Accept:");
chunk = curl_slist_append(chunk, "X-Device-Key-0:eth0");
chunk = curl_slist_append(chunk, buf);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
```
