Create License Key

Generate a new license key for a specific product (productId). You can optionally define activation limits (maxActivations), set an expiration date (expiryDate), assign it to an existing customer (customerId), or create and assign it to a new customer (newCustomer).

Endpoint

POST /create-key

Base URL: https://docs/api.keymint.dev

Request

Send a POST request with a JSON body and Content-Type: application/json. Include the accessToken as a Bearer token in the Authorization header.

Headers

HeaderValueRequiredDescription
AuthorizationBearer <accessToken>YesAPI access token for authentication.

Body Parameters

ParameterTypeRequiredDescription
productIdstringYesUnique product identifier (e.g., prod_...).
maxActivationsstringNoMaximum number of activations allowed (e.g., "5"). Omit or set to null for unlimited.
expiryDatestringNoExpiration date in ISO 8601 format (e.g., "2024-12-31T23:59:59Z"). Defaults to 1 month from creation if omitted.
customerIdstringNoID of an existing customer to assign the key to (e.g., cust_...). Cannot be used with newCustomer.
newCustomerobjectNoObject containing name (string, required) and email (string, optional) to create a new customer. Cannot be used with customerId.

Example Requests

Simple Key

POST /create-key HTTP/1.1
Host: api.keymint.dev
Authorization: Bearer at_verylongaccesstokenstringgeneratedforyourapplication12345678
Content-Type: application/json

{
  "productId": "your_product_id_123",
  "maxActivations": "3",
  "expiryDate": "2025-06-30T23:59:59Z"
}

Assign to New Customer

POST /create-key HTTP/1.1
Host: api.keymint.dev
Authorization: Bearer at_verylongaccesstokenstringgeneratedforyourapplication12345678
Content-Type: application/json

{
  "productId": "your_product_id_123",
  "newCustomer": {
    "name": "John Doe",
    "email": "john.doe.new@example.com"
  }
}

Assign to Existing Customer

POST /create-key HTTP/1.1
Host: api.keymint.dev
Authorization: Bearer at_verylongaccesstokenstringgeneratedforyourapplication12345678
Content-Type: application/json

{
  "productId": "your_product_id_123",
  "customerId": "cust_abc123"
}

Responses

The API returns the newly generated license key.

Success Response (200 OK)

{
  "code": 0,
  "key": "xxxxx-xxxxx-xxxxx-xxxxx"
}

Error Responses

Status CodeCodeDescriptionExample Response Body
4001Missing required parameters (productId) or invalid format (e.g., expiryDate).{"message": "Missing required params", "code": 1}
4011Invalid or missing Authorization header.{"message": "Invalid access token", "code": 1}
4041productId not found or inactive.{"message": "Product not found or inactive", "code": 1}
4042customerId provided, but the customer was not found.{"message": "Customer with ID cust_... not found", "code": 2}
4092newCustomer provided with an email that already exists.{"message": "CONFLICT: Customer email ... already exists.", "code": 2}
5001Internal server error (e.g., database insertion failure, unexpected issue).{"message": "Server error", "code": 1}