Skip to content

Public API Overview

The Public API is designed for integration into your distributed product. Use it to validate licenses, handle activations, serve updates, collect feedback, and track analytics.

Base URL: https://api.packedge.dev/public/v1

Integration Options

MethodPackageBest For
JS SDKpackedgeFrontend, WordPress plugins
PHP SDKpackedge-sdk/licensePHP backends, WordPress
REST APIAny language, custom needs

JS SDK

Install via package manager (pnpm recommended):

bash
pnpm add packedge
bash
npm install packedge
bash
yarn add packedge
bash
bun add packedge
javascript
import packedge from 'packedge';

packedge.init('pk_your_public_key');

// Validate license (site auto-detected from browser)
const result = await packedge.validateLicense('LICENSE-KEY');

// Or specify site manually
const result = await packedge.validateLicense('LICENSE-KEY', { site: 'https://example.com' });

// Activate license
await packedge.activateLicense('LICENSE-KEY');

// Track feature usage
packedge.track('feature_used', { feature: 'export' });

// Submit feedback
await packedge.submitFeedback({ type: 'bug', message: 'Button broken' });

Or via CDN (non-WordPress contexts):

html
<script src="https://cdn.packedge.dev/packedge.js"></script>
<script>
packedge.init('pk_your_public_key');
</script>

WordPress

WordPress doesn't allow remote scripts. Use the ES6 module approach with a bundler instead.

PHP SDK

bash
composer require packedge-sdk/license
composer require packedge-sdk/analytics
php
use PackEdge\License;
use PackEdge\Analytics;

// License validation + auto-updates
$license = License::init('pk_your_public_key', __FILE__);

if ($license->is_valid()) {
    // Enable premium features
}

// Auto-updates (call once)
$license->updater();

// Analytics + feedback (separate package)
$analytics = Analytics::init('pk_your_public_key', __FILE__);

// Track feature usage
$analytics->track('feature_used', ['feature' => 'export']);

// Submit feedback
$analytics->feedback('bug', 'Button broken', 'user@example.com');

REST API

bash
curl -X POST https://api.packedge.dev/public/v1/licenses/validate \
  -H "Content-Type: application/json" \
  -d '{"public_key": "pk_your_key", "license_key": "XXX", "site": "example.com"}'

Authentication

Pass your public_key in the request body (REST) or constructor (SDK). This key is safe to embed in distributed code — it only identifies your product and cannot modify data.

php
// REST API example
$response = wp_remote_post('https://api.packedge.dev/public/v1/licenses/validate', [
    'body' => json_encode([
        'public_key' => 'pk_your_public_key', // Safe to embed
        'license_key' => $customer_license,
    ]),
]);

Public Key vs API Key

Public KeyAPI Key
Prefixpk_sk_
PurposeIdentify product in customer appsManage resources from your backend
Safe to embedYesNo (secret)
Can validate licensesYesYes
Can create/modify dataNoYes

Endpoints

Licenses

Let customers validate and manage their license activations.

  • Validate — Check license validity and status
  • Activate — Activate on a domain/device
  • Deactivate — Release an activation slot
  • Check — Quick activation status check

WordPress Updates

Power automatic updates in WordPress plugins.

Feedback & Analytics

Collect user feedback and track product usage.

  • Submit Feedback — Bug reports, feature requests, general feedback
  • Track Event — Feature usage, behavior analytics
  • Track Deactivation — Capture reason when license deactivated

Error Handling

All endpoints return standard HTTP status codes:

StatusMeaning
200Success
400Bad request — invalid parameters or business logic error
404Not found — invalid public_key or license_key

Error responses include an error field:

json
{
  "error": "License has expired"
}

Caching

Edge endpoints run on Cloudflare Workers with KV caching:

  • Validation responses cached for 60 seconds
  • Update check responses cached for 5 minutes
  • Cache invalidated on activation/deactivation

Rate Limits

Standard Cloudflare Workers rate limits apply. The KV caching layer minimizes database load for high-volume validation.