Skip to content

BuiltByBit ​

BuiltByBit's External license key placeholder asks SunLicense for a key every time someone downloads your resource and writes it into the file. Each buyer gets their own key, the same one on every re-download, and you never send anything by hand.

1. Connect it in SunLicense ​

Integrations → BuiltByBit → Connect. Map your resource ID (the number at the end of the resource URL) to a policy, or leave * for all your resources. SunLicense creates a secret for you.

2. Create the placeholder on BuiltByBit ​

  1. Creator dashboard → Placeholders → Create placeholder.
  2. Placeholder: a unique string, e.g. %%__SUNLICENSE__%%.
  3. Type: External license key.
  4. URL: the hook URL from the integration page.
  5. Secret: the secret from the integration page.
  6. Apply it to your resources, then publish an update: placeholders only apply to files uploaded after they exist.

3. Read the key in your plugin ​

java
// BuiltByBit replaces this string with the buyer's SunLicense key when they download.
private static final String LICENSE_KEY = "%%__SUNLICENSE__%%";

@Override
public void onEnable() {
    SunLicense client = new SunLicense.Builder()
            .baseUrl("https://api.sunlicense.com")
            .token(API_KEY)                         // an API key from the API keys page
            .build();
    String serverId = getServer().getIp() + ":" + getServer().getPort();
    if (!client.validate(LICENSE_KEY, Map.of("host", serverId)).isValid()) {
        getLogger().severe("This copy is not licensed. Contact the author.");
        getServer().getPluginManager().disablePlugin(this);
    }
}

The policy's machine limit now applies per buyer: with 2 machines, a buyer's key works on two servers. If their jar leaks, open the license (the event log links to it, named BuiltByBit user 4242) and Revoke: every copy of that jar stops validating within seconds.

Optional: create the license at purchase time ​

The placeholder creates the license on the first download. To have it exist from the moment of purchase, add a webhook: Creator dashboard → Webhooks → Create webhook, trigger Purchase, method POST, content type JSON, URL = the same hook URL, and this custom body (the integration page fills in your secret):

json
{"event":"purchase","secret":"<your secret>","user_id":"{user_id}","username":"{username}","resource_id":"{resource_id}"}

What SunLicense receives ​

FieldUsed for
secretMust equal the integration's secret, or the request is refused (401)
user_id, resource_idOne license per buyer per resource; resource_id picks the policy
version_id, version_number, steam_id, builtbybitIgnored

SunLicense answers with the key as plain text. On any problem (wrong secret, unmapped resource, plan limit) it answers with an error status, and BuiltByBit fills the placeholder with its "contact the creator" message instead of an error text.

Before you announce it

BuiltByBit doesn't publish the exact reply format it expects from an external license server. Do one real test download and check that your jar contains a key like K7QX-M2PD-9HWT-R4CN.

Refunds

The placeholder carries no refund information. Revoke refunded buyers from the license page.