> ## Documentation Index
> Fetch the complete documentation index at: https://docs.craftingstudiopro.de/llms.txt
> Use this file to discover all available pages before exploring further.

# License System

> Protect your premium plugins by integrating our license validation system

## Overview

Protect your work with our modern license system. You can easily validate licenses via our REST API using just a few lines of code.

## API Endpoint

To validate a license, send a `POST` request to:

```http theme={null}
https://api.craftingstudiopro.de/v1/license/validate
```

## Authentication

All license validation requests require a **Developer API Key** in the header:

```http theme={null}
X-API-Key: your_api_key
```

<Note>
  **Important:** Never share your developer API key publicly (e.g., on GitHub).
</Note>

## Request & Response

### Request Body (JSON)

```json theme={null}
{
  "licenseKey": "XXXX-XXXX-XXXX-XXXX",
  "pluginId": "your-plugin-slug-or-id"
}
```

### Success Response Example

```json theme={null}
{
  "valid": true,
  "message": null,
  "purchase": {
    "id": "123",
    "userId": "456",
    "pluginId": "789",
    "createdAt": "2024-03-09T10:00:00Z"
  }
}
```

## Java Implementation

For Minecraft plugin developers, here is a simple validator class using Java's `HttpClient`:

```java theme={null}
public class LicenseValidator {
    private static final String API_URL = "https://api.craftingstudiopro.de/v1/license/validate";
    private static final String API_KEY = "YOUR_DEVELOPER_API_KEY";

    public boolean validate(String licenseKey, String pluginSlug) {
        try {
            HttpClient client = HttpClient.newHttpClient();
            String json = String.format("{\"licenseKey\": \"%s\", \"pluginId\": \"%s\"}", 
                                       licenseKey, pluginSlug);

            HttpRequest request = HttpRequest.newBuilder()
                    .uri(URI.create(API_URL))
                    .header("Content-Type", "application/json")
                    .header("X-API-Key", API_KEY)
                    .POST(HttpRequest.BodyPublishers.ofString(json))
                    .build();

            HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
            
            // Check if status is 200 and response contains "valid":true
            return response.statusCode() == 200 && response.body().contains("\"valid\":true");
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}
```

<CardGroup cols={2}>
  <Card title="Fast Validation" icon="bolt">
    Validation takes less than 200ms on average.
  </Card>

  <Card title="Slug Support" icon="link">
    You can use either the numeric ID or the plugin slug as the `pluginId`.
  </Card>
</CardGroup>
