Core API Reference
The Moonbase Core API has endpoints where you can manage your Moonbase account using API keys from other systems. It's the ideal set of endpoints to use when building custom integrations or migrating a lot of data to Moonbase.
When calling endpoints, be sure to use the full URL including your Moonbase account ID. Examples on this page assumes an account ID of demo, and so the base URL for all endpoints will be https://demo.moonbase.sh/api/.
Do you have a specific scenario you need to support or other questions?
Reach out to us through the support channel, or at developers@moonbase.sh.
Authentication
All endpoints that are part of this Core API require an API key on requests. API keys can be created in your Moonbase account settings, and should be included in a header called Api-Key. For example:
curl -X 'GET' https://demo.moonbase.sh/api/products \
-H 'Api-Key: mb_bbdac119b64649f6937e...'
Pagination
For endpoints that query a list of resources, we have pagination in place to make sure you can iterate through large amounts of data easily. When you receive paginated responses, they always come wrapped in the same response wrapper:
- Name
items- Type
- array
- Description
This array contains objects with the resources requested.
- Name
hasMore- Type
- boolean
- Description
Flag to indicate whether there are more results to be retrieved.
- Name
next- Type
- string
- Nullability
- nullable
- Description
The path to call to get the next page of results.
Pagination example
{
"items": [
{
...
}
],
"hasMore": true,
"next": "/api/customers?paginationToken=..."
}
Custom Properties
Custom properties allow you to attach arbitrary metadata to your core entities: customers, licenses, products, trials, product releases, vouchers, and coupons. Each property has a typed value and two visibility flags that control where the property appears.
Property structure
Each custom property is an object with the following fields:
- Name
type- Type
- enum(text|number|boolean|date|object)
- Description
The type of value this property holds.
- Name
value- Type
- string|number|boolean|datetime|object
- Description
The value of the property:
- text: A string value
- number: A decimal number value
- boolean: A true or false value
- date: An ISO-8601 date and time value
- object: A nested object containing more typed values
- Name
public- Type
- boolean
- Description
Controls if this property is visible in storefront and customer-facing endpoints. Properties with
publicset tofalsewill only be visible in the Core API.
- Name
includeInToken- Type
- boolean
- Description
Controls if this property is included in license tokens. See the licensing API documentation for details on how custom properties appear in tokens.
Validation rules
- Property names must start with a letter or underscore and contain only letters, digits, underscores, hyphens, or periods.
- Nested objects support up to 5 levels of depth.
- Total custom properties size must not exceed 48 KB per entity.
- Object properties must contain at least one field.
Custom property examples
{
"company_size": {
"type": "number",
"value": 50,
"public": false,
"includeInToken": false
},
"category": {
"type": "text",
"value": "Audio Tools",
"public": true,
"includeInToken": false
},
"beta_access": {
"type": "boolean",
"value": true,
"public": true,
"includeInToken": true
},
"renewal_date": {
"type": "date",
"value": "2026-06-01T00:00:00Z",
"public": false,
"includeInToken": true
},
"metadata": {
"type": "object",
"value": {
"region": {
"type": "text",
"value": "eu-west"
},
"tier": {
"type": "number",
"value": 2
}
},
"public": false,
"includeInToken": false
}
}
Customers
Use customer endpoints to manage your customer accounts and get insights into who are buying your products. The customer object will contain the following fields:
- Name
id- Type
- string
- Description
The Moonbase ID of the customer.
- Name
name- Type
- string
- Description
The full name of the customer.
- Name
businessName- Type
- string
- Nullability
- nullable
- Description
If the customer is a business, this holds the business name.
- Name
taxId- Type
- string
- Nullability
- nullable
- Description
If the customer is a business, this holds the tax ID if given.
- Name
email- Type
- string
- Description
Current email address of the customer.
- Name
emailConfirmed- Type
- boolean
- Description
Flag for if the current email address has ever been confirmed.
- Name
hasPassword- Type
- boolean
- Description
Flag for if the customer has created a password yet.
- Name
isDeleted- Type
- boolean
- Description
Flag for if the this customer account has been deleted.
- Name
ownedProducts- Type
- array
- Description
List of product IDs that this customer owns.
- Name
subscribedProducts- Type
- array
- Description
List of product IDs that this customer is currently subscribed to.
- Name
address- Type
- object
- Nullability
- nullable
- Description
Billing address for the customer if stored. Contains the following properties:
- Name
countryCode- Type
- string
- Description
ISO 3166-1 alpha-2 two-letter country code.
- Name
streetAddress1- Type
- string
- Description
First line of the regular street address.
- Name
streetAddress2- Type
- string
- Optionality
- optional
- Description
Second line of the regular street address.
- Name
postCode- Type
- string
- Description
Postal code of the address.
- Name
locality- Type
- string
- Description
Locality of the address, only required if no region is given.
Also known asCity.
- Name
region- Type
- string
- Description
Region of the address, only required if no locality is given.
Also known asState.
- Name
communicationPreferences- Type
- object
- Description
Contains specific communication opt-ins given by the customer:
- Name
newsletterOptIn- Type
- boolean
- Description
Flag for if the customer wants to receive newsletters.
- Name
properties- Type
- object
- Optionality
- optional
- Description
Custom properties attached to this customer. See custom properties for more details on the shape and types of custom properties.
Customer example
{
"id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"name": "Tobias",
"businessName": null,
"taxId": null,
"email": "tobias@moonbase.sh",
"emailConfirmed": true,
"hasPassword": true,
"isDeleted": false,
"ownedProducts": [
"example-app"
],
"subscribedProducts": [],
"address": null,
"communicationPreferences": {
"newsletterOptIn": true
},
"properties": {
"company_size": {
"type": "number",
"value": 50,
"public": false,
"includeInToken": false
}
}
}
Get customers
Use this endpoint to fetch all customers page by page. For more details on how pagination works, see pagination.
Optional query parameters
- Name
pageSize- Type
- number
- Optionality
- optional
- Description
Adjust the size of each page returned.
Request
GET https://demo.moonbase.sh/api/customers
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"items": [
{
"id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"name": "Tobias",
...
}
],
"hasMore": false,
"next": null
}
Get customer by ID or email
Use this endpoint to look up a customer by their ID or email address.
Request
GET https://demo.moonbase.sh/api/customers/tobias@moonbase.sh
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"name": "Tobias",
...
}
Import customer
Importing a customer creates them a user account. It will not send any emails to the customer, and they will be able to reset their password using the normal reset password flow on your website or the hosted customer portal. You can also supply their password if you already have it, or can generate a secure one.
In case a customer account with the given email already exists, you will receive a 409: Conflict response, where you can access the customer ID using the instance property of the error object.
Required body properties
- Name
name- Type
- string
- Description
Full name of the user.
- Name
email- Type
- string
- Description
Email address of the user. Will be used as username. Can be changed by the user.
Optional body properties
- Name
password- Type
- string
- Optionality
- optional
- Description
The initial password for the user. Must contain lower case characters, uppercase characters, numbers and a symbol.
- Name
address- Type
- object
- Optionality
- optional
- Description
A billing address for the user. Will be used when purchasing new products.
Contains the following properties:- Name
countryCode- Type
- string
- Description
ISO 3166-1 alpha-2 two-letter country code.
- Name
streetAddress1- Type
- string
- Description
First line of the regular street address.
- Name
streetAddress2- Type
- string
- Optionality
- optional
- Description
Second line of the regular street address.
- Name
postCode- Type
- string
- Description
Postal code of the address.
- Name
locality- Type
- string
- Description
Locality of the address, only required if no region is given.
Also known asCity.
- Name
region- Type
- string
- Description
Region of the address, only required if no locality is given.
Also known asState.
- Name
communicationPreferences- Type
- object
- Optionality
- optional
- Description
The existing communication preferences the customer has given, if any.
Contains the following properties:- Name
newsletterOptIn- Type
- boolean
- Optionality
- optional
- Description
Customer has agreed to receive newsletters or other marketing emails.
- Name
productUpdatesOptIn- Type
- boolean
- Optionality
- optional
- Description
Customer has agreed to receive product updates and similar emails.
Request
POST https://demo.moonbase.sh/api/customers/import
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"name": "Example User",
"email": "user@example.com",
"password": "Password1234!",
"address": {
"countryCode": "NO",
"streetAddress1": "Slottsplassen 1",
"streetAddress2": null,
"postCode": "0010",
"region": "Oslo",
"locality": null
},
"communicationPreferences": {
"newsletterOptIn": true
}
}
Response
{
"id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"name": "Example User",
...
}
Update customer
This endpoint can be used to partially update customer accounts, with every property being optional.
Optional body properties
- Name
name- Type
- string
- Optionality
- optional
- Description
Full name of the user.
- Name
email- Type
- string
- Optionality
- optional
- Description
Email address of the user. Will be used as username. Can be changed by the user. Changing this will not send an email to the customer, and they will immediately be able to log in using the new address.
- Name
communicationPreferences- Type
- object
- Optionality
- optional
- Description
If you have collected updated communication opt-ins, you can update those using this object:
- Name
newsletterOptIn- Type
- boolean
- Description
Flag for if this customer has opted in to receive newsletters.
Request
PATCH https://demo.moonbase.sh/api/customers/49b8da10-2d72-4bdf-bf9c-47e56c184bfa
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"name": "Example User",
"communicationPreferences": {
"newsletterOptIn": true
}
}
Response
{
"id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"name": "Example User",
...
}
Delete customer
Use this to delete customers from your Moonbase account. They will lose access to all products, and their user will be stripped of all personal information. Deleting customers will not affect historical sales, as we are required to store billing details for financial compliancy.
Request
DELETE https://demo.moonbase.sh/api/customers/49b8da10-2d72-4bdf-bf9c-47e56c184bfa
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"name": "Example User",
...
}
Set custom properties
Use this endpoint to set custom properties on a customer. This replaces all existing custom properties on the customer. See custom properties for more details on the shape and types of custom properties.
Request body
The body should be a JSON object where each key is the property name, and the value is a custom property object.
- Name
{key}- Type
- object
- Description
Each property must contain the following fields:
- Name
type- Type
- enum(text|number|boolean|date|object)
- Description
The type of value this property holds.
- Name
value- Type
- string|number|boolean|datetime|object
- Description
The value of the property, matching the declared type.
- Name
public- Type
- boolean
- Description
Flag for if this property should be visible in storefront and customer-facing endpoints.
- Name
includeInToken- Type
- boolean
- Description
Flag for if this property should be included in license tokens.
Request
PUT https://demo.moonbase.sh/api/customers/49b8da10-2d72-4bdf-bf9c-47e56c184bfa/custom-properties
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"company_size": {
"type": "number",
"value": 50,
"public": false,
"includeInToken": false
}
}
Response
{
"id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"name": "Tobias",
...
}
Licenses
License endpoints let you manage the full life cycle of licenses, including individual activations. If you need to connect your own licensing system with Moonbase licenses, these endpoints should suffice. The license object contains the following:
- Name
id- Type
- string
- Description
The Moonbase ID of the license.
- Name
ownerId- Type
- string
- Description
The Moonbase ID of the customer that owns this license.
- Name
productId- Type
- string
- Description
The Moonbase ID of the product that this license is for.
- Name
status- Type
- enum(Active|Revoked|Expired)
- Description
Current status of the license:
- Active: The license can be used by the customer
- Revoked: The license has been revoked by the merchant
- Expired: The subscription for the license has expired
- Name
activeNumberOfActivations- Type
- number
- Description
Number of devices currently activated on this license.
- Name
maxNumberOfActivations- Type
- number
- Description
Max number of devices allowed to activate this license.
- Name
offlineActivationsAllowed- Type
- boolean
- Description
Flag for if offline activations are allowed for this license.
- Name
properties- Type
- object
- Optionality
- optional
- Description
Custom properties attached to this license. See custom properties for more details on the shape and types of custom properties.
License example
{
"id": "32016591-73c5-4956-938c-e34366599bc7",
"ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"productId": "example-app",
"status": "Active",
"activeNumberOfActivations": 0,
"maxNumberOfActivations": 1,
"offlineActivationsAllowed": false
}
Get licenses
Use this endpoint to fetch all licenses page by page. For more details on how pagination works, see pagination.
Optional query parameters
- Name
pageSize- Type
- number
- Optionality
- optional
- Description
Adjust the size of each page returned.
- Name
productFilter- Type
- string
- Optionality
- optional
- Description
Optionally filter licenses belonging to this product ID.
- Name
before- Type
- datetime
- Optionality
- optional
- Description
Optionally filter licenses created before this ISO-8601 date and time.
- Name
after- Type
- datetime
- Optionality
- optional
- Description
Optionally filter licenses created after this ISO-8601 date and time.
Request
GET https://demo.moonbase.sh/api/licenses
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"items": [
{
"id": "32016591-73c5-4956-938c-e34366599bc7",
"ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"productId": "example-app",
"status": "Active",
...
}
],
"hasMore": false,
"next": null
}
Get license by ID
Use this endpoint to look up a license by its ID.
Request
GET https://demo.moonbase.sh/api/licenses/32016591-73c5-4956-938c-e34366599bc7
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"id": "32016591-73c5-4956-938c-e34366599bc7",
"ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"productId": "example-app",
"status": "Active",
...
}
Provision licenses
This endpoint can be used to create multiple licenses for a given customer for several products. In case you want to create the user in the same process, you may instead opt to provide customer details instead of an owner ID. The response will contain a list of licenses that have been provisioned.
Request body properties
- Name
ownerId- Type
- string
- Optionality
- optional
- Description
Moonbase ID of the customer that should receive the license(s). Skip this if submitting customer details instead.
- Name
customer- Type
- object
- Optionality
- optional
- Description
Provide this if you don't have an existing customer to grant the licenses to. This object must contain the following:
- Name
name- Type
- string
- Description
Full name of the customer.
- Name
email- Type
- string
- Description
Email address of the customer. If a customer already exists with this email, we attach the licenses to that user instead.
- Name
requests- Type
- array
- Description
A list of license requests that should be fulfilled, each object contain the following properties:
- Name
productId- Type
- string
- Description
Moonbase ID of the product you want to issue a license for.
- Name
quantity- Type
- number
- Optionality
- optional
- Description
Number of licenses to issue, defaults to 1.
- Name
limitPerCustomer- Type
- number
- Optionality
- optional
- Description
Use this to only provision licenses up to a certain number for the given customer.
Request
POST https://demo.moonbase.sh/api/licenses/provision
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"requests": [
{
"productId": "example-app"
}
]
}
Response
[
{
"id": "32016591-73c5-4956-938c-e34366599bc7",
"ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"productId": "example-app",
"status": "Active",
...
}
]
Import license
Importing a license is almost the same as provisioning it through the Moonbase app or API, with the exception of no communication to the customer being done. The license will be available on their account immediately, and can be used to import a large amount of licenses. This endpoint also allows you to add existing activations for a given license or external key codes previously generated, making migrations easier in some cases.
Request body properties
- Name
ownerId- Type
- string
- Optionality
- optional
- Description
Moonbase ID of the customer that should receive this license. Either
ownerIdorownerEmailmust be provided, but not both.
- Name
ownerEmail- Type
- string
- Optionality
- optional
- Description
Email address of an existing customer that should receive this license. Either
ownerIdorownerEmailmust be provided, but not both. The customer must already exist in your tenant — unknown emails are rejected.
- Name
productId- Type
- string
- Description
Moonbase ID of the product that this license is for.
- Name
maxNumberOfActivations- Type
- number
- Optionality
- optional
- Description
Max number of devices allowed to activate this license. If omitted, Moonbase will use the currently configured value from the product.
- Name
offlineActivationsAllowed- Type
- boolean
- Optionality
- optional
- Description
Flag for if offline activations are allowed for this license. If omitted, Moonbase will use the currently configured value from the product.
- Name
activations- Type
- array
- Optionality
- optional
- Description
If you know devices that have already activated this license, you can also import them. It's important that the device signature will be the same so that license activation finds the correct seat to activate. Each activation contains the following properties:
- Name
deviceName- Type
- string
- Description
User-friendly name of the device.
- Name
deviceSignature- Type
- string
- Description
Fingerprint of the device generated by the licensing SDK.
- Name
activationMethod- Type
- enum(Online|Offline)
- Description
Flag for if this activation has been activated as an online or offline device.
- Name
lastValidation- Type
- datetime
- Description
ISO-8601 date and time for when the device was last validated.
- Name
keyCode- Type
- string
- Optionality
- optional
- Description
If you have an external license key code that you want to associate with this license, you can provide it here. Will be visible to the customer in their customer portal. Cannot be combined with
file.
- Name
file- Type
- object
- Optionality
- optional
- Description
An existing license file to attach to this license, for customers that already have a generated license file you want to migrate. Cannot be combined with
keyCode. Contains the following properties:- Name
fileName- Type
- string
- Description
Name of the file as it should appear to the customer.
- Name
data- Type
- string
- Description
Base64-encoded contents of the file.
- Name
contentType- Type
- string
- Description
MIME type of the file, for example
application/octet-stream.
- Name
externalId- Type
- string
- Optionality
- optional
- Description
This is an internal property, stored on licenses to let you correlate imported licenses with your existing systems.
- Name
expiresAt- Type
- datetime
- Optionality
- optional
- Description
Sets the expiry date of this license to this ISO-8601 date and time.
- Name
createdAt- Type
- datetime
- Optionality
- optional
- Description
Sets the created date of this license to this ISO-8601 date and time.
Request
POST https://demo.moonbase.sh/api/licenses/import
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"productId": "example-app"
}
Response
{
"id": "32016591-73c5-4956-938c-e34366599bc7",
"ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"productId": "example-app",
"status": "Active",
...
}
Revoke license
Revoking a license makes it inaccessible for the owner, and causes any further client-side validations to fail. This is different from revoking license activations, which only disables single devices and doesn't prevent the user from re-activating their license.
Request
POST https://demo.moonbase.sh/api/licenses/32016591-73c5-4956-938c-e34366599bc7/revoke
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"productId": "example-app"
}
Response
{
"id": "32016591-73c5-4956-938c-e34366599bc7",
"ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"productId": "example-app",
"status": "Active",
...
}
Set custom properties
Use this endpoint to set custom properties on a license. This replaces all existing custom properties on the license. See custom properties for more details on the shape and types of custom properties.
Request body
The body should be a JSON object where each key is the property name, and the value is a custom property object.
Request
PUT https://demo.moonbase.sh/api/licenses/32016591-73c5-4956-938c-e34366599bc7/custom-properties
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"seat_name": {
"type": "text",
"value": "Studio A",
"public": true,
"includeInToken": true
}
}
Response
{
"id": "32016591-73c5-4956-938c-e34366599bc7",
"ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"productId": "example-app",
"status": "Active",
...
}
Trials
Trial endpoints let you query current trials in Moonbase, and import existing trials you may have. The trial object contains the following:
- Name
id- Type
- string
- Description
The Moonbase ID of the trial.
- Name
productId- Type
- string
- Description
The Moonbase ID of the product that this license is for.
- Name
deviceName- Type
- string
- Description
Friendly name of the device that the trial is activated on.
- Name
deviceSignature- Type
- string
- Description
Hardware signature of the device that the trial is activated on.
- Name
lastValidatedAt- Type
- datetime
- Description
ISO-8601 date and time of the last validation.
- Name
expiresAt- Type
- datetime
- Description
ISO-8601 date and time of the expiry of this trial.
- Name
status- Type
- enum('Active' | 'Expired')
- Description
Current status of the trial, if it's active or expired.
- Name
properties- Type
- object
- Optionality
- optional
- Description
Custom properties attached to this trial. See custom properties for more details on the shape and types of custom properties.
Trial example
{
"id": "5f113851778f34b175101c65657e7ea8",
"productId": "example-product",
"deviceName": "Example Device",
"deviceSignature": "89419872hc72nv150989",
"lastValidatedAt": "2025-11-24T17:26:37.0417505Z",
"expiresAt": "2025-12-08T17:26:35.047223Z",
"status": "Expired"
}
Get trials
Use this endpoint to fetch all trials page by page. For more details on how pagination works, see pagination.
Optional query parameters
- Name
pageSize- Type
- number
- Optionality
- optional
- Description
Adjust the size of each page returned.
- Name
productFilter- Type
- string
- Optionality
- optional
- Description
Optionally filter trials belonging to this product ID.
- Name
before- Type
- datetime
- Optionality
- optional
- Description
Optionally filter trials created before this ISO-8601 date and time.
- Name
after- Type
- datetime
- Optionality
- optional
- Description
Optionally filter trials created after this ISO-8601 date and time.
Request
GET https://demo.moonbase.sh/api/trials
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"items": [
{
"id": "5f113851778f34b175101c65657e7ea8",
"productId": "example-app",
"status": "Active",
...
}
],
"hasMore": false,
"next": null
}
Get trial by ID
Use this endpoint to look up a trial by its ID.
Request
GET https://demo.moonbase.sh/api/trials/5f113851778f34b175101c65657e7ea8
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"id": "5f113851778f34b175101c65657e7ea8",
"productId": "example-app",
"status": "Active",
...
}
Import trial
Importing a trial lets you import existing trials you may have, to prevent your users from re-starting trials from other systems.
Required body properties
- Name
productId- Type
- string
- Description
Moonbase ID of the product that this trial is for.
- Name
deviceName- Type
- string
- Description
User-friendly name of the device that the trial is activated on.
- Name
deviceSignature- Type
- string
- Description
Fingerprint of the device generated by the licensing SDK of choice.
- Name
expiresAt- Type
- datetime
- Description
ISO-8601 date and time of the expiry of this trial.
Optional body properties
- Name
ownerId- Type
- string
- Optionality
- optional
- Description
Moonbase ID of the customer that should be attributed to this trial.
- Name
lastValidation- Type
- datetime
- Optionality
- optional
- Description
ISO-8601 date and time for when the device was last validated.
- Name
createdAt- Type
- datetime
- Optionality
- optional
- Description
Sets the created date of this trial to this ISO-8601 date and time.
Request
POST https://demo.moonbase.sh/api/trials/import
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"productId": "example-app",
"deviceName": "Example Device",
"deviceSignature": "89419872hc72nv150989",
"expiresAt": "2025-12-08T17:26:35.007223Z"
}
Response
{
"id": "5f113851778f34b175101c65657e7ea8",
"productId": "example-app",
"status": "Active",
...
}
Set custom properties
Use this endpoint to set custom properties on a trial. This replaces all existing custom properties on the trial. See custom properties for more details on the shape and types of custom properties.
Request body
The body should be a JSON object where each key is the property name, and the value is a custom property object.
Request
PUT https://demo.moonbase.sh/api/trials/5f113851778f34b175101c65657e7ea8/custom-properties
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"source": {
"type": "text",
"value": "website_banner",
"public": false,
"includeInToken": false
}
}
Response
{
"id": "5f113851778f34b175101c65657e7ea8",
"productId": "example-app",
"status": "Active",
...
}
Products
Product endpoints let you manage the products in your Moonbase account. The product object contains the following:
- Name
id- Type
- string
- Description
The Moonbase ID of the product.
- Name
name- Type
- string
- Description
The name of the product.
- Name
tagline- Type
- string
- Description
The tag line of the product.
- Name
description- Type
- string
- Description
The description of the product.
- Name
status- Type
- enum(Active|Inactive)
- Description
Current status of the product:
- Active: The product can be issued licenses for
- Inactive: The product cannot be used by any customer
- Name
purchasable- Type
- boolean
- Description
Flag for if this product can be purchased.
- Name
website- Type
- url
- Nullability
- nullable
- Description
Configured website URL for this product if any.
- Name
iconUrl- Type
- url
- Nullability
- nullable
- Description
Link to the icon added to this product if any.
- Name
currentReleaseVersion- Type
- string
- Nullability
- nullable
- Description
Semantic version of the current release of this product if any.
- Name
notes- Type
- string
- Nullability
- nullable
- Description
Internal notes for this product. Not visible to customers.
- Name
defaultVariationId- Type
- string
- Nullability
- nullable
- Description
The ID of the default pricing variation.
- Name
releaseAccessControlLevel- Type
- enum(AllowAnonymous|AllowCustomers|AllowOwners)
- Description
Controls who can access releases for this product.
- Name
licensingConfiguration- Type
- object
- Description
Licensing configuration for this product.
- Name
numberOfActivationsPerLicense- Type
- number
- Description
Maximum number of concurrent activations allowed per license.
- Name
offlineActivationsEnabled- Type
- boolean
- Description
Whether offline activation is allowed.
- Name
autoProvisionOnActivation- Type
- boolean
- Description
Whether to automatically provision a license on activation.
- Name
trialsConfiguration- Type
- object
- Description
Trial configuration for this product.
- Name
enabled- Type
- boolean
- Description
Whether trials are enabled for this product.
- Name
requireAccount- Type
- boolean
- Description
Whether a customer account is required to start a trial.
- Name
numberOfDays- Type
- number
- Description
Duration of the trial period in days.
- Name
pricingConfiguration- Type
- array
- Description
Array of pricing variations for this product. Each variation defines a way the product can be purchased.
- Name
id- Type
- string
- Description
Unique identifier for this variation.
- Name
name- Type
- string
- Description
Display name for this variation.
- Name
entitlement- Type
- object
- Description
The type of entitlement granted. Either
PerpetualLicenseorSubscriptionLicensewith a grace period.
- Name
recurrence- Type
- object
- Description
The billing recurrence. Either
OneOfffor a one-time purchase orRecurringwith a cycle length.
- Name
price- Type
- object
- Description
Object mapping currency codes to amounts.
- Name
pricingTiers- Type
- array
- Optionality
- optional
- Description
Array of tiered pricing levels with
minQuantityandprice.
- Name
licenseConfigurationOverride- Type
- object
- Optionality
- optional
- Description
Override the product-level licensing configuration for this specific variation.
- Name
discounts- Type
- array
- Description
Array of pricing discounts for this product.
- Name
name- Type
- string
- Description
Display name for the discount.
- Name
description- Type
- string
- Optionality
- optional
- Description
Description of the discount.
- Name
discount- Type
- object
- Description
The discount type. Either
PercentageOffDiscountorFlatAmountOffDiscount.
- Name
exclusivity- Type
- object
- Optionality
- optional
- Description
Controls which customers can see and use this discount.
- Name
applicableVariationIds- Type
- array
- Optionality
- optional
- Description
Array of variation IDs this discount applies to.
- Name
validity- Type
- object
- Optionality
- optional
- Description
Time range for when this discount is valid.
- Name
recurringPaymentUseCount- Type
- number
- Optionality
- optional
- Description
Number of recurring payments the discount applies to before expiring.
- Name
properties- Type
- object
- Optionality
- optional
- Description
Custom properties attached to this product. See custom properties for more details on the shape and types of custom properties.
Product example
{
"id": "example-product",
"name": "AudioPanel",
"tagline": "This product is used for demo purposes",
"description": "Used for demo purposes",
"notes": null,
"status": "Active",
"purchasable": true,
"website": null,
"iconUrl": "https://assets.moonbase.sh/demo/products/example-product/icon/...",
"currentReleaseVersion": "1.0.0",
"defaultVariationId": "standard",
"releaseAccessControlLevel": "AllowOwners",
"licensingConfiguration": {
"numberOfActivationsPerLicense": 3,
"offlineActivationsEnabled": false,
"autoProvisionOnActivation": false
},
"trialsConfiguration": {
"enabled": false,
"requireAccount": false,
"numberOfDays": 0
},
"pricingConfiguration": [
{
"id": "standard",
"name": "Standard",
"entitlement": {
"type": "PerpetualLicense"
},
"recurrence": {
"type": "OneOff"
},
"price": {
"USD": 49.99
}
}
],
"discounts": [],
"properties": {
"category": {
"type": "text",
"value": "Audio Tools",
"public": true,
"includeInToken": false
}
}
}
Get products
Use this endpoint to fetch all products page by page. For more details on how pagination works, see pagination.
Optional query parameters
- Name
pageSize- Type
- number
- Optionality
- optional
- Description
Adjust the size of each page returned.
Request
GET https://demo.moonbase.sh/api/products
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"items": [
{
"id": "exmaple-product",
"name": "Example Product",
...
}
],
"hasMore": false,
"next": null
}
Get product by ID
Use this endpoint to look up a product by their ID.
Request
GET https://demo.moonbase.sh/api/products/example-product
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"id": "example-product",
"name": "Example Product",
...
}
Upsert product
Use this endpoint to create a new product or update an existing one. The product ID is specified in the URL path. If a product with the given ID already exists, it will be updated; otherwise, a new product will be created.
Returns 201 Created when a new product is created, or 200 OK when an existing product is updated.
Required body parameters
- Name
name- Type
- string
- Description
The name of the product.
- Name
tagline- Type
- string
- Description
The tag line of the product.
- Name
description- Type
- string
- Description
The description of the product.
Optional body parameters
- Name
parentId- Type
- string
- Optionality
- optional
- Description
Parent product ID, used to create sub-products. Note that nested sub-products (a sub-product of a sub-product) are not allowed.
- Name
website- Type
- url
- Optionality
- optional
- Description
Website URL for this product.
- Name
notes- Type
- string
- Optionality
- optional
- Description
Internal notes for this product. Not visible to customers.
- Name
purchasable- Type
- boolean
- Optionality
- optional
- Description
Whether this product can be purchased. Defaults to
false.
- Name
defaultVariationId- Type
- string
- Optionality
- optional
- Description
The ID of the default pricing variation.
- Name
releaseAccessControlLevel- Type
- enum(AllowAnonymous|AllowCustomers|AllowOwners)
- Optionality
- optional
- Description
Controls who can access releases for this product.
- Name
properties- Type
- object
- Optionality
- optional
- Description
Custom properties to attach to this product. See custom properties for more details on the shape and types of custom properties.
- Name
licensingConfiguration- Type
- object
- Optionality
- optional
- Description
Licensing configuration for this product.
- Name
numberOfActivationsPerLicense- Type
- number
- Description
Maximum number of concurrent activations allowed per license.
- Name
offlineActivationsEnabled- Type
- boolean
- Description
Whether offline activation is allowed.
- Name
autoProvisionOnActivation- Type
- boolean
- Description
Whether to automatically provision a license on activation.
- Name
trialsConfiguration- Type
- object
- Optionality
- optional
- Description
Trial configuration for this product.
- Name
enabled- Type
- boolean
- Description
Whether trials are enabled for this product.
- Name
requireAccount- Type
- boolean
- Description
Whether a customer account is required to start a trial.
- Name
numberOfDays- Type
- number
- Description
Duration of the trial period in days.
- Name
pricingConfiguration- Type
- array
- Optionality
- optional
- Description
Array of pricing variations for this product. Each variation defines a way the product can be purchased.
- Name
id- Type
- string
- Description
Unique identifier for this variation.
- Name
name- Type
- string
- Description
Display name for this variation.
- Name
entitlement- Type
- object
- Description
The type of entitlement granted. Use
{ "type": "PerpetualLicense" }for a perpetual license, or{ "type": "SubscriptionLicense", "gracePeriod": "..." }for a subscription with a grace period.
- Name
recurrence- Type
- object
- Description
The billing recurrence. Use
{ "type": "OneOff" }for a one-time purchase, or{ "type": "Recurring", "cycleLength": "Monthly" }for recurring billing. Supported cycle lengths areMonthlyandYearly. Optionally includerenewalPriceto set a different price for renewals.
- Name
price- Type
- object
- Description
Object mapping currency codes to amounts, e.g.
{ "USD": 29.99, "EUR": 24.99 }.
- Name
pricingTiers- Type
- array
- Optionality
- optional
- Description
Array of tiered pricing levels. Each tier has a
minQuantity(number) andprice(object mapping currencies to amounts).
- Name
licenseConfigurationOverride- Type
- object
- Optionality
- optional
- Description
Override the product-level licensing configuration for this specific variation. Same shape as
licensingConfiguration.
- Name
discounts- Type
- array
- Optionality
- optional
- Description
Array of pricing discounts for this product.
- Name
name- Type
- string
- Description
Display name for the discount.
- Name
description- Type
- string
- Optionality
- optional
- Description
Description of the discount.
- Name
discount- Type
- object
- Description
The discount type. Use
{ "type": "PercentageOffDiscount", "percentage": 0.2 }for a percentage discount (value between 0 and 1), or{ "type": "FlatAmountOffDiscount", "total": { "USD": 5.00 } }for a flat amount off.
- Name
exclusivity- Type
- object
- Optionality
- optional
- Description
Controls which customers can see and use this discount.
- Name
applicableVariationIds- Type
- array
- Optionality
- optional
- Description
Array of variation IDs this discount applies to. If omitted, applies to all variations.
- Name
validity- Type
- object
- Optionality
- optional
- Description
Time range for when this discount is valid. Contains optional
fromandtodatetime fields.
- Name
recurringPaymentUseCount- Type
- number
- Optionality
- optional
- Description
Number of recurring payments the discount applies to before expiring.
Request
PUT https://demo.moonbase.sh/api/products/example-product
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"name": "AudioPanel",
"tagline": "Professional audio processing plugin",
"description": "A versatile audio plugin for mixing and mastering",
"purchasable": true,
"website": "https://example.org",
"licensingConfiguration": {
"numberOfActivationsPerLicense": 3,
"offlineActivationsEnabled": true,
"autoProvisionOnActivation": false
},
"trialsConfiguration": {
"enabled": true,
"requireAccount": false,
"numberOfDays": 14
},
"pricingConfiguration": [
{
"id": "standard",
"name": "Standard",
"entitlement": {
"type": "PerpetualLicense"
},
"recurrence": {
"type": "OneOff"
},
"price": {
"USD": 49.99
}
}
],
"defaultVariationId": "standard"
}
Response
{
"id": "example-product",
"name": "AudioPanel",
"tagline": "Professional audio processing plugin",
"description": "A versatile audio plugin for mixing and mastering",
"notes": null,
"status": "Active",
"purchasable": true,
"website": "https://example.org",
"iconUrl": null,
"currentReleaseVersion": null,
"defaultVariationId": "standard",
"releaseAccessControlLevel": "AllowAnonymous",
"licensingConfiguration": {
"numberOfActivationsPerLicense": 3,
"offlineActivationsEnabled": true,
"autoProvisionOnActivation": false
},
"trialsConfiguration": {
"enabled": true,
"requireAccount": false,
"numberOfDays": 14
},
"pricingConfiguration": [
{
"id": "standard",
"name": "Standard",
"entitlement": {
"type": "PerpetualLicense"
},
"recurrence": {
"type": "OneOff"
},
"price": {
"USD": 49.99
}
}
],
"discounts": []
}
Set custom properties
Use this endpoint to set custom properties on a product. This replaces all existing custom properties on the product. See custom properties for more details on the shape and types of custom properties.
Request body
The body should be a JSON object where each key is the property name, and the value is a custom property object.
Request
PUT https://demo.moonbase.sh/api/products/example-product/custom-properties
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"category": {
"type": "text",
"value": "Audio Tools",
"public": true,
"includeInToken": false
}
}
Response
{
"id": "example-product",
"name": "AudioPanel",
...
}
Product Releases
Product release endpoints let you manage the releases for the products in your Moonbase account. The product release object contains the following:
- Name
version- Type
- string
- Description
The semantic version of this release.
- Name
description- Type
- string
- Nullability
- nullable
- Description
Changelog for this release if any.
- Name
publishedAt- Type
- datetime
- Nullability
- nullable
- Description
ISO-8601 date and time for when this release was published if any.
- Name
downloadUrl- Type
- url
- Description
URL to download this release, based on the storefront mode of your Moonbase account.
- Name
hostedDownloadUrl- Type
- url
- Description
URL to download this release using the Moonbase hosted customer portal.
- Name
downloads- Type
- array
- Description
List of downloadable files for this release. Each download contains the following properties:
- Name
name- Type
- string
- Description
File name for this download
- Name
key- Type
- string
- Description
Unique key for this download.
- Name
platform- Type
- enum(Universal|Windows|Linux|Mac|iOS|Android)
- Description
The intended platform for this download.
- Name
size- Type
- number
- Description
The size of this file in bytes.
- Name
downloadUrl- Type
- url
- Description
URL to download this specific file, based on the storefront mode of your Moonbase account.
- Name
hostedDownloadUrl- Type
- url
- Description
URL to download this specific file using the Moonbase hosted customer portal.
- Name
directUrl- Type
- url
- Description
Direct URL to download this file, will depend on authentication based on your product security settings.
- Name
properties- Type
- object
- Optionality
- optional
- Description
Custom properties attached to this release. See custom properties for more details on the shape and types of custom properties.
Product release example
{
"version": "1.0.0",
"description": null,
"publishedAt": "2023-10-01T07:28:37.147407Z",
"downloadUrl": "https://example.org/?mb_intent=download_product...",
"hostedDownloadUrl": "https://demo.moonbase.sh/download?product_id=example-product&version=1.0.0",
"downloads": [
{
"name": "installer.exe",
"key": "demo/1d7c685e-3a4e-4051-8526-6df436b6fd27",
"platform": "Universal",
"size": 2503,
"downloadUrl": "https://example.org/?mb_intent=download_product...",
"hostedDownloadUrl": "https://demo.moonbase.sh/download?product_id=example-product&version=1.0.0&key=1d7c685e-3a4e-4051-8526-6df436b6fd27",
"directUrl": "https://demo.moonbase.sh/api/customer/inventory/products/example-product/download/1.0.0/1d7c685e-3a4e-4051-8526-6df436b6fd27",
}
]
}
Get product releases
Use this endpoint to fetch all releases for a product page by page. For more details on how pagination works, see pagination.
Optional query parameters
- Name
pageSize- Type
- number
- Optionality
- optional
- Description
Adjust the size of each page returned.
Request
GET https://demo.moonbase.sh/api/products/example-product/releases
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"items": [
{
"version": "1.0.0",
"description": null,
"publishedAt": "2023-10-01T07:28:37.147407Z",
...
}
],
"hasMore": false,
"next": null
}
Create release
Creating a new release lets you expose and publish uploaded files to your customers by tying downloads to a product release.
Required body properties
- Name
version- Type
- object
- Description
Semantic version of the new release. Object with a number for each part:
- Name
major- Type
- number
- Description
Major version part
- Name
minor- Type
- number
- Description
Minor version part
- Name
patch- Type
- number
- Description
Patch version part
- Name
description- Type
- string
- Optionality
- optional
- Description
Optional description of what this release is about.
- Name
downloads- Type
- array
- Description
List of downloads that this release should contain. For more information on how to prepare the key for these downloads, see downloads. Each object in this array must contain the following:
- Name
name- Type
- string
- Description
Name of this file.
- Name
key- Type
- string
- Description
Unique key generated by the download prepare endpoint.
- Name
platform- Type
- enum(Universal|Windows|Linux|Mac|iOS|Android)
- Description
The intended platform for this download.
Optional query parameters
- Name
publishImmediately- Type
- bool
- Optionality
- optional
- Description
Flag that can be given to immediately publish this new release.
Request
POST https://demo.moonbase.sh/api/products/example-product/releases/new
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"version": {
"major": 1,
"minor": 0,
"patch": 0
},
"downloads": [
{
"name": "Installer.exe",
"platform": "Windows",
"key": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa"
}
]
}
Response
{
"version": "1.0.0",
"description": null,
"publishedAt": null,
...
}
Update release
Updating a release replaces the all downloads, and updates the description if given
Required body properties
- Name
description- Type
- string
- Optionality
- optional
- Description
Optional description of what this release is about.
- Name
downloads- Type
- array
- Description
List of downloads that this release should contain. For more information on how to prepare these downloads, see downloads. Each object in this array must contain the following:
- Name
name- Type
- string
- Description
Name of this file.
- Name
key- Type
- string
- Description
Unique key generated by the download prepare endpoint.
- Name
platform- Type
- enum(Universal|Windows|Linux|Mac|iOS|Android)
- Description
The intended platform for this download.
Optional query parameters
- Name
publishImmediately- Type
- bool
- Optionality
- optional
- Description
Flag that can be given to immediately publish this updated release.
Request
PUT https://demo.moonbase.sh/api/products/example-product/releases/1.0.0
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"description": "1.0.0 is the initial release of Example Product",
"downloads": [
{
"name": "Installer.exe",
"platform": "Windows",
"key": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa"
}
]
}
Response
{
"version": "1.0.0",
"description": "1.0.0 is the initial release of Example Product",
"publishedAt": null,
...
}
Add download
Using this endpoint, you can add more downloads to a release. These are deduplicated based on the platform and file name, and is useful if you have separate build steps per platform that each add their own download to new releases.
Required body properties
- Name
name- Type
- string
- Description
Name of this file.
- Name
key- Type
- string
- Description
Unique key generated by the download prepare endpoint.
- Name
platform- Type
- enum(Universal|Windows|Linux|Mac|iOS|Android)
- Description
The intended platform for this download.
Request
PUT https://demo.moonbase.sh/api/products/example-product/releases/1.0.0/add-download
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"name": "Installer.exe",
"platform": "Windows",
"key": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa"
}
Response
{
"version": "1.0.0",
"description": null,
"publishedAt": "2023-10-01T07:28:37.147407Z",
...
}
Publish release
Publish an existing product release. This makes the release available to your customers, and also updates the current version of the product to point to this release.
Request
POST https://demo.moonbase.sh/api/products/example-product/releases/1.0.0/publish
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"version": "1.0.0",
"description": null,
"publishedAt": null,
...
}
Set custom properties
Use this endpoint to set custom properties on a product release. This replaces all existing custom properties on the release. See custom properties for more details on the shape and types of custom properties.
Request body
The body should be a JSON object where each key is the property name, and the value is a custom property object.
Request
PUT https://demo.moonbase.sh/api/products/example-product/releases/1.0.0/custom-properties
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"min_os_version": {
"type": "text",
"value": "14.0",
"public": true,
"includeInToken": false
},
"is_prerelease": {
"type": "boolean",
"value": false,
"public": true,
"includeInToken": false
}
}
Response
{
"version": "1.0.0",
"description": null,
"publishedAt": "2023-10-01T07:28:37.147407Z",
...
}
Downloads
Download endpoints let you upload files to your Moonbase account to use in product releases.
Prepare upload
Prepare to upload a file to Moonbase.
Mandatory query parameters
- Name
contentType- Type
- string
- Description
The MIME type of the content in this file. For binary files, you may use
application/octet-stream. This parameter is important so that customers know what file they are downloading later on.
Response body
- Name
key- Type
- string
- Description
The unique key for this file. Use this when creating product releases to connect the file to the release.
- Name
url- Type
- string
- Description
The URL where you may upload the file. This URL requires no authentication, and you may do a direct PUT with the file content. For example:
curl --upload-file Installer.exe {URL} \ -H 'Content-Type: application/octet-stream'
Request
POST https://demo.moonbase.sh/api/downloads/prepare?contentType=application%2foctet-stream
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"key": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"url": "https://demo.moonbase.sh/..."
}
Vouchers
Voucher endpoints let you manage vouchers, which are one-time-use codes that grant licenses to products and bundles. The voucher object contains the following:
- Name
id- Type
- string
- Description
The Moonbase ID of the voucher.
- Name
name- Type
- string
- Description
The name of the voucher.
- Name
description- Type
- string
- Description
Description of the voucher.
- Name
numberOfCodes- Type
- number
- Description
The number of codes associated with this voucher.
- Name
numberOfRedemptions- Type
- number
- Description
The number of times codes from this voucher have been redeemed.
- Name
redeemsProducts- Type
- array
- Description
List of products that this voucher redeems, each wrapped in a quantity/value object.
- Name
redeemsBundles- Type
- array
- Description
List of bundles that this voucher redeems, each wrapped in a quantity/value object.
- Name
properties- Type
- object
- Optionality
- optional
- Description
Custom properties attached to this voucher. See custom properties for more details on the shape and types of custom properties.
Voucher example
{
"id": "58927685-61ad-4caa-ad6f-8613d7200d4f",
"name": "Demo voucher",
"description": "Used for demo purposes",
"numberOfCodes": 100,
"numberOfRedemptions": 12,
"redeemsProducts": [
{
"quantity": 1,
"value": {
"id": "example-product",
"name": "AudioPanel",
...
}
}
],
"redeemsBundles": [],
"properties": {
"campaign": {
"type": "text",
"value": "summer_2026",
"public": true,
"includeInToken": false
}
}
}
Create voucher
Creates a new voucher with product and bundle entitlements.
Required body properties
- Name
name- Type
- string
- Description
Name of the voucher.
- Name
description- Type
- string
- Description
Description of the voucher.
Optional body properties
- Name
productEntitlements- Type
- record<productId, number>
- Optionality
- optional
- Description
A map of product IDs to the number of licenses to grant per redemption.
- Name
bundleEntitlements- Type
- record<bundleId, number>
- Optionality
- optional
- Description
A map of bundle IDs to the number of licenses to grant per redemption.
Request
POST https://demo.moonbase.sh/api/vouchers/create
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"name": "Demo voucher",
"description": "Used for demo purposes",
"productEntitlements": {
"example-product": 1
}
}
Response
{
"id": "58927685-61ad-4caa-ad6f-8613d7200d4f",
"name": "Demo voucher",
...
}
Get vouchers
Use this endpoint to fetch all vouchers page by page. For more details on how pagination works, see pagination.
Optional query parameters
- Name
pageSize- Type
- number
- Optionality
- optional
- Description
Adjust the size of each page returned.
Request
GET https://demo.moonbase.sh/api/vouchers
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"items": [
{
"id": "58927685-61ad-4caa-ad6f-8613d7200d4f",
"name": "Demo voucher",
...
}
],
"hasMore": false,
"next": null
}
Get voucher by ID
Use this endpoint to look up a voucher by its ID.
Request
GET https://demo.moonbase.sh/api/vouchers/58927685-61ad-4caa-ad6f-8613d7200d4f
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"id": "58927685-61ad-4caa-ad6f-8613d7200d4f",
"name": "Demo voucher",
...
}
Add voucher codes
Adds one or more codes to an existing voucher. Codes are normalized to uppercase.
Request body
The body should be a JSON array of code strings.
Request
PUT https://demo.moonbase.sh/api/vouchers/58927685-61ad-4caa-ad6f-8613d7200d4f/codes
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
[
"VOUCHER-CODE-001",
"VOUCHER-CODE-002"
]
Get voucher codes
Use this endpoint to fetch codes for a voucher page by page. For more details on how pagination works, see pagination.
Optional query parameters
- Name
pageSize- Type
- number
- Optionality
- optional
- Description
Adjust the size of each page returned.
- Name
redeemedBefore- Type
- datetime
- Optionality
- optional
- Description
Filter to codes redeemed before this ISO-8601 date and time.
- Name
redeemedAfter- Type
- datetime
- Optionality
- optional
- Description
Filter to codes redeemed after this ISO-8601 date and time.
Response content
The inner voucher code objects have the following schema:
- Name
voucherId- Type
- string
- Description
The Moonbase ID of the voucher this code belongs to.
- Name
code- Type
- string
- Description
The code string.
- Name
isRedeemed- Type
- boolean
- Description
Flag for if this code has been redeemed.
- Name
redeemedBy- Type
- string
- Optionality
- optional
- Description
The Moonbase ID of the customer who redeemed the code, if redeemed.
- Name
redeemedAt- Type
- datetime
- Optionality
- optional
- Description
ISO-8601 date and time of when the code was redeemed, if redeemed.
Request
GET https://demo.moonbase.sh/api/vouchers/58927685-61ad-4caa-ad6f-8613d7200d4f/codes
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"items": [
{
"voucherId": "58927685-61ad-4caa-ad6f-8613d7200d4f",
"code": "VOUCHER-CODE-001",
"isRedeemed": true,
"redeemedBy": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
"redeemedAt": "2026-03-15T10:30:00Z"
}
],
"hasMore": false,
"next": null
}
Delete voucher code
Deletes a single code from a voucher.
Request
DELETE https://demo.moonbase.sh/api/vouchers/58927685-61ad-4caa-ad6f-8613d7200d4f/codes/VOUCHER-CODE-001
Api-Key: mb_bbdac119b64649f6937e...
Set custom properties
Use this endpoint to set custom properties on a voucher. This replaces all existing custom properties on the voucher. See custom properties for more details on the shape and types of custom properties.
Request body
The body should be a JSON object where each key is the property name, and the value is a custom property object.
Request
PUT https://demo.moonbase.sh/api/vouchers/58927685-61ad-4caa-ad6f-8613d7200d4f/custom-properties
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"campaign": {
"type": "text",
"value": "summer_2026",
"public": true,
"includeInToken": false
}
}
Response
{
"id": "58927685-61ad-4caa-ad6f-8613d7200d4f",
"name": "Demo voucher",
...
}
Coupons
Coupon endpoints let you manage coupons, which provide discount codes for products and bundles. The coupon object contains the following:
- Name
id- Type
- string
- Description
The Moonbase ID of the coupon.
- Name
name- Type
- string
- Description
The name of the coupon.
- Name
description- Type
- string
- Description
Description of the coupon.
- Name
numberOfCodes- Type
- number
- Description
The number of codes associated with this coupon.
- Name
numberOfRedemptions- Type
- number
- Description
The number of times codes from this coupon have been redeemed.
- Name
combinable- Type
- boolean
- Description
Flag for if this coupon can be combined with product discounts.
- Name
discount- Type
- object
- Description
The discount this coupon applies. Can be either a flat amount off or a percentage off discount.
- Name
applicableProducts- Type
- array
- Description
List of products that this coupon can be applied to.
- Name
applicableBundles- Type
- array
- Description
List of bundles that this coupon can be applied to.
- Name
validity- Type
- object
- Optionality
- optional
- Description
Time range during which this coupon is valid, if restricted.
- Name
isDeleted- Type
- boolean
- Description
Flag for if this coupon has been deleted.
- Name
properties- Type
- object
- Optionality
- optional
- Description
Custom properties attached to this coupon. See custom properties for more details on the shape and types of custom properties.
Coupon example
{
"id": "SUMMER2026",
"name": "Summer Sale",
"description": "Summer 2026 promotion",
"numberOfCodes": 500,
"numberOfRedemptions": 42,
"combinable": false,
"discount": {
"type": "PercentageOffDiscount",
"percentage": 0.2
},
"applicableProducts": [ ... ],
"applicableBundles": [],
"validity": null,
"isDeleted": false,
"properties": {
"tracking_id": {
"type": "text",
"value": "promo_summer_2026",
"public": false,
"includeInToken": false
}
}
}
Create coupon
Creates a new coupon with a discount, product and bundle applicability, and an optional validity period.
Required body properties
- Name
name- Type
- string
- Description
Name of the coupon.
- Name
description- Type
- string
- Description
Description of the coupon.
- Name
discount- Type
- object
- Description
The discount this coupon applies. This is a discriminated object based on the
typefield:Percentage off
- Name
type- Type
- 'PercentageOffDiscount'
- Description
Discount type discriminator.
- Name
percentage- Type
- number
- Description
The percentage to discount, normalized to between 0 and 1.
Flat amount off
- Name
type- Type
- 'FlatAmountOffDiscount'
- Description
Discount type discriminator.
- Name
total- Type
- record<currency, number>
- Description
The flat amount to discount per currency.
Optional body properties
- Name
applicableProducts- Type
- record<productId, string[]>
- Optionality
- optional
- Description
A map of product IDs to an array of pricing variation IDs that this coupon applies to.
- Name
applicableBundles- Type
- record<bundleId, string[]>
- Optionality
- optional
- Description
A map of bundle IDs to an array of pricing variation IDs that this coupon applies to.
- Name
validity- Type
- object
- Optionality
- optional
- Description
Time range during which this coupon is valid.
- Name
from- Type
- datetime
- Description
ISO-8601 date and time for when the coupon becomes valid.
- Name
to- Type
- datetime
- Description
ISO-8601 date and time for when the coupon expires.
Request
POST https://demo.moonbase.sh/api/coupons/create
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"name": "Summer Sale",
"description": "Summer 2026 promotion",
"discount": {
"type": "PercentageOffDiscount",
"percentage": 0.2
},
"applicableProducts": {
"example-product": ["default"]
}
}
Response
{
"id": "SUMMER2026",
"name": "Summer Sale",
...
}
Get coupons
Use this endpoint to fetch all coupons page by page. For more details on how pagination works, see pagination.
Optional query parameters
- Name
pageSize- Type
- number
- Optionality
- optional
- Description
Adjust the size of each page returned.
Request
GET https://demo.moonbase.sh/api/coupons
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"items": [
{
"id": "SUMMER2026",
"name": "Summer Sale",
...
}
],
"hasMore": false,
"next": null
}
Get coupon by ID
Use this endpoint to look up a coupon by its ID.
Request
GET https://demo.moonbase.sh/api/coupons/SUMMER2026
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"id": "SUMMER2026",
"name": "Summer Sale",
...
}
Add coupon codes
Adds one or more codes to an existing coupon. You can optionally set a validity period for the individual codes, separate from the coupon's overall validity.
Request body
The body should be a JSON array of code strings.
Optional query parameters
- Name
validFrom- Type
- datetime
- Optionality
- optional
- Description
ISO-8601 date and time for when these codes become valid.
- Name
validTo- Type
- datetime
- Optionality
- optional
- Description
ISO-8601 date and time for when these codes expire.
Request
PUT https://demo.moonbase.sh/api/coupons/SUMMER2026/codes
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
[
"SUMMER-001",
"SUMMER-002"
]
Get coupon codes
Use this endpoint to fetch codes for a coupon page by page. For more details on how pagination works, see pagination.
Optional query parameters
- Name
pageSize- Type
- number
- Optionality
- optional
- Description
Adjust the size of each page returned.
Response content
The inner coupon code objects have the following schema:
- Name
code- Type
- string
- Description
The code string.
- Name
numberOfRedemptions- Type
- number
- Description
The number of times this code has been redeemed.
- Name
validity- Type
- object
- Optionality
- optional
- Description
The validity period for this specific code, if set.
- Name
from- Type
- datetime
- Description
ISO-8601 date and time for when the code becomes valid.
- Name
to- Type
- datetime
- Description
ISO-8601 date and time for when the code expires.
Request
GET https://demo.moonbase.sh/api/coupons/SUMMER2026/codes
Api-Key: mb_bbdac119b64649f6937e...
Response
{
"items": [
{
"code": "SUMMER-001",
"numberOfRedemptions": 3,
"validity": null
}
],
"hasMore": false,
"next": null
}
Delete coupon code
Deletes a single code from a coupon.
Request
DELETE https://demo.moonbase.sh/api/coupons/SUMMER2026/codes/SUMMER-001
Api-Key: mb_bbdac119b64649f6937e...
Set custom properties
Use this endpoint to set custom properties on a coupon. This replaces all existing custom properties on the coupon. See custom properties for more details on the shape and types of custom properties.
Request body
The body should be a JSON object where each key is the property name, and the value is a custom property object.
Request
PUT https://demo.moonbase.sh/api/coupons/SUMMER2026/custom-properties
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json
{
"tracking_id": {
"type": "text",
"value": "promo_summer_2026",
"public": false,
"includeInToken": false
}
}
Response
{
"id": "SUMMER2026",
"name": "Summer Sale",
...
}