Skip to content

feat: implement an api endpoint to create a new license #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 25, 2025

Conversation

SRWieZ
Copy link
Member

@SRWieZ SRWieZ commented Jul 24, 2025

Adds a new API endpoint for external services to create licenses programmatically. The endpoint handles user
creation/lookup, license generation through Anystack, and tracks the license source for better analytics.

Usage

1. Generate an API Token

  1. Login to the admin panel
  2. Navigate to "API Keys" in the sidebar
  3. Click "Create" and fill in:
    - Name: A descriptive name for your API key
    - User: Select the admin user
    - Abilities: Leave as * for full access
  4. Copy the generated token immediately (it won't be shown again)

2. Create a License via API

  curl -X POST https://your-domain.com/api/licenses \
    -H "Authorization: Bearer YOUR_API_TOKEN" \
    -H "Content-Type: application/json" \
    -H "Accept: application/json" \
    -d '{
      "email": "[email protected]",
      "name": "Customer Name",
      "subscription": "pro"
    }'

Available subscription types: mini, pro, max, forever, trial

3. Response

The API returns the created license object:

  {
    "id": 123,
    "user_id": 456,
    "policy_name": "pro",
    "source": "bifrost",
    "key": "LICENSE-KEY-HERE",
    "expires_at": null,
    "created_at": "2025-07-24T12:00:00Z",
    "updated_at": "2025-07-24T12:00:00Z"
  }

Notes

  • If the email already exists, the existing user will be used
  • New users are created with a random password
  • All licenses created via this API are marked with source: "bifrost"
  • The endpoint requires Anystack API credentials to be configured

@simonhamp simonhamp merged commit b53460b into main Jul 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants