πŸ”API Keys

API Keys are the β€œpower tools” of DevPayr. While License Keys validate your software at runtime, API Keys allow your backend to communicate with DevPayr and perform advanced operations.

If a License Key is your product’s entry pass, an API Key is the VIP badge your backend uses to manage DevPayr itself.

🧠 What Are API Keys?

API Keys let your server:

  • Create, update, revoke, or reactivate licenses

  • Manage domains for a project

  • Upload and retrieve injectables

  • Run server-side payment checks

  • Automate client provisioning

  • Integrate DevPayr into your CI/CD or billing pipelines

  • Build custom dashboards and internal tools

  • Access DevPayr SDK service classes (projects(), licenses(), domains(), payments(), etc.)

API Keys turn DevPayr from β€œa licensing engine” into a fully programmable backend service.

πŸ”‘ API Keys vs License Keys

Key Type
Purpose
Used In

License Key

Validates whether the running copy of your app is allowed to run

Inside your app (frontend or backend)

API Key

Authenticates your backend to manage DevPayr resources

Server-side only

Quick rule:

License Key β†’ β€œIs this copy licensed?” API Key β†’ β€œLet my backend control DevPayr.”

If you only validate licenses β†’ no API Key needed. If you want automation β†’ API Key required.

🎯 When Do You Need an API Key?

Use an API Key when you want to:

  • Auto-create licenses after payment

  • Suspend or reactivate licenses inside your billing system

  • Assign domains to clients dynamically

  • Build a custom admin dashboard

  • Work with injectables programmatically

  • Check license/payment status from backend

  • Access richer details via SDK service classes

  • Build deeper integrations with your software pipeline

You don’t need an API Key if you’re only checking if a license is valid at runtime.

πŸ› οΈ Creating an API Key

1. Go to β€œAPI Keys” in the sidebar

This page lists all existing keys.

2. Click β€œCreate New Key”

A form will appear.

3. Choose where the key should belong

Project-Scoped Key

Only works for one project.

Global Key (if your plan supports it)

Works across all your projects. Use carefully β€” global keys are extremely powerful.

4. Select the Scopes

Scopes define what the key can do.

Examples include:

  • Reading/creating licenses

  • Managing project domains

  • Managing injectables

  • Accessing payment checks

  • Updating project meta

Each API Key should have only the permissions it needs.

5. (Optional) Set an Expiration Date

Useful for:

  • Contractors

  • Temporary integrations

  • CI bots or staging pipelines

Leave empty for permanent keys.

6. Click β€œCreate”

You’ll see the key once. Copy and store it securely.

πŸ”’ Security Best Practices

Treat API Keys like real credentials.

  • NEVER use API Keys in frontend code

  • Keep API Keys in environment variables

  • Prefer project-level keys over global keys

  • Delete keys you’re no longer using

  • Rotate keys regularly

  • Limit scopes aggressively

If an API Key leaks, assume full backend access is compromised.


βš™οΈ Using API Keys in SDKs

SDKs automatically send all required headers β€” including the domain from which the app is running.

You can override the domain manually if your setup requires it.

Example (Node.js SDK)

After bootstrapping:

PHP and Python SDKs follow the same principle.

🌐 Raw HTTP Calls (cURL)

When making direct API requests (cURL, Postman, fetch, axios, etc.):

The following headers are mandatory:

  • X-API-KEY β€” authenticates your API Key

  • X-Devpayr-Domain β€” tells DevPayr which domain is using the license

Example (Checking if a project is paid)

Example (License-based validation)

πŸ“Œ Best Practices for API Key Usage

  • Use project-scoped keys unless you truly need global access

  • Store keys safely in environment variables

  • Use the SDK whenever possible β€” it handles all required headers

  • Always include X-Devpayr-Domain in raw HTTP requests

  • Delete old or unused keys

  • Combine API Key + License Key when you need deep control

πŸŽ‰ Summary

  • API Keys grant your backend controlled access to DevPayr

  • Scopes define exactly what each API Key can do

  • SDKs manage all required headers automatically

  • Raw HTTP calls must always include X-API-KEY and X-Devpayr-Domain

  • API Keys complement License Keys β€” they don’t replace them

This is the full, accurate, clean version of the β€œAPI Keys” page.

Last updated