License Key Deactivation with Creem

The deactivation endpoint allows you to remove a device’s access to a license key. This documentation will guide you through implementing license deactivation in your application.

Overview

License deactivation is essential for managing device transfers, subscription cancellations, and maintaining security of your software.

  1. Key Deactivation Features
    • Instance Management: Remove specific device instances from active licenses
    • Activation Slot Recovery: Free up slots for new device activations
    • Usage Tracking: Monitor deactivation history and remaining slots
    • Automatic Cleanup: Clear associated device data upon deactivation

Deactivation Flow Example

Here’s how the deactivation process typically works:

  1. User initiates deactivation (e.g., switching devices)
  2. Application retrieves stored license key and instance ID
  3. Sends deactivation request to Creem API
  4. Cleans up local license data
  5. Provides feedback to user about deactivation status

Endpoint Details

  • URL: https://test-api.creem.io/v1/licenses/deactivate
  • Method: POST
  • Authentication: Requires API key in headers

Request Parameters

The request body should include:

  • key (required): The license key to deactivate
  • instance_id (required): The instance ID to deactivate

Response Format

{
  "id": "<string>",
  "mode": "test",
  "object": "<string>",
  "status": "active",
  "key": "ABC123-XYZ456-XYZ456-XYZ456",
  "activation": 5,
  "activation_limit": 1,
  "expires_at": "2023-09-13T00:00:00Z",
  "created_at": "2023-09-13T00:00:00Z",
  "instance": [
    {
      "id": "<string>",
      "mode": "test",
      "object": "license-instance",
      "name": "My Customer License Instance",
      "status": "active",
      "created_at": "2023-09-13T00:00:00Z"
    }
  ]
}

Implementation Examples

  • JavaScript Example:

    const deactivateLicense = async (licenseKey, instanceId) => {
      const response = await fetch('https://test-api.creem.io/v1/licenses/deactivate', {
        method: 'POST',
        headers: {
          'accept': 'application/json',
          'x-api-key': 'YOUR_API_KEY',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          key: licenseKey,
          instance_id: instanceId
        })
      });
      return await response.json();
    }
    
  • cURL Example:

    curl -X POST https://api.creem.io/v1/licenses/deactivate \
      -H "accept: application/json" \
      -H "x-api-key: YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "key": "ABC123-XYZ456-XYZ456-XYZ456",
        "instance_id": "inst_xyz123"
      }'
    
  • Python Example:

    import requests
    
    def deactivate_license(license_key, instance_id):
        url = "https://test-api.creem.io/v1/licenses/deactivate"
        headers = {
            "accept": "application/json",
            "x-api-key": "YOUR_API_KEY",
            "Content-Type": "application/json"
        }
        data = {
            "key": license_key,
            "instance_id": instance_id
        }
        
        response = requests.post(url, json=data, headers=headers)
        return response.json()
    

Error Handling

Common error responses include:

  • 400 Bad Request: Invalid or missing parameters
  • 401 Unauthorized: Invalid API key
  • 404 Not Found: Invalid license key or instance ID
  • 409 Conflict: Instance already deactivated