Clavem

Check for updates and download builds from a Unity game

Send GET /v1/releases/:productId/latest with your license key in the X-License-Key header, compare the version with Application.version, and ask again for a fresh link when the player clicks Update. A running Windows game cannot replace itself, so hand the file to an installer.

What the endpoint gives a game

GET /v1/releases/:productId/latest returns the newest published release. Add platform to get only that platform’s files plus unlabeled ones. With a valid key each file carries a signed url, good for one hour. Without one you get version and published_at. If the product has no published release, the answer is 404, which I captured from the live API on 19 November 2026:

GET /v1/releases/75/latest   X-License-Key: S1GNE-TDEM0-7K4QX-9WZ2P-H5RB8
404  {"error":{"code":"not_found","message":"This product has no published release yet."}}

Releases use the platform labels you picked when you uploaded. windows, macos and linux map straight to RuntimePlatform.

Check, compare, download

using System;
using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;

[Serializable] public class ReleaseFile { public int id; public string filename; public long size; public string platform; public string url; }
[Serializable] public class ReleaseInfo { public string version; public string notes; public string published_at; public ReleaseFile[] files; }

public static class UpdateChecker
{
    const string Base = "https://clavem.io";
    const int ProductId = 75; // from your product page

    static string PlatformLabel()
    {
        switch (Application.platform)
        {
            case RuntimePlatform.WindowsPlayer: return "windows";
            case RuntimePlatform.OSXPlayer: return "macos";
            case RuntimePlatform.LinuxPlayer: return "linux";
            default: return null; // the Editor, WebGL, mobile and consoles update elsewhere
        }
    }

    /// done(release) when a newer build exists, otherwise done(null).
    /// Files carry a url only for a license that may download.
    public static IEnumerator Check(string licenseKey, Action<ReleaseInfo> done)
    {
        string label = PlatformLabel();
        if (label == null) { done(null); yield break; }

        using (var req = UnityWebRequest.Get(Base + "/v1/releases/" + ProductId + "/latest?platform=" + label))
        {
            req.SetRequestHeader("X-License-Key", licenseKey); // the header keeps the key out of URLs and logs
            req.timeout = 8;
            yield return req.SendWebRequest();

            if (req.responseCode != 200) { done(null); yield break; } // 404 nothing published, 429 Retry-After 60
            ReleaseInfo info = null;
            try { info = JsonUtility.FromJson<ReleaseInfo>(req.downloadHandler.text); } catch (ArgumentException) { }
            done(info != null && IsNewer(info.version, Application.version) ? info : null);
        }
    }

    static bool IsNewer(string latest, string current)
    {
        // System.Version cannot parse "4.0.0-beta.2", so compare the numeric part and handle prereleases by hand.
        if (!TryParse(latest, out var a) || !TryParse(current, out var b)) return false;
        bool latestPre = latest.IndexOf('-') >= 0, currentPre = current.IndexOf('-') >= 0;
        if (latestPre && !currentPre) return false; // a beta never replaces a stable install
        return a > b || (a == b && currentPre && !latestPre);
    }

    static bool TryParse(string s, out Version v)
    {
        int cut = s.IndexOfAny(new[] { '-', '+' });
        return Version.TryParse(cut < 0 ? s : s.Substring(0, cut), out v);
    }

    /// Streams the file to disk without holding it in memory. Fetch a fresh link first.
    public static IEnumerator Download(ReleaseFile file, Action<float> progress, Action<string> done)
    {
        string path = Path.Combine(Application.persistentDataPath, Path.GetFileName(file.filename));
        using (var req = UnityWebRequest.Get(file.url))
        {
            req.downloadHandler = new DownloadHandlerFile(path) { removeFileOnAbort = true };
            var op = req.SendWebRequest();
            while (!op.isDone) { progress(req.downloadProgress); yield return null; } // yields every frame, so it does not block
            done(req.result == UnityWebRequest.Result.Success ? path : null);
        }
    }
}

On Click, call Check again and take the first file that has a url. Do not reuse the response from launch. Application.version is the Bundle Version in Player Settings, so keep that in step with the version you publish.

Latest means last published

If you publish a 1.4.2 backport after 1.5.0, the endpoint returns 1.4.2. The check above only offers a build that is newer than the installed one, so a 1.5.0 player is not offered a downgrade. Unpublishing a bad build makes the previous release the latest again, and your game stops offering the bad one.

Applying the update

Clavem stores and serves your files. It has no updater, no delta patches, and the release response carries no checksum, so integrity checks are yours to add. What the player’s machine does next is a Unity question:

  • Windows. A running executable cannot be overwritten. Run the downloaded installer with System.Diagnostics.Process.Start(path), then call Application.Quit(). Or ship a small launcher that owns the download and starts the game.
  • macOS and Linux. Open the disk image or archive for the player. The least risky route is Application.OpenURL(file.url), which hands the link to the browser. It also gives a long download the browser’s pause and resume, which DownloadHandlerFile does not.
  • WebGL. You deploy the new build to your server. There is nothing to fetch.
  • Mobile. The stores deliver updates.

Editor tools sold directly

An editor extension can use the same endpoint. Label the file unitypackage, run the request from an editor window, and import the result. Coroutines are unreliable in edit mode, so use the completion callback:

var op = req.SendWebRequest();
op.completed += _ =>
{
    // parse, pick a file, download it to a temp path, then:
    UnityEditor.AssetDatabase.ImportPackage(tempPath, true); // interactive: the user sees what is imported
};

Rate limits

The endpoint allows 120 requests a minute per IP address, counted apart from validation. A studio network can share one IP across many machines, so check once per launch, or once a day with the time kept in your license file. A 429 carries Retry-After: 60: say nothing and try next launch.

Doing this with Clavem

Upload a build per platform on the product page, label it, and publish. Players with an order page download from there too. Endpoint details and limits are in Releases and downloads, and the key check that gates links is in validation in Unity.

Questions

Why not request the download link at launch?

Links are signed and valid for one hour. A prompt that sits on screen, or a player who clicks Update later, would hit an expired link. Check the version at launch and fetch the link when the player clicks.

What does the endpoint return for an expired license?

Only version and published_at. Notes and file links come back only for a license of this product that is neither expired nor disabled, so you can still say an update exists and send the player to renew.

Sources

  1. Unity scripting API, Application.version (checked November 2026)
  2. Unity scripting API, DownloadHandlerFile (checked November 2026)