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 under Account settings > Developer in Moonbase, 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...'

A key has full access, or is restricted to the areas you choose, each with Read or Read & write access: products, customers, orders, subscriptions, licenses, activations, trials, coupons, vouchers, affiliates and campaigns. When a restricted key calls an endpoint outside its access, the API responds with 403: Forbidden, and missingScopes in the response body names the access it needs, such as customers:read or orders:write.


Rate limits

Core API requests are limited to 500 requests per minute.

If your server calls the Storefront API or Licensing API on behalf of your customers, include your API key on those requests too, so they are not limited by IP address.

When you exceed the limit, the API responds with 429: Too Many Requests and a Retry-After header telling you how many seconds to wait. Rather than hard-coding the limit into your client, honor Retry-After and back off until the window resets.

  • Name
    Retry-After
    Type
    number
    Description

    Present on 429 responses. The number of seconds to wait before retrying.

429 response

HTTP/1.1 429 Too Many Requests
Retry-After: 60

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.

  • Name
    pageSize
    Type
    number
    Description

    The actual page size applied to this response. Requested pageSize values are clamped to a per-endpoint maximum (typically between 100 and 500) — read this field to confirm the effective limit rather than assuming the request value was honored.

Pagination example

{
    "items": [
        {
            ...
        }
    ],
    "hasMore": true,
    "next": "/api/customers?paginationToken=...",
    "pageSize": 100
}

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 public set to false will 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, or hyphens.
  • 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. Not every customer has an account: newsletter contacts, such as people who subscribed through a sign-up form or were imported from a mailing list, are customers too, and get an account once they sign up or buy with the same email address. The customer object will contain the following fields:

  • Name
    id
    Type
    string
    Description

    The Moonbase ID of the customer.

  • Name
    name
    Type
    string
    Nullability
    nullable
    Description

    The full name of the customer. Can be null for a newsletter contact imported without a name.

  • 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
    hasAccount
    Type
    boolean
    Description

    Flag for if the customer has an account they can sign in with. false for a newsletter contact, until they sign up or buy with the same email address.

  • 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 as City.

    • Name
      region
      Type
      string
      Description

      Region of the address, only required if no locality is given.
      Also known as State.

  • 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,
    "hasAccount": true,
    "isDeleted": false,
    "ownedProducts": [
        "example-app"
    ],
    "subscribedProducts": [],
    "address": null,
    "communicationPreferences": {
        "newsletterOptIn": true
    },
    "properties": {
        "company_size": {
            "type": "number",
            "value": 50,
            "public": false,
            "includeInToken": false
        }
    }
}

GET Authenticated/api/customers

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.

  • Name
    before
    Type
    datetime
    Optionality
    optional
    Description

    ISO-8601 timestamp; only return customers created before this point in time.

  • Name
    after
    Type
    datetime
    Optionality
    optional
    Description

    ISO-8601 timestamp; only return customers created after this point in time.

Request

POST
/api/customers
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 Authenticated/api/customers/{id|email}

Get customer by ID or email

Use this endpoint to look up a customer by their ID or email address.

Request

POST
/api/customers/{id|email}
GET https://demo.moonbase.sh/api/customers/tobias@moonbase.sh
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
    "name": "Tobias",
    ...
}

POST Authenticated/api/customers/import

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.

To bring over a mailing list instead, set createAccount to false. That imports each address as a newsletter contact without an account, the same kind of customer a newsletter sign-up form creates. A contact needs no name, has no password, and gets an account once they sign up or buy with the same email address.

In case a customer 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. Optional when createAccount is false.

  • 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
    createAccount
    Type
    boolean
    Optionality
    optional
    Description

    Whether to import the customer with an account. Defaults to true. Set it to false to import a newsletter contact without an account, and send communicationPreferences.newsletterOptIn as true along with it, or the contact will not receive your newsletters.

  • Name
    password
    Type
    string
    Optionality
    optional
    Description

    The initial password for the user. Must contain lower case characters, uppercase characters, numbers and a symbol. Not allowed when createAccount is false: the request is rejected with 400: Bad Request, since a contact sets their password when they sign up.

  • Name
    externalId
    Type
    string
    Optionality
    optional
    Description

    ID of this customer in your existing system, useful for cross-referencing with other systems.

  • Name
    createdAt
    Type
    datetime
    Optionality
    optional
    Description

    ISO-8601 timestamp to backfill the customer's creation date when migrating from another system.

  • 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 as City.

    • Name
      region
      Type
      string
      Description

      Region of the address, only required if no locality is given.
      Also known as State.

  • Name
    businessName
    Type
    string
    Optionality
    optional
    Description

    Registered business name, for a customer buying on behalf of a company.

  • Name
    taxId
    Type
    string
    Optionality
    optional
    Description

    The customer's business tax ID, for example a VAT number. Requires address to be supplied with a countryCode: the issuing country decides how the ID is interpreted, and there is no existing customer to fall back on during an import, so a taxId without one is rejected rather than dropped.

  • Name
    communicationPreferences
    Type
    object
    Optionality
    optional
    Description

    The existing communication preferences the customer has given, if any.
    Leaving a value out records no decision for that channel rather than an opt-out.
    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. Omit it and the newsletter decision covers this channel too, since systems you import from rarely separate the two.

Request

POST
/api/customers/import
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",
    "hasAccount": true,
    ...
}

Request without an account

POST
/api/customers/import
POST https://demo.moonbase.sh/api/customers/import
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "email": "subscriber@example.com",
    "createAccount": false,
    "communicationPreferences": {
        "newsletterOptIn": true
    }
}

PATCH Authenticated/api/customers/{id}

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
    phone
    Type
    string
    Optionality
    optional
    Description

    Phone number of the customer.

  • 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
/api/customers/{id}
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 Authenticated/api/customers/{id}

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
/api/customers/{id}
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",
    ...
}

PUT Authenticated/api/customers/{id}/custom-properties

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
/api/customers/{id}/custom-properties
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",
    ...
}

Orders

An order represents a customer purchase in Moonbase. Every checkout, whether paid or free, creates an order that moves through a short lifecycle: it starts Open, becomes Paid once payment is captured, and then Completed once Moonbase has fulfilled it by issuing licenses and sending the receipt. Use these endpoints to read orders from other systems, for example to reconcile revenue or sync purchases into your own tooling, to prepare an order for a customer to pay for, to record sales another store or reseller makes as they happen, or to import purchases made before you moved to Moonbase.

The order object contains the following:

  • Name
    id
    Type
    string
    Description

    Unique identifier of the order.

  • Name
    status
    Type
    enum(Open|PaymentProcessing|Paid|Completed|Failed)
    Description

    The current status of the order:

    • Open: The order has been created but not yet paid.
    • PaymentProcessing: Payment is being processed.
    • Paid: Payment has been captured, fulfillment is pending.
    • Completed: The order has been paid and fulfilled.
    • Failed: The payment failed and the order was not completed.
  • Name
    currency
    Type
    string
    Description

    The currency used for this purchase.

  • Name
    channel
    Type
    string
    Description

    Where the sale was made: moonbase for your Moonbase checkout, import for imported orders without a channel of their own, or the channel a sale was recorded or imported under, such as my-shopify-store.

  • Name
    externalId
    Type
    string
    Optionality
    optional
    Description

    The order's reference in the store where it was made, for a recorded or imported order, stored trimmed and in lowercase. Omitted on orders from your Moonbase checkout.

  • Name
    completedAt
    Type
    datetime
    Optionality
    optional
    Description

    The timestamp for when the order was completed. Omitted while the order is not completed.

  • Name
    refundedAt
    Type
    datetime
    Optionality
    optional
    Description

    The timestamp for when the order was fully refunded. Omitted while the order is not fully refunded.

  • Name
    isFullyRefunded
    Type
    boolean
    Description

    Whether the entire order has been refunded. Remains false for a partial refund, even though refundHistory lists the refunded amounts.

  • Name
    isPartiallyRefunded
    Type
    boolean
    Description

    Whether the order has been partially but not fully refunded. true once at least one refund has settled while the order still has unrefunded units.

  • Name
    totalRefundedAmount
    Type
    object
    Optionality
    optional
    Description

    The total amount refunded across all settled refunds, with currency and amount properties. Omitted while nothing has been refunded.

  • Name
    refundHistory
    Type
    array
    Optionality
    optional
    Description

    The settled refunds applied to this order, present once at least one refund has settled. Each entry describes a single refund:

    • Name
      id
      Type
      string
      Description

      Unique identifier of the refund.

    • Name
      at
      Type
      datetime
      Description

      The timestamp for when this refund was made.

    • Name
      amount
      Type
      object
      Description

      The amount refunded to the customer in this refund, containing:

      • currency: The currency of the refunded amount.
      • amount: The refunded amount.
    • Name
      lineItems
      Type
      array
      Description

      The order line items covered by this refund, each containing:

      • Name
        lineItemId
        Type
        string
        Description

        Identifier of the refunded order line item. Matches the lineItemId of an entry in the order's items array.

      • Name
        quantity
        Type
        number
        Description

        The number of units refunded for this line item in this refund.

      • Name
        amount
        Type
        object
        Description

        The amount refunded to the customer for this line item, with the same currency and amount properties as above.

    • Name
      kind
      Type
      enum(Sale|TaxAdjustment)
      Description

      What the refund returned. Sale for a refund of the purchase itself, TaxAdjustment for over-collected tax returned after business details were applied to a completed purchase. A TaxAdjustment refunds no units, so each of its lineItems carries a quantity of 0, and neither isFullyRefunded nor isPartiallyRefunded changes.

    • Name
      reason
      Type
      enum(Duplicate|PurchasedByMistake|ChangedMind|NotAsExpected|TechnicalIssues|Fraudulent|Other)
      Nullability
      nullable
      Description

      Why the order was refunded. null when no reason was given, and on a TaxAdjustment.

    • Name
      comment
      Type
      string
      Nullability
      nullable
      Description

      Anything added about the refund when it was made.

  • Name
    isDisputed
    Type
    boolean
    Description

    Flag indicating if this purchase has been disputed.

  • Name
    total
    Type
    object
    Description

    Calculated total for all items part of the order. Each value is an object with currency and amount properties:

    • original: The original amount before discounts.
    • discount: The total amount of discounts applied.
    • subtotal: The total amount after discounts have been removed.
    • taxes: Total taxes to pay, may be inclusive or exclusive of the subtotal depending on configuration, currency and region.
    • due: How much is being paid in total by the customer.
  • Name
    payout
    Type
    object
    Optionality
    optional
    Description

    Payout details for this order, only present if an amount is to be paid out. Note that this may get updated as affiliate revenue splits are calculated later in the pipeline.

    • subtotal: The original amount paid by the customer.
    • taxes: The total amount of taxes collected and remitted.
    • platformFees: The total amount of fees going to Moonbase.
    • due: How much is being paid out to you.
  • Name
    customer
    Type
    object
    Optionality
    optional
    Description

    Billing details about the customer who made the purchase:

    • Name
      name
      Type
      string
      Description

      Full name of the customer.

    • Name
      businessName
      Type
      string
      Nullability
      nullable
      Description

      In case the purchase was a business purchase, this field will have the name.

    • Name
      taxId
      Type
      string
      Nullability
      nullable
      Description

      In case the purchase was a business purchase, this field will have the tax id if given.

    • Name
      email
      Type
      string
      Description

      Email address of the customer.

    • Name
      phone
      Type
      string
      Nullability
      nullable
      Description

      Phone number of the customer. Note that collecting phone numbers is an optional feature in Moonbase and not activated by default.

    • Name
      address
      Type
      object
      Nullability
      nullable
      Description

      Billing address for the customer, not present if the purchase was a lead generator purchase. 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 as City.

      • Name
        region
        Type
        string
        Description

        Region of the address, only required if no locality is given.
        Also known as State.

  • Name
    couponsApplied
    Type
    array
    Description

    The coupons applied to this order, if any. Each entry contains:

    • Name
      id
      Type
      string
      Description

      Unique identifier of the coupon.

    • Name
      code
      Type
      string
      Description

      The coupon code that was redeemed.

    • Name
      name
      Type
      string
      Description

      Display name of the coupon.

    • Name
      description
      Type
      string
      Description

      Description of the coupon.

    • Name
      combinable
      Type
      boolean
      Description

      Whether this coupon can be combined with other discounts.

    • Name
      discount
      Type
      object
      Description

      The discount granted by the coupon, discriminated using the type property:

      • PercentageOffDiscount: has a percentage property with a value between 0 and 1.
      • FlatAmountOffDiscount: has a total property mapping currency codes to amounts.
    • Name
      applicableProductVariations
      Type
      object
      Description

      Map of product IDs to the pricing variation IDs the coupon applies to. Empty when the coupon applies to the whole order.

    • Name
      applicableBundleVariations
      Type
      object
      Description

      Map of bundle IDs to the pricing variation IDs the coupon applies to. Empty when the coupon applies to the whole order.

  • Name
    items
    Type
    array
    Description

    Collection of items part of the order. Note that this can be either products or bundles, and they are discriminated using the type property. Some properties are specific to each type, others are shared:

      Product line item

    • Name
      type
      Type
      'Product'
      Description

      Item type discriminator.

    • Name
      productId
      Type
      string
      Description

      The unique ID of the product.

    • Name
      targetLicenseId
      Type
      string
      Optionality
      optional
      Description

      The customer's license this line upgrades or renews, for a license that covers only some releases.

      Bundle line item

    • Name
      type
      Type
      'Bundle'
      Description

      Item type discriminator.

    • Name
      bundleId
      Type
      string
      Description

      The unique ID of the bundle.

      Shared

    • Name
      lineItemId
      Type
      string
      Description

      Stable identifier of this order line item. Use it to correlate entries in refundHistory back to the line they refunded.

    • Name
      variationId
      Type
      string
      Description

      The ID of the selected pricing variation.

    • Name
      quantity
      Type
      number
      Description

      The quantity of this item.

    • Name
      price
      Type
      object
      Description

      The original per-unit price, as a map of currency codes to amounts.

    • Name
      total
      Type
      object
      Description

      The calculated total for this line item, with original, discount, subtotal and due amounts.

      When you need to know where the discount came from, the line total also splits it per source, each amount being what one unit of the line was discounted by: productDiscount for the discount on the product itself, offerDiscount for an offer picked for this item, couponDiscount for a redeemed code, and cartOfferDiscount for this line's share of a cart offer applied to the order as a whole. All four are omitted on older orders that were priced before the split existed.

    • Name
      received
      Type
      object
      Optionality
      optional
      Description

      For a sale made elsewhere, what the store or reseller paid you for this line after keeping its cut, excluding tax, with currency and amount properties. Omitted unless it was sent when the order was recorded or imported.

    • Name
      variation
      Type
      object
      Optionality
      optional
      Description

      Details about the selected pricing variation, including its id, name, entitlement, recurrence and price.

    • Name
      fulfillment
      Type
      object
      Optionality
      optional
      Description

      Details about how the line item was fulfilled, discriminated using the type property. For a License fulfillment this includes the issued licenseIds, and extendedLicenseIds for the licenses an upgrade or renewal extended instead.

    • Name
      refundedAmount
      Type
      object
      Optionality
      optional
      Description

      The amount refunded for this line item so far, with currency and amount properties. Omitted while nothing has been refunded for the line.

    • Name
      isLineFullyRefunded
      Type
      boolean
      Description

      Whether every unit of this line item has been refunded.

  • Name
    created
    Type
    object
    Description

    When the order was created, containing an at timestamp.

  • Name
    lastUpdated
    Type
    object
    Description

    When the order was last updated, containing an at timestamp.

  • Name
    withdrawalConsent
    Type
    object
    Optionality
    optional
    Description

    The consumer right of withdrawal on this order. EU and EEA consumers have to waive it at checkout before their purchase can be delivered. Omitted on orders the right does not cover, which is every order billed outside the EU and EEA and every business purchase.

    • Name
      required
      Type
      boolean
      Description

      Whether the buyer has to waive the right to check out.

    • Name
      statement
      Type
      string
      Description

      The wording the buyer agreed to, or is being asked to agree to.

    • Name
      grantedAt
      Type
      datetime
      Optionality
      optional
      Description

      When the buyer waived the right. Omitted until they do, so a required consent without grantedAt is an order the buyer can still withdraw from.

  • Name
    receiptUrl
    Type
    string
    Optionality
    optional
    Description

    A link to the order's receipt as a PDF, for you to send to your customer, for example from your own emails or support replies. It opens without signing in and does not expire, so anyone holding it can read the receipt, including the buyer's name, address and tax ID. Send it to the buyer only, rather than logging it or putting it on a page others can see.

    Present once the order is completed. Omitted on orders paid outside Moonbase, recorded or imported, since the customer has a receipt from whoever took their payment. Always use this field rather than building a receipt link from the order ID, which will not open.

Order example

{
    "id": "dc0b53f9-4e43-4179-8554-00f2a8228a25",
    "status": "Completed",
    "currency": "EUR",
    "channel": "moonbase",
    "completedAt": "2024-11-11T11:11:11.0000000Z",
    "isFullyRefunded": false,
    "isPartiallyRefunded": false,
    "isDisputed": false,
    "total": {
        "original": { "currency": "EUR", "amount": 10 },
        "discount": { "currency": "EUR", "amount": 5 },
        "subtotal": { "currency": "EUR", "amount": 5 },
        "taxes": { "currency": "EUR", "amount": 0 },
        "due": { "currency": "EUR", "amount": 5 }
    },
    "payout": {
        "subtotal": { "currency": "EUR", "amount": 5 },
        "taxes": { "currency": "EUR", "amount": 0 },
        "platformFees": { "currency": "EUR", "amount": 0.5 },
        "due": { "currency": "EUR", "amount": 4.5 }
    },
    "customer": {
        "name": "Example User",
        "businessName": null,
        "taxId": null,
        "email": "user@example.com",
        "phone": null,
        "address": {
            "countryCode": "NO",
            "streetAddress1": "Utsikten 6",
            "streetAddress2": null,
            "locality": "Skien",
            "region": null,
            "postCode": "3718"
        }
    },
    "couponsApplied": [
        {
            "id": "43396b94-53b4-4901-8e9e-ab1d6ee7d3b5",
            "code": "MY-UNIQUE-CODE",
            "name": "Half off coupon",
            "description": "Thanks for being our customer!",
            "combinable": false,
            "discount": {
                "type": "PercentageOffDiscount",
                "percentage": 0.5
            },
            "applicableProductVariations": {},
            "applicableBundleVariations": {}
        }
    ],
    "items": [
        {
            "type": "Product",
            "lineItemId": "7c1f0b2a-9d3e-4a5b-8c6d-0e1f2a3b4c5d",
            "productId": "example-app",
            "variationId": "v802c5",
            "quantity": 1,
            "price": {
                "EUR": 10
            },
            "total": {
                "original": { "currency": "EUR", "amount": 10 },
                "discount": { "currency": "EUR", "amount": 5 },
                "subtotal": { "currency": "EUR", "amount": 5 },
                "due": { "currency": "EUR", "amount": 5 }
            },
            "variation": {
                "id": "v802c5",
                "name": "Default",
                "entitlement": { "type": "PerpetualLicense" },
                "recurrence": { "type": "OneOff" },
                "price": { "EUR": 10 }
            },
            "fulfillment": {
                "type": "License",
                "licenseIds": [
                    "d564a47a-d7f3-48ea-8698-57ad7512b11d"
                ]
            },
            "isLineFullyRefunded": false
        }
    ],
    "created": { "at": "2024-11-11T11:11:10.0000000Z" },
    "lastUpdated": { "at": "2024-11-11T11:11:11.0000000Z" },
    "withdrawalConsent": {
        "required": true,
        "statement": "I want immediate access to my purchase, and I acknowledge that I thereby lose my 14-day right of withdrawal.",
        "grantedAt": "2024-11-11T11:11:10.0000000Z"
    },
    "receiptUrl": "https://demo.moonbase.sh/api/customer/orders/dc0b53f9-4e43-4179-8554-00f2a8228a25/receipt?t=CfDJ8Nw3..."
}

GET Authenticated/api/orders

Get orders

Use this endpoint to fetch all orders page by page, newest first. 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
    status
    Type
    enum(Open|PaymentProcessing|Paid|Completed|Failed)
    Optionality
    optional
    Description

    Only return orders with the given status.

  • Name
    before
    Type
    datetime
    Optionality
    optional
    Description

    ISO-8601 timestamp; only return orders created before this point in time.

  • Name
    after
    Type
    datetime
    Optionality
    optional
    Description

    ISO-8601 timestamp; only return orders created after this point in time.

Request

GET
/api/orders
GET https://demo.moonbase.sh/api/orders
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "items": [
        {
            "id": "dc0b53f9-4e43-4179-8554-00f2a8228a25",
            "status": "Completed",
            "currency": "EUR",
            ...
        }
    ],
    "hasMore": false,
    "next": null
}

GET Authenticated/api/orders/{id}

Get order by ID

Use this endpoint to look up a single order by its ID. If no order exists with the given ID, the API responds with 404: Not Found.

This is also how you get a receipt link to send a customer who asks for their receipt: a completed order comes with its receiptUrl.

Request

GET
/api/orders/{id}
GET https://demo.moonbase.sh/api/orders/dc0b53f9-4e43-4179-8554-00f2a8228a25
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "dc0b53f9-4e43-4179-8554-00f2a8228a25",
    "status": "Completed",
    "currency": "EUR",
    ...
    "receiptUrl": "https://demo.moonbase.sh/api/customer/orders/dc0b53f9-4e43-4179-8554-00f2a8228a25/receipt?t=CfDJ8Nw3..."
}

GET Authenticated/api/orders/external

Get order by external ID

Use this endpoint to find an order you recorded or imported by its reference in the store where it was made, for example when that store tells you about a refund. Letter case and surrounding whitespace are ignored. If no order has the reference, the API responds with 404: Not Found.

Required query parameters

  • Name
    externalId
    Type
    string
    Description

    The order's reference in the store where it was made.

Request

GET
/api/orders/external
GET https://demo.moonbase.sh/api/orders/external?externalId=SHOP-1001
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "2b9d5c1e-7f4a-5e3b-9c8d-1a2b3c4d5e6f",
    "status": "Completed",
    "currency": "EUR",
    "channel": "my-shopify-store",
    "externalId": "shop-1001",
    ...
}

POST Authenticated/api/orders/prepare

Prepare order

Use this endpoint to put an order together on your own server and send the customer straight to checkout to pay for it, for example from your app, a sales tool or a support conversation. Prices come from the products and bundles in your Moonbase account.

The response is the new order with a status of Open, along with three URLs to pay for it. Which one you use decides how checkout is presented:

  • Name
    checkoutUrl
    Type
    string
    Description

    URL to pay for the order, pointing at whichever checkout the storefront mode of your Moonbase account is configured for.

  • Name
    hostedCheckoutUrl
    Type
    string
    Description

    URL to pay for the order on the Moonbase hosted checkout, as a full-page navigation.

  • Name
    embeddedCheckoutUrl
    Type
    string
    Description

    URL to pay for the order in an iframe on a page of your own.

The checkout URLs are only returned here, not when you get the order later. If the request names a customer that does not exist, or is otherwise invalid, the API responds with 400: Bad Request and a description of the problem.

Required body properties

  • Name
    currency
    Type
    string
    Description

    Three-letter code of the currency to price the order in, for example USD. Checkout may still change it based on the customer's location and your account settings.

  • Name
    items
    Type
    array
    Description

    The products and bundles the customer is buying, each containing:

    • Name
      type
      Type
      enum(Product|Bundle)
      Description

      Whether this item is a product or a bundle.

    • Name
      productId
      Type
      string
      Description

      The ID of the product. Required when type is Product.

    • Name
      bundleId
      Type
      string
      Description

      The ID of the bundle. Required when type is Bundle.

    • Name
      variationId
      Type
      string
      Optionality
      optional
      Description

      The ID of the pricing variation to sell. Defaults to the default pricing variation of the product or bundle.

    • Name
      quantity
      Type
      number
      Description

      The number of units to sell.

    • Name
      targetLicenseId
      Type
      string
      Optionality
      optional
      Description

      For a product sold with licenses that cover only some releases, the customer's license this item upgrades or renews. Buying it extends that license instead of issuing a new one, and any upgrade discount on the product applies. The quantity must be 1, and each license can only be named once per order, so add one item per license. Without it, the purchase issues new licenses.

Optional body properties

  • Name
    customer
    Type
    object
    Optionality
    optional
    Description

    Billing details to prefill at checkout, with the same name, businessName, taxId, email, phone and address properties as the order's customer.

  • Name
    customerId
    Type
    string
    Optionality
    optional
    Description

    The ID of an existing customer to attach the order to. The purchase goes to this customer's account whatever email address is entered at checkout. When you leave out customer, the checkout is prefilled with this customer's details.

Optional query parameters

  • Name
    returnUrl
    Type
    string
    Optionality
    optional
    Description

    Where the customer should be sent after a successful purchase.

Request

POST
/api/orders/prepare
POST https://demo.moonbase.sh/api/orders/prepare?returnUrl=https%3A%2F%2Fexample.com%2Fthanks
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "currency": "USD",
    "items": [
        {
            "type": "Product",
            "productId": "example-app",
            "quantity": 1
        }
    ],
    "customer": {
        "name": "Example User",
        "email": "user@example.com"
    }
}

Response

{
    "id": "5d3a2c26-d09f-45b3-b018-3461c20efc23",
    "status": "Open",
    "currency": "USD",
    ...
    "checkoutUrl": "https://demo.moonbase.sh/checkout/5d3a2c26-d09f-45b3-b018-3461c20efc23?return=https%3A%2F%2Fexample.com%2Fthanks",
    "hostedCheckoutUrl": "https://demo.moonbase.sh/checkout/5d3a2c26-d09f-45b3-b018-3461c20efc23?return=https%3A%2F%2Fexample.com%2Fthanks",
    "embeddedCheckoutUrl": "https://demo.moonbase.sh/embedded/checkout/5d3a2c26-d09f-45b3-b018-3461c20efc23?return=https%3A%2F%2Fexample.com%2Fthanks"
}

POST Authenticated/api/orders/external

Record external order

Use this endpoint to record a sale another store or reseller has just made, so Moonbase delivers it the way it delivers a checkout. Moonbase issues the licenses, from Moonbase, the product's key pool or its license generator, or attaches the keys the store already gave the buyer. The completed order then reaches your webhooks, marketing integrations, customer groups and automations like any other sale.

The response is the order with a status of Paid. Delivery follows within moments: the OrderCompleted webhook tells you when, and the order then lists the licenses on each line. An order that cannot be delivered, for example because the key pool ran out, is listed under Sales > Failed in Moonbase for you to retry.

Since the payment was taken elsewhere, the order is never part of your payouts, and Moonbase does not send the buyer a receipt or order confirmation. Put the accountLink from the response in the receipt your store sends, so the buyer can find their purchase in your customer portal:

  • Name
    accountLink
    Type
    object
    Optionality
    optional
    Description

    The link the buyer creates their account or logs in with, the same one a Moonbase order confirmation would carry. Only returned by this endpoint, and omitted when your Moonbase account has no customer portal.

    • Name
      kind
      Type
      enum(CreateAccount|LogIn)
      Description

      CreateAccount for a buyer without a password yet, who confirms their email address and chooses one. LogIn for a buyer who already has an account.

    • Name
      url
      Type
      string
      Description

      The link itself. A CreateAccount link lets whoever holds it set the account's password, so give it to the buyer only. It is valid for 30 days, and a buyer who follows an expired one is emailed a new one.

Sending the same sale again, with the same externalId, channel and buyer, responds with the order already recorded and a fresh accountLink instead of recording it twice, so a request that timed out is safe to retry. The same externalId for another buyer or channel, or one you imported, responds with 409: Conflict. Any other problem, such as an unknown product, responds with 400: Bad Request describing what is wrong, and nothing is recorded.

Required body properties

  • Name
    externalId
    Type
    string
    Description

    The order's reference in the store where it was made.

  • Name
    channel
    Type
    string
    Description

    Where the sale was made, for example my-shopify-store. Letters, digits and dashes only, stored in lowercase. Sales analytics can filter on it and break revenue down by it. Cannot be moonbase or import.

  • Name
    currency
    Type
    string
    Description

    Three-letter code of the currency the buyer paid in.

  • Name
    lines
    Type
    array
    Description

    The line items of the order, at least one. Amounts follow the tax mode of your prices in that currency: when your prices include tax, so do unitPrice, discount and total, and taxes is the part of them that was tax. Otherwise taxes comes on top. Each line contains:

    • Name
      productId
      Type
      string
      Optionality
      optional
      Description

      The ID of the product sold on this line. Each line needs exactly one of productId and bundleId.

    • Name
      bundleId
      Type
      string
      Optionality
      optional
      Description

      The ID of the bundle sold on this line.

    • Name
      variationId
      Type
      string
      Optionality
      optional
      Description

      The ID of the pricing variation sold. Defaults to the current default pricing variation of the product or bundle. A recurring pricing variation is only accepted when the line carries the keys or licenses the buyer was given, since Moonbase cannot renew a subscription it does not bill.

    • Name
      quantity
      Type
      number
      Optionality
      optional
      Description

      The number of units sold. Defaults to 1.

    • Name
      unitPrice
      Type
      number
      Optionality
      optional
      Description

      The price of one unit before discounts. Defaults to 0.

    • Name
      discount
      Type
      number
      Optionality
      optional
      Description

      The discount on one unit. Defaults to 0.

    • Name
      taxes
      Type
      number
      Optionality
      optional
      Description

      The total tax on the whole line. Defaults to 0.

    • Name
      total
      Type
      number
      Optionality
      optional
      Description

      The total for the whole line, treating tax the same way as unitPrice. Defaults to unitPrice minus discount, times quantity. Supply it to keep the store's own rounding. It has to agree with the per-unit amounts to within a cent per unit.

    • Name
      received
      Type
      number
      Optionality
      optional
      Description

      What the store paid you for the whole line, after keeping its cut and excluding tax. Net revenue in your sales analytics then shows this instead of the buyer's price before tax. It never counts as a payout. Send it on every line of the order or on none, and no more than the buyer paid for the line before tax.

    • Name
      provisionLicenses
      Type
      boolean
      Optionality
      optional
      Description

      Deliver licenses for this line. Without keyCodes or generatedLicenses, Moonbase issues them the way it does at checkout. Leave it out when the store delivered everything the buyer got.

    • Name
      keyCodes
      Type
      array
      Optionality
      optional
      Description

      The license keys the store gave the buyer, one per unit. Requires provisionLicenses, and only works on product lines. Keys from the product's key pool in Moonbase are taken out of the pool, and a key the pool has already issued responds with 409: Conflict.

    • Name
      generatedLicenses
      Type
      array
      Optionality
      optional
      Description

      For a product on a license generator other than iLok, the licenses the generator issued when the store called it, one per unit. Moonbase records them as the generator's own instead of calling it again. Requires provisionLicenses, only works on product lines, and cannot be combined with keyCodes.

    • Name
      licenseExpiresAt
      Type
      datetime
      Optionality
      optional
      Description

      When the licenses from this line expire, as an ISO-8601 date and time. Only accepted with keyCodes or generatedLicenses, since a license Moonbase issues takes its terms from the pricing variation.

Customer properties

Every order needs a buyer. Provide either customerId or customer, not both.

  • Name
    customerId
    Type
    string
    Optionality
    optional
    Description

    The ID of an existing customer who made the purchase.

  • Name
    customer
    Type
    object
    Optionality
    optional
    Description

    The buyer as the store knows them. They are matched to an existing customer by externalId, then by email, and get an account when there is none, as a buyer at checkout does. The order keeps the details given here as its billing details, while an existing customer's profile is left as it is.

    • Name
      email
      Type
      string
      Description

      Email address of the buyer.

    • Name
      name
      Type
      string
      Optionality
      optional
      Description

      Full name of the buyer.

    • Name
      externalId
      Type
      string
      Optionality
      optional
      Description

      ID of this buyer in the store.

    • Name
      address
      Type
      object
      Optionality
      optional
      Description

      Billing address of the buyer, with the same properties as when importing a customer.

    • Name
      businessName
      Type
      string
      Optionality
      optional
      Description

      Registered business name, for a purchase made on behalf of a company.

    • Name
      taxId
      Type
      string
      Optionality
      optional
      Description

      The buyer's business tax ID, for example a VAT number. Only kept when address has a countryCode.

    • Name
      phone
      Type
      string
      Optionality
      optional
      Description

      Phone number of the buyer.

Optional body properties

  • Name
    completedAt
    Type
    datetime
    Optionality
    optional
    Description

    When the purchase was made, as an ISO-8601 date and time. Defaults to now. Taken as UTC when it has no offset, and cannot be in the future.

  • Name
    marketingOptIn
    Type
    boolean
    Optionality
    optional
    Description

    Set to true only when the buyer agreed, where they bought, to hear from you and not just from the store. They are then subscribed to your newsletter and product updates, as with the opt-in at checkout. Without it, Moonbase sends them no marketing emails.

  • Name
    utm
    Type
    object
    Optionality
    optional
    Description

    The UTM tags the buyer arrived at the store with: source, medium, campaign, term, content, and the referrer. Sales analytics break the sale down by them, and a sale tagged by one of your campaigns counts towards its results.

Request

POST
/api/orders/external
POST https://demo.moonbase.sh/api/orders/external
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "externalId": "SHOP-1001",
    "channel": "my-shopify-store",
    "currency": "EUR",
    "customer": {
        "email": "user@example.com",
        "name": "Example User"
    },
    "lines": [
        {
            "productId": "example-app",
            "unitPrice": 40,
            "taxes": 8,
            "received": 22.40,
            "provisionLicenses": true
        }
    ]
}

Response

{
    "id": "2b9d5c1e-7f4a-5e3b-9c8d-1a2b3c4d5e6f",
    "status": "Paid",
    "currency": "EUR",
    "channel": "my-shopify-store",
    "externalId": "shop-1001",
    ...
    "accountLink": {
        "kind": "CreateAccount",
        "url": "https://demo.moonbase.sh/sign-up?email=user%40example.com&code=CfDJ8Nw3..."
    }
}

POST Authenticated/api/orders/external/refunds

Record external refund

Use this endpoint to record a refund or chargeback that the store which sold an order has made, on an order you recorded or imported. No money moves, since the store already returned it. The refunded licenses are revoked, the refund no longer counts towards the customer's lifetime value, and the OrderRefunded webhook is sent, as for a refund made in Moonbase.

The response is the order with the refund in its refundHistory. Sending a refundId that is already recorded responds with the order as it stands, so a retry is safe. If no order has the externalId, the API responds with 404: Not Found. An order that is not completed yet responds with 400: Bad Request, and one that is already fully refunded with 409: Conflict.

Required body properties

  • Name
    externalId
    Type
    string
    Description

    The order's reference in the store where it was made, as you recorded or imported it.

  • Name
    refundId
    Type
    string
    Description

    The refund's reference in the store.

Optional body properties

  • Name
    lines
    Type
    array
    Optionality
    optional
    Description

    The lines and units that were refunded. Leave it out to refund everything not yet refunded. Each entry contains:

    • Name
      lineItemId
      Type
      string
      Description

      The lineItemId of the refunded line on the order.

    • Name
      quantity
      Type
      number
      Optionality
      optional
      Description

      How many of the line's units were refunded. Defaults to all that are left.

  • Name
    refundedAt
    Type
    datetime
    Optionality
    optional
    Description

    When the store made the refund, as an ISO-8601 date and time. Defaults to now. Taken as UTC when it has no offset, and cannot be in the future or before the purchase.

  • Name
    reason
    Type
    enum(Duplicate|PurchasedByMistake|ChangedMind|NotAsExpected|TechnicalIssues|Fraudulent|Other)
    Optionality
    optional
    Description

    Why the order was refunded.

  • Name
    comment
    Type
    string
    Optionality
    optional
    Description

    Anything to add about the refund, up to 1,000 characters.

Request

POST
/api/orders/external/refunds
POST https://demo.moonbase.sh/api/orders/external/refunds
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "externalId": "SHOP-1001",
    "refundId": "SHOP-R-2001",
    "reason": "ChangedMind"
}

Response

{
    "id": "2b9d5c1e-7f4a-5e3b-9c8d-1a2b3c4d5e6f",
    "status": "Completed",
    "currency": "EUR",
    "channel": "my-shopify-store",
    "externalId": "shop-1001",
    "isFullyRefunded": true,
    "isPartiallyRefunded": false,
    ...
}

POST Authenticated/api/orders/import

Import order

Importing an order records a purchase made in another system as a completed order in Moonbase, so your customers' purchase history and lifetime value carry over when you migrate. The order is dated from when the purchase happened, not from when you import it, and importing it sends no emails or webhooks. Since the payment was taken elsewhere, an imported order is never part of your payouts and has no receiptUrl, and a refund the other store makes is recorded rather than paid through Moonbase. For sales another store or reseller is still making, record them as they happen instead.

Each externalId can only be imported once. Importing it again responds with 409: Conflict rather than creating a second order, and letter case and surrounding whitespace are ignored when comparing. Any other problem, such as an unknown product or a line total that does not add up, responds with 400: Bad Request describing what is wrong, and nothing is imported.

Required body properties

  • Name
    externalId
    Type
    string
    Description

    The order's reference in the system you are moving from.

  • Name
    currency
    Type
    string
    Description

    Three-letter code of the currency the purchase was paid in.

  • Name
    completedAt
    Type
    datetime
    Description

    When the purchase happened, as an ISO-8601 date and time. Taken as UTC when it has no offset, and cannot be in the future.

  • Name
    lines
    Type
    array
    Description

    The line items of the order, at least one. Amounts follow the tax mode of your prices in that currency: when your prices include tax, so do unitPrice, discount and total, and taxes is the part of them that was tax. Otherwise taxes comes on top. Each line contains:

    • Name
      productId
      Type
      string
      Optionality
      optional
      Description

      The ID of the product sold on this line. Each line needs exactly one of productId and bundleId.

    • Name
      bundleId
      Type
      string
      Optionality
      optional
      Description

      The ID of the bundle sold on this line.

    • Name
      variationId
      Type
      string
      Optionality
      optional
      Description

      The ID of the pricing variation sold. Defaults to the current default pricing variation of the product or bundle.

    • Name
      quantity
      Type
      number
      Optionality
      optional
      Description

      The number of units sold. Defaults to 1.

    • Name
      unitPrice
      Type
      number
      Optionality
      optional
      Description

      The price of one unit before discounts. Defaults to 0.

    • Name
      discount
      Type
      number
      Optionality
      optional
      Description

      The discount on one unit. Defaults to 0.

    • Name
      taxes
      Type
      number
      Optionality
      optional
      Description

      The total tax on the whole line. Defaults to 0.

    • Name
      total
      Type
      number
      Optionality
      optional
      Description

      The total for the whole line, treating tax the same way as unitPrice: including it when your prices include tax, and before tax otherwise, with taxes added on top. Defaults to unitPrice minus discount, times quantity. Supply it to keep the rounding of the system you are moving from. It has to agree with the per-unit amounts to within a cent per unit.

    • Name
      received
      Type
      number
      Optionality
      optional
      Description

      For a sale a store or reseller made, what it paid you for the whole line, after keeping its cut and excluding tax. Net revenue in your sales analytics then shows this instead of the buyer's price before tax. Send it on every line of the order or on none.

    • Name
      provisionLicenses
      Type
      boolean
      Optionality
      optional
      Description

      Issue the licenses this line delivered, using the product's current license settings. Products that get their licenses from a key pool or an external generator also need keyCodes, since Moonbase will not issue a new key for a purchase that was already fulfilled.

    • Name
      keyCodes
      Type
      array
      Optionality
      optional
      Description

      The license keys this line delivered, one per unit. Requires provisionLicenses, and only works on product lines.

    • Name
      licenseExpiresAt
      Type
      datetime
      Optionality
      optional
      Description

      When the licenses from this line expire, as an ISO-8601 date and time. A date in the past imports them already expired.

Customer properties

Every order needs a customer. Provide either customerId or customer, not both.

  • Name
    customerId
    Type
    string
    Optionality
    optional
    Description

    The ID of an existing customer the purchase belongs to.

  • Name
    customer
    Type
    object
    Optionality
    optional
    Description

    The customer as your previous system knows them. They are matched to an existing customer by externalId, then by email, and created when there is none, without sending them any emails.

    • Name
      email
      Type
      string
      Description

      Email address of the customer.

    • Name
      name
      Type
      string
      Optionality
      optional
      Description

      Full name of the customer.

    • Name
      externalId
      Type
      string
      Optionality
      optional
      Description

      ID of this customer in your previous system.

    • Name
      address
      Type
      object
      Optionality
      optional
      Description

      Billing address of the customer, with the same properties as when importing a customer.

    • Name
      businessName
      Type
      string
      Optionality
      optional
      Description

      Registered business name, for a purchase made on behalf of a company.

    • Name
      taxId
      Type
      string
      Optionality
      optional
      Description

      The customer's business tax ID, for example a VAT number. Only kept when address has a countryCode.

    • Name
      phone
      Type
      string
      Optionality
      optional
      Description

      Phone number of the customer.

Optional body properties

  • Name
    channel
    Type
    string
    Optionality
    optional
    Description

    Where the sale came from, for example my-shopify-store, so you can tell sales from different sources apart. Letters, digits and dashes only, stored in lowercase. Defaults to import.

Request

POST
/api/orders/import
POST https://demo.moonbase.sh/api/orders/import
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "externalId": "ORD-1001",
    "customerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
    "currency": "EUR",
    "completedAt": "2024-03-01T10:00:00Z",
    "lines": [
        {
            "productId": "example-app",
            "quantity": 2,
            "unitPrice": 40,
            "taxes": 16,
            "provisionLicenses": true
        }
    ]
}

Response

{
    "id": "8f14e45f-ceea-567a-9a36-0e4b8c1d2a7b",
    "status": "Completed",
    "currency": "EUR",
    "completedAt": "2024-03-01T10:00:00.0000000Z",
    ...
}

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
    releaseAccess
    Type
    object
    Optionality
    optional
    Description

    What a license that covers only some releases covers. Left out when the license covers every release.

    • Name
      updatesUntil
      Type
      datetime
      Optionality
      optional
      Description

      Releases published until then are covered, and every release while it hasn't passed.

    • Name
      upToMajor
      Type
      number
      Optionality
      optional
      Description

      Every version whose major version is at most this is covered.

    A license with both covers a release that either of them covers.

  • 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 Authenticated/api/licenses

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
/api/licenses
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 Authenticated/api/licenses/{id}

Get license by ID

Use this endpoint to look up a license by its ID.

Request

GET
/api/licenses/{id}
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",
    ...
}

POST Authenticated/api/licenses/provision

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.

    • Name
      expiresAt
      Type
      datetime
      Optionality
      optional
      Description

      ISO-8601 timestamp; if set, the provisioned licenses will expire at this point in time.

    • Name
      releaseAccess
      Type
      object
      Optionality
      optional
      Description

      Limits the licenses to some releases, with an updatesUntil date, an upToMajor version, or both, shaped like the license's releaseAccess. Left out, the licenses cover every release.

Request

POST
/api/licenses/provision
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",
        ...
    }
]

POST Authenticated/api/licenses/import

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 ownerId or ownerEmail must be provided, but not both.

  • Name
    ownerEmail
    Type
    string
    Optionality
    optional
    Description

    Email address of an existing customer that should receive this license. Either ownerId or ownerEmail must be provided, but not both. The customer must already exist in your Moonbase account — 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.

  • Name
    releaseAccess
    Type
    object
    Optionality
    optional
    Description

    Limits the license to some releases, with an updatesUntil date, an upToMajor version, or both, shaped like the license's releaseAccess. Left out, the license covers every release.

Request

POST
/api/licenses/import
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",
    ...
}

POST Authenticated/api/licenses/{licenseId}/revoke

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
/api/licenses/{licenseId}/revoke
POST https://demo.moonbase.sh/api/licenses/32016591-73c5-4956-938c-e34366599bc7/revoke
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "32016591-73c5-4956-938c-e34366599bc7",
    "ownerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
    "productId": "example-app",
    "status": "Active",
    ...
}

PUT Authenticated/api/licenses/{id}/custom-properties

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
/api/licenses/{id}/custom-properties
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 the trials in Moonbase, start trials on your customers' devices, record trials another store gave, 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
    externalId
    Type
    string
    Optionality
    optional
    Description

    The store's reference for a trial recorded from another store, or your own for an imported one. Omitted when not set.

  • Name
    productId
    Type
    string
    Description

    The Moonbase ID of the product that this trial 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
    Optionality
    optional
    Description

    ISO-8601 date and time of the expiry of this trial. Absent for an endless trial, one started while its product's trials never expire.

  • Name
    status
    Type
    enum('Active' | 'Expired')
    Description

    Current status of the trial, if it's active or expired.

  • Name
    customer
    Type
    object
    Optionality
    optional
    Description

    The customer the trial is for, shaped like the customer object. Omitted for a trial nobody owns.

  • Name
    issuedExternally
    Type
    boolean
    Description

    true for a trial recorded from another store, which that store runs with its own licensing. You can't extend or end it in Moonbase, and it has no license token.

  • 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",
    "status": "Expired",
    "expiresAt": "2025-12-08T17:26:35.047223Z",
    "customer": {
        "id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
        "name": "Example User",
        "email": "user@example.com",
        ...
    },
    "issuedExternally": false
}

GET Authenticated/api/trials

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
/api/trials
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 Authenticated/api/trials/{id}

Get trial by ID

Use this endpoint to look up a trial by its ID.

Request

GET
/api/trials/{id}
GET https://demo.moonbase.sh/api/trials/5f113851778f34b175101c65657e7ea8
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "5f113851778f34b175101c65657e7ea8",
    "productId": "example-app",
    "status": "Active",
    ...
}

POST Authenticated/api/trials/{productId}/request

Start trial

Use this endpoint to start a trial of a product on a device for one of your customers, for example from an installer that sets the product up on their computer. Name the customer with customerId or customerEmail, or leave both out for a trial nobody owns, which only a product that doesn't require an account for trials allows. A new trial lasts the product's trial length, and sends the TrialActivated webhook.

A device has one trial of each product. If the device already has one, you get that trial back as it is, with no extra days, whoever it was started for. A trial nobody owned becomes the named customer's. Send the device signature your licensing SDK computes on that device, so the app finds this trial when it requests its own. To put the trial on the device yourself, get its license token.

An unknown product or customer responds with 404: Not Found. A product that doesn't allow trials, or that requires an account when no customer is named, responds with 400: Bad Request. If the product's trials need a newsletter opt-in, the customer must have opted in to your newsletter, or the response is 403: Forbidden.

Required body properties

  • Name
    deviceName
    Type
    string
    Description

    User-friendly name of the device, shown to you and the customer.

  • Name
    deviceSignature
    Type
    string
    Description

    Fingerprint of the device, as generated by the licensing SDK.

Optional body properties

  • Name
    customerId
    Type
    string
    Optionality
    optional
    Description

    Moonbase ID of the customer the trial is for. Cannot be combined with customerEmail.

  • Name
    customerEmail
    Type
    string
    Optionality
    optional
    Description

    Email address of an existing customer the trial is for.

Optional query parameters

The same appVersion, platform and meta parameters as the Licensing API's metadata for analytics, describing the device the trial is for.

Request

POST
/api/trials/{productId}/request
POST https://demo.moonbase.sh/api/trials/example-app/request
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "customerEmail": "user@example.com",
    "deviceName": "Studio Mac",
    "deviceSignature": "89419872hc72nv150989"
}

Response

{
    "id": "5f113851778f34b175101c65657e7ea8",
    "productId": "example-app",
    "deviceName": "Studio Mac",
    "status": "Active",
    "expiresAt": "2026-11-09T12:00:00.0000000Z",
    "customer": {
        "id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
        "email": "user@example.com",
        ...
    },
    "issuedExternally": false,
    ...
}

GET Authenticated/api/trials/{id}/token

Get trial token

Use this endpoint to get the signed license token for a trial, the same token its device gets when it requests the trial itself, so an app that started a trial for a device can put it there. The response body is the token, with a content type of application/jwt.

Getting the token doesn't start the trial again or extend it: an expired trial's token says it has expired. A trial recorded from another store has no token, and responds with 400: Bad Request.

Request

GET
/api/trials/{id}/token
GET https://demo.moonbase.sh/api/trials/5f113851778f34b175101c65657e7ea8/token
Api-Key: mb_bbdac119b64649f6937e...

Response

eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVmMTEzODUxNzc4ZjM0YjE3NTEwMWM2NTY1N2U3ZWE4Ii...

POST Authenticated/api/trials/external

Record external trial

Use this endpoint to record a trial another store or app gave of its own copy of your product, as it starts, so it counts as the customer's trial: it shows on the customer, counts in your trial analytics, and starts the automations and TrialActivated webhooks a trial does. The store's own licensing runs the trial, so Moonbase issues no license token for it, and the product's trial settings don't apply, apart from its trial length when you leave out expiresAt. The trial is marked issuedExternally, and can't be extended or ended in Moonbase.

Sending the same externalId again responds with the trial already recorded instead of recording it twice, so a request that timed out is safe to retry.

To send trials the store gave before, include createdAt. The trial is then recorded as history: dated then and counted on that day, without starting automations or sending webhooks. A trial sent both as it started and later as history is recorded once.

An unknown product responds with 404: Not Found. An unknown customerId, or a createdAt in the future, responds with 400: Bad Request, and nothing is recorded.

Required body properties

  • Name
    productId
    Type
    string
    Description

    Moonbase ID of the product that was tried.

  • Name
    externalId
    Type
    string
    Description

    The store's reference for the trial, up to 200 characters.

Customer properties

Provide either customerId or customer, not both. Leave both out for a trial nobody owns.

  • Name
    customerId
    Type
    string
    Optionality
    optional
    Description

    The ID of an existing customer the trial is for.

  • Name
    customer
    Type
    object
    Optionality
    optional
    Description

    The person trying it as the store knows them. They are matched to an existing customer by externalId, then by email, and get an account when there is none.

    • Name
      email
      Type
      string
      Description

      Email address of the customer.

    • Name
      name
      Type
      string
      Optionality
      optional
      Description

      Full name of the customer.

    • Name
      externalId
      Type
      string
      Optionality
      optional
      Description

      ID of this customer in the store.

Optional body properties

  • Name
    deviceName
    Type
    string
    Optionality
    optional
    Description

    The computer the trial runs on, when the store's trials are per computer, up to 200 characters. Left out, the trial shows as Unknown device.

  • Name
    deviceSignature
    Type
    string
    Optionality
    optional
    Description

    The store's own identifier for that computer, up to 200 characters.

  • Name
    expiresAt
    Type
    datetime
    Optionality
    optional
    Description

    When the store's trial ends, as an ISO-8601 date and time, taken as UTC when it has no offset. Left out, the product's trial length applies from when the trial started, and a product whose trials never expire gives an endless trial.

  • Name
    createdAt
    Type
    datetime
    Optionality
    optional
    Description

    When the store gave the trial, for one sent after the fact, as an ISO-8601 date and time. Records the trial as history, as described above.

Request

POST
/api/trials/external
POST https://demo.moonbase.sh/api/trials/external
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "productId": "example-app",
    "externalId": "SHOP-1001",
    "customer": {
        "email": "user@example.com",
        "name": "Example User"
    },
    "deviceName": "Studio Mac",
    "expiresAt": "2026-11-09T12:00:00Z"
}

Response

{
    "id": "ext_3f9c2b7a1d4e6f8091a2b3c4d5e6f708",
    "externalId": "SHOP-1001",
    "productId": "example-app",
    "deviceName": "Studio Mac",
    "status": "Active",
    "expiresAt": "2026-11-09T12:00:00.0000000Z",
    "customer": {
        "id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
        "name": "Example User",
        "email": "user@example.com",
        ...
    },
    "issuedExternally": true,
    ...
}

POST Authenticated/api/trials/import

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
    externalId
    Type
    string
    Optionality
    optional
    Description

    ID of this trial in your existing system, returned as the trial's externalId.

  • 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
/api/trials/import
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",
    ...
}

PUT Authenticated/api/trials/{id}/custom-properties

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
/api/trials/{id}/custom-properties
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|Private)
    Description

    Current status of the product:

    • Active: The product can be issued licenses for
    • Inactive: The product cannot be used by any customer
    • Private: Licensing, activation and fulfillment work exactly as they do for Active, but the product is hidden from your storefront and from every customer-facing API response unless the requesting customer owns it, and it cannot be purchased. Use it for products you hand out yourself, through this API or through a voucher.

    The status is set in Moonbase rather than through this API, so it is read-only here.

  • Name
    purchasable
    Type
    boolean
    Description

    Flag for if this product can be purchased.

  • Name
    fulfillment
    Type
    object
    Nullability
    nullable
    Description

    How the product is fulfilled, discriminated by its type, or null when it follows your account's default:

    • Moonbase: Moonbase issues the licenses, activated as licensingConfiguration sets out.
    • DigitalProduct: file delivery only. A license records that the customer owns the product, with nothing to activate.
    • KeyCodes: each license carries a key from the product's key code list.
    • ILok: licenses are deposited through the iLok integration, as the iLok product named by productId.
    • Custom: your own license generator, named by its id, issues the licenses.
    • Disabled: a placeholder for a product sold and delivered elsewhere. It can't be bought, trialled or given new releases, and a license for it only records that the customer owns it.
  • 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. Set it with set product icon.

  • 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|AllowGroupMembers|NoAccess)
    Description

    Deprecated, use releaseAccessControl instead. Reports the level configured for the current release, so it cannot describe a product whose categories differ.

  • Name
    releaseAccessControl
    Type
    object
    Description

    Controls who can download releases of this product. Each category of release is controlled separately, so the current release can be open to everyone while older versions stay owner-only and unpublished builds are restricted to a beta group.

    • Name
      pastReleases
      Type
      object
      Description

      Applies to published releases that are no longer the current one.

    • Name
      currentRelease
      Type
      object
      Description

      Applies to the release the product currently points at.

    • Name
      preReleases
      Type
      object
      Description

      Applies to releases that have not been published yet.

    All three have the same shape: a level, plus a groupId that is only present when the level is AllowGroupMembers.

    • AllowAnonymous: anyone can download, no account needed
    • AllowCustomers: any signed-in customer can download
    • AllowOwners: only customers who own or subscribe to the product can download
    • AllowGroupMembers: only members of the customer group named by groupId can download. Membership is the whole test, so owning the product without being in the group is not enough.
    • NoAccess: nobody can download, owners included. The releases are still listed, with their notes, so you can withdraw old versions without hiding their history.

    A product whose status is Private overrides this when a download is actually attempted: every category also requires ownership, and any level other than AllowGroupMembers and NoAccess collapses to owners only. The values reported here are the ones you configured, not the ones a private product resolves to.

  • Name
    customerVisibility
    Type
    enum(WhenOwned|Never|Always)
    Description

    Controls when this product appears in a customer's account area:

    • WhenOwned (default): visible only to customers who own a license for the product.
    • Never: never surfaced to customers — useful for internal SKUs, bundle children, or products that are sold but should not show up in the inventory UI.
    • Always: always visible, even to customers who don't own it — useful for upsell or cross-sell catalogs.
  • 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
      includeInParentLicense
      Type
      boolean
      Description

      For an add-on, whether it is included in its main product's license: a device that activates the main product takes a seat of the add-on too, and the main product's license tokens list it.

  • 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
      endless
      Type
      boolean
      Description

      Whether trials never expire. A trial started while this is on has no expiry, and numberOfDays only applies again once it is turned off.

  • 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 PerpetualLicense or SubscriptionLicense with a grace period. A PerpetualLicense that covers only some releases has a releaseAccess, described under upsert product.

    • Name
      recurrence
      Type
      object
      Description

      The billing recurrence. Either OneOff for a one-time purchase or Recurring with 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 minQuantity and price.

    • 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 PercentageOffDiscount or FlatAmountOffDiscount.

    • 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
      promotionId
      Type
      string
      Optionality
      optional
      Description

      Present when the discount comes from a promotion running across your catalogue. The promotion owns the discount, so it cannot be changed or removed through the product endpoints.

  • 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,
    "fulfillment": {
        "type": "Moonbase"
    },
    "website": null,
    "iconUrl": "https://assets.moonbase.sh/demo/products/example-product/icon/...",
    "currentReleaseVersion": "1.0.0",
    "defaultVariationId": "standard",
    "releaseAccessControlLevel": "AllowOwners",
    "releaseAccessControl": {
        "pastReleases": {
            "level": "AllowOwners"
        },
        "currentRelease": {
            "level": "AllowOwners"
        },
        "preReleases": {
            "level": "AllowGroupMembers",
            "groupId": "beta-testers"
        }
    },
    "customerVisibility": "WhenOwned",
    "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 Authenticated/api/products

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.

  • Name
    status
    Type
    enum(Active|Inactive|Private)
    Optionality
    optional
    Description

    Only return products with this status. Omit it to return products of every status.

  • Name
    activeOnly
    Type
    boolean
    Optionality
    optional
    Description

    Deprecated, use status instead. true is equivalent to status=Active, and it is ignored when status is supplied. Defaults to false.

Request

GET
/api/products
GET https://demo.moonbase.sh/api/products
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "items": [
        {
            "id": "exmaple-product",
            "name": "Example Product",
            ...
        }
    ],
    "hasMore": false,
    "next": null
}

GET Authenticated/api/products/{id}

Get product by ID

Use this endpoint to look up a product by their ID.

Request

GET
/api/products/{id}
GET https://demo.moonbase.sh/api/products/example-product
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "example-product",
    "name": "Example Product",
    ...
}

PUT Authenticated/api/products/{id}

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.

Optional body parameters

  • Name
    tagline
    Type
    string
    Optionality
    optional
    Description

    The tag line of the product.

  • Name
    description
    Type
    string
    Optionality
    optional
    Description

    The description of the product.

  • Name
    parentId
    Type
    string
    Optionality
    optional
    Description

    Parent product ID, used to create sub-products. Sub-products can also be addressed directly by using a dot in the product ID (for example, parent-product.sub-product); when the ID already contains a dot, parentId should be omitted. 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
    fulfillment
    Type
    object
    Optionality
    optional
    Description

    How the product is fulfilled, such as { "type": "Disabled" }: Moonbase, DigitalProduct, KeyCodes or Disabled, as described in the product model. Left unchanged when omitted. ILok and Custom are set up in Moonbase, and sending them here responds with 400: Bad Request.

    Disabled turns the product into a placeholder that is no longer purchasable or offers trials, and keeps its prices. While it stays disabled, making it purchasable, turning trials on, or creating or publishing a release responds with 400: Bad Request. To sell it again, set another type, which can go in the same request that makes it purchasable.

  • Name
    defaultVariationId
    Type
    string
    Optionality
    optional
    Description

    The ID of the default pricing variation.

  • Name
    releaseAccessControl
    Type
    object
    Optionality
    optional
    Description

    Controls who can download releases of this product, one category at a time. Takes pastReleases, currentRelease and preReleases, each an object with a level and, when that level is AllowGroupMembers, the groupId of the customer group whose members may download. See the product schema above for what each level means.

    A category you leave out is left unchanged, so you can restrict pre-releases without restating the other two. Naming a group that does not exist is rejected outright, since a typo would otherwise quietly lock every customer out.

  • Name
    releaseAccessControlLevel
    Type
    enum(AllowAnonymous|AllowCustomers|AllowOwners)
    Optionality
    optional
    Description

    Deprecated, use releaseAccessControl instead. Applies one level to past, current and pre-releases alike, and is ignored when releaseAccessControl is supplied. It cannot express AllowGroupMembers, which needs a group to go with it.

  • Name
    customerVisibility
    Type
    enum(WhenOwned|Never|Always)
    Optionality
    optional
    Description

    Controls when this product is shown in the customer-facing account area. Defaults to WhenOwned. See the product schema above for what each value means.

  • 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
      includeInParentLicense
      Type
      boolean
      Optionality
      optional
      Description

      For an add-on, whether to include it in its main product's license. Left unchanged when omitted, and only an add-on can set it to true.

  • 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
      endless
      Type
      boolean
      Optionality
      optional
      Description

      Whether trials never expire, false when left out. A trial started while this is on has no expiry, and numberOfDays only applies again once it is turned off.

  • 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.

      On a one-off PerpetualLicense, add a releaseAccess to sell licenses that cover only some releases, discriminated by its type:

      • { "type": "TimeLimited", "period": { "count": 12, "unit": "Month" } }: releases published within the period after purchase. unit is Day, Week, Month or Year, up to 10 years.
      • { "type": "MajorVersions", "additionalMajors": 0 }: the major version current at purchase, plus this many later ones. Needs a published release.
      • { "type": "UpToMajor", "major": 2 }: every version up to this major.
      • { "type": "AllReleases" }: removes the limit. Leaving releaseAccess out keeps the variation's current one.

      Older versions are always covered. Not available for add-ons, products with autoProvisionOnActivation, or products whose licenses an external system issues.

    • 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 are Monthly and Yearly. Optionally include renewalPrice to 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) and price (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. Replaces the discounts you manage yourself, so send the full list every time.

    Discounts that a promotion put on the product are left out of this: any entry carrying a promotionId is ignored here, and the product re-attaches the ones its promotions own after the upsert. That makes it safe to read a product, change something, and send the whole thing back without stripping a running sale or duplicating it.

    • 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.

      To price upgrades and renewals of licenses that cover only some releases, use an OwnsSomeOf condition with outdatedLicense, like { "type": "OwnsSomeOf", "productIds": ["example-product"], "includeSubscriptions": false, "outdatedLicense": { "daysBeforeEnd": 30, "daysAfterEnd": 90 } }. It applies to an order line that upgrades a license whose updates end within daysBeforeEnd days, or ended at most daysAfterEnd days ago (no limit when null), or that is limited to an older major version than the current release.

    • 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 from and to datetime fields.

    • Name
      recurringPaymentUseCount
      Type
      number
      Optionality
      optional
      Description

      Number of recurring payments the discount applies to before expiring.

Request

PUT
/api/products/{id}
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,
    "fulfillment": null,
    "website": "https://example.org",
    "iconUrl": null,
    "currentReleaseVersion": null,
    "defaultVariationId": "standard",
    "releaseAccessControlLevel": "AllowAnonymous",
    "releaseAccessControl": {
        "pastReleases": {
            "level": "AllowAnonymous"
        },
        "currentRelease": {
            "level": "AllowAnonymous"
        },
        "preReleases": {
            "level": "AllowAnonymous"
        }
    },
    "customerVisibility": "WhenOwned",
    "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": []
}

PUT Authenticated/api/products/{id}/icon

Set product icon

Use this endpoint to give a product a new icon. Send the image as the icon field of a multipart/form-data body: a PNG, JPEG or WebP image under 4 MB. Moonbase crops it to a square from the middle, scales it to 512 by 512 pixels and serves it as a PNG at the product's iconUrl, in place of the icon it had.

The response is the updated product. An image Moonbase can't read, or one too large to process, responds with 400: Bad Request, and an unknown product with 404: Not Found.

Required form fields

  • Name
    icon
    Type
    file
    Description

    The image file.

Request

PUT
/api/products/{id}/icon
PUT https://demo.moonbase.sh/api/products/example-product/icon
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: multipart/form-data; boundary=MoonbaseBoundary

--MoonbaseBoundary
Content-Disposition: form-data; name="icon"; filename="icon.png"
Content-Type: image/png

(image data)
--MoonbaseBoundary--

Response

{
    "id": "example-product",
    "name": "AudioPanel",
    "iconUrl": "https://assets.moonbase.sh/demo/products/example-product/icon/...",
    ...
}

PUT Authenticated/api/products/{id}/custom-properties

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
/api/products/{id}/custom-properties
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, download their files for a customer, and record downloads you served yourself. 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
      arch
      Type
      enum(Unknown|Universal|X86|X64|Arm|Arm64)
      Optionality
      optional
      Description

      CPU architecture for this download. Omitted when not set. Lets you ship per-architecture binaries on the same release without encoding the arch into the filename.

    • 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": "Windows",
            "arch": "X64",
            "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",
        },
        {
            "name": "installer.exe",
            "key": "demo/9f0a2c7e-b1d4-4f33-9a8a-5e5c8b1bd910",
            "platform": "Windows",
            "arch": "Arm64",
            "size": 2491,
            "downloadUrl": "https://example.org/?mb_intent=download_product...",
            "hostedDownloadUrl": "https://demo.moonbase.sh/download?product_id=example-product&version=1.0.0&key=9f0a2c7e-b1d4-4f33-9a8a-5e5c8b1bd910",
            "directUrl": "https://demo.moonbase.sh/api/customer/inventory/products/example-product/download/1.0.0/9f0a2c7e-b1d4-4f33-9a8a-5e5c8b1bd910",
        }
    ]
}

GET Authenticated/api/products/{productId}/releases

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
/api/products/{productId}/releases
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
}

POST Authenticated/api/products/{productId}/releases/new

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.

    • Name
      arch
      Type
      enum(Unknown|Universal|X86|X64|Arm|Arm64)
      Optionality
      optional
      Description

      CPU architecture for this download. Omit for arch-agnostic binaries. Two downloads with the same name and platform but different arch will coexist on the release.

Optional body properties

  • Name
    publishedAt
    Type
    datetime
    Optionality
    optional
    Description

    With publishImmediately, the date the release came out, for a release published before it reached Moonbase. Can't be in the future. See set release date.

Optional query parameters

  • Name
    publishImmediately
    Type
    bool
    Optionality
    optional
    Description

    Flag that can be given to immediately publish this new release.

Request

POST
/api/products/{productId}/releases/new
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",
            "arch": "X64",
            "key": "demo/49b8da10-2d72-4bdf-bf9c-47e56c184bfa"
        },
        {
            "name": "Installer.exe",
            "platform": "Windows",
            "arch": "Arm64",
            "key": "demo/f3d24a7b-9c4f-4d61-8e2a-72b1a0e3c4d5"
        }
    ]
}

Response

{
    "version": "1.0.0",
    "description": null,
    "publishedAt": null,
    ...
}

PUT Authenticated/api/products/{productId}/releases/{version}

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.

    • Name
      arch
      Type
      enum(Unknown|Universal|X86|X64|Arm|Arm64)
      Optionality
      optional
      Description

      CPU architecture for this download. Omit for arch-agnostic binaries. Two downloads with the same name and platform but different arch will coexist on the release.

Optional body properties

  • Name
    publishedAt
    Type
    datetime
    Optionality
    optional
    Description

    The release date of a published release, or of the one this update publishes. Left out, the date stays as it is.

Optional query parameters

  • Name
    publishImmediately
    Type
    bool
    Optionality
    optional
    Description

    Flag that can be given to immediately publish this updated release.

Request

PUT
/api/products/{productId}/releases/{version}
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": "demo/49b8da10-2d72-4bdf-bf9c-47e56c184bfa"
        }
    ]
}

Response

{
    "version": "1.0.0",
    "description": "1.0.0 is the initial release of Example Product",
    "publishedAt": null,
    ...
}

POST Authenticated/api/products/{productId}/releases/{version}/add-download

Add download

Using this endpoint, you can add more downloads to a release. These are deduplicated based on the platform, architecture, and file name, and is useful if you have separate build steps per platform or architecture that each add their own download to new releases.

If you submit the same name and platform with a different arch, both downloads are kept; submitting the same name, platform, and arch replaces the existing entry. Existing downloads without an arch continue to deduplicate by name and platform as before.

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.

  • Name
    arch
    Type
    enum(Unknown|Universal|X86|X64|Arm|Arm64)
    Optionality
    optional
    Description

    CPU architecture for this download. Omit for arch-agnostic binaries.

Request

POST
/api/products/{productId}/releases/{version}/add-download
POST 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": "demo/49b8da10-2d72-4bdf-bf9c-47e56c184bfa"
}

Response

{
    "version": "1.0.0",
    "description": null,
    "publishedAt": "2023-10-01T07:28:37.147407Z",
    ...
}

POST Authenticated/api/products/{productId}/releases/{version}/publish

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.

Optional query parameters

  • Name
    publishedAt
    Type
    datetime
    Optionality
    optional
    Description

    The date the release came out, for a release published before it reached Moonbase. Can't be in the future. See set release date. A release dated before the current one is published without becoming the current release, and sends no ProductReleasePublished webhook.

Request

POST
/api/products/{productId}/releases/{version}/publish
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,
    ...
}

PUT Authenticated/api/products/{productId}/releases/{version}/release-date

Set release date

Changes the date of a published release, for example to bring over the history of a product you are moving to Moonbase. The dates decide which releases a license with updates for a period covers, so add older releases with their dates before you sell those licenses.

Changing the date doesn't change which release is current, and sends no webhook. Responds with 400: Bad Request if the release isn't published yet, or if the date is in the future.

Required body properties

  • Name
    publishedAt
    Type
    datetime
    Description

    The date the release came out.

Request

PUT
/api/products/{productId}/releases/{version}/release-date
PUT https://demo.moonbase.sh/api/products/example-product/releases/1.0.0/release-date
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "publishedAt": "2025-03-14T00:00:00Z"
}

Response

{
    "version": "1.0.0",
    "description": null,
    "publishedAt": "2025-03-14T00:00:00Z",
    ...
}

PUT Authenticated/api/products/{productId}/releases/{version}/custom-properties

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
/api/products/{productId}/releases/{version}/custom-properties
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",
    ...
}

POST Authenticated/api/products/{productId}/download/{platform}/latest

Download latest release

Use this endpoint to get a link to the current release's file for a platform on behalf of a customer, so your own server or installer can download it for them. Who may download is decided by the product's releaseAccessControl, checked against the customer you name, or against anyone when you name none. Moonbase counts the download as the customer's, like one from their account. A key with read access to products is enough.

platform is one of Universal, Windows, Linux, Mac, iOS or Android, and has to match the file's exactly, so a Universal file is only found under Universal. When the current release has several files for the platform, such as one per architecture, you get the first one: use download release file to choose.

A customer who may not download the release responds with 403: Forbidden, as does naming no customer for a release that only some customers may download. An unknown product or customer, a product without a current release, or a release without a file for the platform responds with 404: Not Found.

Optional body properties

The body is required, so send {} to name no customer.

  • Name
    customerId
    Type
    string
    Optionality
    optional
    Description

    The ID of the customer the download is for.

  • Name
    customerEmail
    Type
    string
    Optionality
    optional
    Description

    The email address of the customer the download is for, instead of customerId. Sending both responds with 400: Bad Request.

Response body

  • Name
    url
    Type
    url
    Description

    Link to the file. It needs no authentication and works for 15 minutes.

  • Name
    version
    Type
    string
    Description

    The version of the release the file belongs to.

  • Name
    name
    Type
    string
    Description

    File name of the download.

  • Name
    platform
    Type
    enum(Universal|Windows|Linux|Mac|iOS|Android)
    Description

    The platform of the download.

  • Name
    size
    Type
    number
    Description

    The size of the file in bytes.

  • Name
    arch
    Type
    enum(Unknown|Universal|X86|X64|Arm|Arm64)
    Optionality
    optional
    Description

    CPU architecture of the download. Omitted when not set.

  • Name
    manifest
    Type
    object
    Optionality
    optional
    Description

    Where an installer puts the file's contents and the license, from the download or, when it has none, the product's default for its platform. Omitted when neither has one.

Request

POST
/api/products/{productId}/download/{platform}/latest
POST https://demo.moonbase.sh/api/products/example-product/download/Windows/latest
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "customerEmail": "user@example.com"
}

Response

{
    "url": "https://...",
    "version": "1.0.0",
    "name": "installer.exe",
    "platform": "Windows",
    "size": 2503,
    "arch": "X64"
}

POST Authenticated/api/products/{productId}/download/{version}/{key}

Download release file

Use this endpoint to get a link to one particular file of a release on behalf of a customer, for example the build for one architecture, or an older version. It works like download latest release: access is decided by the product's releaseAccessControl for that release, which can be one not published yet, and the download counts as the customer's.

version is the release's version, such as 1.0.0, and key is the last part of the download's key as the release lists it, after the /. An unknown product, customer, release or file responds with 404: Not Found, and a customer who may not download the release with 403: Forbidden.

Optional body properties

The body is required, so send {} to name no customer.

  • Name
    customerId
    Type
    string
    Optionality
    optional
    Description

    The ID of the customer the download is for.

  • Name
    customerEmail
    Type
    string
    Optionality
    optional
    Description

    The email address of the customer the download is for, instead of customerId. Sending both responds with 400: Bad Request.

The response has the same shape as for download latest release.

Request

POST
/api/products/{productId}/download/{version}/{key}
POST https://demo.moonbase.sh/api/products/example-product/download/1.0.0/9f0a2c7e-b1d4-4f33-9a8a-5e5c8b1bd910
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "customerId": "6f2c1e9a-4b7d-4c3e-9a1f-8d5b2e7c0a43"
}

Response

{
    "url": "https://...",
    "version": "1.0.0",
    "name": "installer.exe",
    "platform": "Windows",
    "size": 2491,
    "arch": "Arm64"
}

POST Authenticated/api/products/{productId}/download/external

Record external download

Use this endpoint to record a download that your own server, CDN or another store served from its own copy of the product, so it counts as the customer's download in Moonbase, like one from their account. Nothing is checked against the product's releaseAccessControl, and the version doesn't have to be a release in Moonbase.

Responds with 204: No Content. A customer you name has to exist already, for example from a sale or trial you recorded first: an unknown customer responds with 404: Not Found, as does an unknown product. Name no customer to record an anonymous download.

Required body properties

  • Name
    version
    Type
    string
    Description

    The version downloaded, such as 1.4.0.

  • Name
    platform
    Type
    enum(Universal|Windows|Linux|Mac|iOS|Android)
    Description

    The platform of the file downloaded.

Optional body properties

  • Name
    arch
    Type
    enum(Unknown|Universal|X86|X64|Arm|Arm64)
    Optionality
    optional
    Description

    CPU architecture of the file downloaded.

  • Name
    size
    Type
    number
    Optionality
    optional
    Description

    The size of the file in bytes.

  • Name
    externalId
    Type
    string
    Optionality
    optional
    Description

    Your reference for the download, up to 200 characters. Sending the same one again for the product within 7 days records nothing more, so a retried request is not counted twice.

  • Name
    customerId
    Type
    string
    Optionality
    optional
    Description

    The ID of the customer who downloaded it.

  • Name
    customerEmail
    Type
    string
    Optionality
    optional
    Description

    The email address of the customer who downloaded it, instead of customerId. Sending both responds with 400: Bad Request.

Request

POST
/api/products/{productId}/download/external
POST https://demo.moonbase.sh/api/products/example-product/download/external
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "version": "1.4.0",
    "platform": "Windows",
    "arch": "X64",
    "size": 1048576,
    "externalId": "dl_20261026_8812",
    "customerEmail": "user@example.com"
}

Response

HTTP/1.1 204 No Content

Downloads

Download endpoints let you upload files to your Moonbase account to use in product releases. Prepare upload takes a whole file in one request, up to 5 GB. For a larger file, or to retry a failed piece instead of the whole file, upload it in parts: start a multipart upload, sign the parts, upload each one to its URL, then complete the upload. Either way, the key you get goes on a release download.

POST Authenticated/api/downloads/prepare

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
/api/downloads/prepare
POST https://demo.moonbase.sh/api/downloads/prepare?contentType=application%2foctet-stream
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "key": "demo/49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
    "url": "https://demo.moonbase.sh/..."
}

POST Authenticated/api/downloads/multipart

Start multipart upload

Use this endpoint to start uploading a file in parts. The response has the upload's id and the file's key. Pass the key with every other call for this upload, and once the upload is complete, add it to a release like a key from prepare upload.

An upload that isn't completed within 7 days of starting it is discarded, along with its parts.

Required query parameters

  • Name
    contentType
    Type
    string
    Description

    The MIME type of the file, such as application/zip. For binary files, you may use application/octet-stream.

Response body

  • Name
    id
    Type
    string
    Description

    The ID of the upload.

  • Name
    key
    Type
    string
    Description

    The unique key for the file.

Request

POST
/api/downloads/multipart
POST https://demo.moonbase.sh/api/downloads/multipart?contentType=application%2fzip
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "VXBsb2FkIElEIGZvciBkZW1vIGluc3RhbGxlcg",
    "key": "demo/1d7c685e-3a4e-4051-8526-6df436b6fd27"
}

POST Authenticated/api/downloads/multipart/{uploadId}/sign

Sign upload parts

Use this endpoint to get the URLs to upload the parts of a file to. Number the parts from 1 in the order they make up the file, and send the numbers as a JSON array, at most 1,000 at a time. Part numbers run from 1 to 10,000, and every part except the last must be at least 5 MiB.

Each URL takes a PUT of that part's bytes, needs no authentication, and works for an hour. Keep the ETag header of each response, since you need it to complete the upload. For example:

curl -i --upload-file part-1.bin '{URL}'

You can sign a part again, for example to retry it once its URL has expired. Part numbers out of range respond with 400: Bad Request, and an upload that doesn't exist or is already complete with 404: Not Found.

Required query parameters

  • Name
    key
    Type
    string
    Description

    The key of the upload.

Response body

An array with an entry for each part number:

  • Name
    partNumber
    Type
    number
    Description

    The part number.

  • Name
    url
    Type
    url
    Description

    The URL to upload that part to.

Request

POST
/api/downloads/multipart/{uploadId}/sign
POST https://demo.moonbase.sh/api/downloads/multipart/VXBsb2FkIElEIGZvciBkZW1vIGluc3RhbGxlcg/sign?key=demo/1d7c685e-3a4e-4051-8526-6df436b6fd27
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

[1, 2, 3]

Response

[
    {
        "partNumber": 1,
        "url": "https://..."
    },
    {
        "partNumber": 2,
        "url": "https://..."
    },
    {
        "partNumber": 3,
        "url": "https://..."
    }
]

POST Authenticated/api/downloads/multipart/{uploadId}/complete

Complete multipart upload

Use this endpoint once every part is uploaded, to put the file together. Send each part's number and ETag, in any order. The file's key can then go on a release through create release, update release or add download.

Responds with 200: OK and no body. If a part is missing, an ETag doesn't match, a part number is listed twice, or a part other than the last is under 5 MiB, it responds with 400: Bad Request saying which, and you can send a corrected list. An upload that doesn't exist or is already complete responds with 404: Not Found.

Required query parameters

  • Name
    key
    Type
    string
    Description

    The key of the upload.

Request body

A JSON array with an entry for each part:

  • Name
    partNumber
    Type
    number
    Description

    The part number.

  • Name
    eTag
    Type
    string
    Description

    The ETag header the part's upload responded with.

Request

POST
/api/downloads/multipart/{uploadId}/complete
POST https://demo.moonbase.sh/api/downloads/multipart/VXBsb2FkIElEIGZvciBkZW1vIGluc3RhbGxlcg/complete?key=demo/1d7c685e-3a4e-4051-8526-6df436b6fd27
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

[
    { "partNumber": 1, "eTag": "\"a54357aff0632cce46d942af68356b38\"" },
    { "partNumber": 2, "eTag": "\"0c78aef83f66abc1fa1e8477f296d394\"" },
    { "partNumber": 3, "eTag": "\"acbd18db4cc2f85cedef654fccc4a4d8\"" }
]

Response

HTTP/1.1 200 OK

GET Authenticated/api/downloads/multipart/{uploadId}

Get uploaded parts

Use this endpoint to list the parts of an upload that have arrived so far, for example to pick up an interrupted upload and send only the parts that are missing. The list can be sent as it is to complete the upload.

An upload that doesn't exist or is already complete responds with 404: Not Found.

Required query parameters

  • Name
    key
    Type
    string
    Description

    The key of the upload.

Response body

An array with an entry for each part uploaded:

  • Name
    partNumber
    Type
    number
    Description

    The part number.

  • Name
    size
    Type
    number
    Description

    The size of the part in bytes.

  • Name
    eTag
    Type
    string
    Description

    The part's ETag.

Request

GET
/api/downloads/multipart/{uploadId}
GET https://demo.moonbase.sh/api/downloads/multipart/VXBsb2FkIElEIGZvciBkZW1vIGluc3RhbGxlcg?key=demo/1d7c685e-3a4e-4051-8526-6df436b6fd27
Api-Key: mb_bbdac119b64649f6937e...

Response

[
    {
        "partNumber": 1,
        "size": 5242880,
        "eTag": "\"a54357aff0632cce46d942af68356b38\""
    },
    {
        "partNumber": 2,
        "size": 5242880,
        "eTag": "\"0c78aef83f66abc1fa1e8477f296d394\""
    }
]

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
        }
    }
}

POST Authenticated/api/vouchers/create

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
/api/vouchers/create
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 Authenticated/api/vouchers

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
/api/vouchers
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 Authenticated/api/vouchers/{id}

Get voucher by ID

Use this endpoint to look up a voucher by its ID.

Request

GET
/api/vouchers/{id}
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",
    ...
}

PUT Authenticated/api/vouchers/{id}/codes

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
/api/vouchers/{id}/codes
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 Authenticated/api/vouchers/{id}/codes

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
/api/vouchers/{id}/codes
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 Authenticated/api/vouchers/{id}/codes/{code}

Delete voucher code

Deletes a single code from a voucher.

Request

DELETE
/api/vouchers/{id}/codes/{code}
DELETE https://demo.moonbase.sh/api/vouchers/58927685-61ad-4caa-ad6f-8613d7200d4f/codes/VOUCHER-CODE-001
Api-Key: mb_bbdac119b64649f6937e...

PUT Authenticated/api/vouchers/{id}/custom-properties

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
/api/vouchers/{id}/custom-properties
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
    maxRedemptions
    Type
    number
    Nullability
    nullable
    Description

    How many times the coupon can be redeemed in all, across its codes. null for no limit.

  • Name
    maxRedemptionsPerCode
    Type
    number
    Nullability
    nullable
    Description

    How many times each of its codes can be redeemed. null for no limit.

  • 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,
    "maxRedemptions": null,
    "maxRedemptionsPerCode": 1,
    "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
        }
    }
}

POST Authenticated/api/coupons/create

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 type field:

    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
/api/coupons/create
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 Authenticated/api/coupons

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
/api/coupons
GET https://demo.moonbase.sh/api/coupons
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "items": [
        {
            "id": "SUMMER2026",
            "name": "Summer Sale",
            ...
        }
    ],
    "hasMore": false,
    "next": null
}

GET Authenticated/api/coupons/{id}

Get coupon by ID

Use this endpoint to look up a coupon by its ID.

Request

GET
/api/coupons/{id}
GET https://demo.moonbase.sh/api/coupons/SUMMER2026
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "SUMMER2026",
    "name": "Summer Sale",
    ...
}

PUT Authenticated/api/coupons/{id}/codes

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
/api/coupons/{id}/codes
PUT https://demo.moonbase.sh/api/coupons/SUMMER2026/codes
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

[
    "SUMMER-001",
    "SUMMER-002"
]

GET Authenticated/api/coupons/{id}/codes

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
/api/coupons/{id}/codes
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 Authenticated/api/coupons/{id}/codes/{code}

Delete coupon code

Deletes a single code from a coupon.

Request

DELETE
/api/coupons/{id}/codes/{code}
DELETE https://demo.moonbase.sh/api/coupons/SUMMER2026/codes/SUMMER-001
Api-Key: mb_bbdac119b64649f6937e...

PUT Authenticated/api/coupons/{id}/custom-properties

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
/api/coupons/{id}/custom-properties
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",
    ...
}

Campaigns

Campaign endpoints let you write an email campaign, send or schedule it to a list or segment, and see who it reached. They are the same campaigns as on the Campaigns page in Moonbase, held to the same rules.

Sending needs a live Moonbase account with a verified sending domain and a marketing sender address, set up under Account settings > Email. A campaign only reaches customers who opted in to its category, and your account can send a limited number of campaign emails each day (UTC): a send that reaches the limit pauses, and carries on by itself the next day. Get campaign usage shows how much of today's allowance is used.

The campaign object contains the following:

  • Name
    id
    Type
    string
    Description

    The Moonbase ID of the campaign.

  • Name
    name
    Type
    string
    Description

    The name of the campaign. Recipients do not see it.

  • Name
    slug
    Type
    string
    Nullability
    nullable
    Description

    The utm_campaign added to every link the campaign sends, unique within your account. Made from the name when the campaign is created, and kept when it is renamed.

  • Name
    status
    Type
    enum(Draft|Scheduled|Sending|Paused|Sent|Cancelled|Failed)
    Description

    Where the campaign is. Only a Draft can be edited.

  • Name
    category
    Type
    enum(Newsletter|ProductUpdates)
    Description

    Which opt-in a customer needs to get it: communicationPreferences.newsletterOptIn or productUpdatesOptIn.

  • Name
    groupId
    Type
    string
    Nullability
    nullable
    Description

    The list or segment the campaign goes to, or all-customers for everyone. A list's or segment's ID is the last part of its address in Moonbase, app.moonbase.sh/customers/{groupId}.

  • Name
    audienceRule
    Type
    object
    Nullability
    nullable
    Description

    A rule that narrows the group to the members it matches, or null for all of them.

  • Name
    subject
    Type
    string
    Description

    The subject line.

  • Name
    previewText
    Type
    string
    Nullability
    nullable
    Description

    The line inboxes show after the subject.

  • Name
    blocks
    Type
    array
    Description

    The body of the email, as a list of blocks.

  • Name
    bodyText
    Type
    string
    Description

    The plain-text part of the email, or empty when it is made from the blocks at send.

  • Name
    utm
    Type
    object
    Description

    The UTM parameters added to the campaign's links: source (mb-campaign), medium (email), campaign (the slug) and content (newsletter or product-updates).

  • Name
    scheduledAt
    Type
    datetime
    Nullability
    nullable
    Description

    When a scheduled campaign starts sending.

  • Name
    localDelivery
    Type
    object
    Nullability
    nullable
    Description

    Set when each recipient gets the campaign at a time of day on their own clock, rather than everyone at once. Contains localTime (HH:mm) and fallbackTimeZone.

  • Name
    sendStartedAt
    Type
    datetime
    Nullability
    nullable
    Description

    When the send started.

  • Name
    sendCompletedAt
    Type
    datetime
    Nullability
    nullable
    Description

    When the send finished.

  • Name
    recipientCount
    Type
    number
    Description

    How many recipients the send has. Zero until it starts. Compare counters.sent with it to follow a send.

  • Name
    counters
    Type
    object
    Description

    Running totals: recipients, sent, failed, rejected, skippedNotOptedIn, skippedSuppressed, skippedUnconfirmed, membersScanned, delivered, bounced, complained, unsubscribed, opened and clicked.

  • Name
    pauseReason
    Type
    enum(Manual|Deliverability|DailyLimitReached)
    Nullability
    nullable
    Description

    Why a paused campaign is paused: by you, by Moonbase to protect your sending reputation (for example after too many spam complaints), or at the daily limit.

  • Name
    autoResumeAt
    Type
    datetime
    Nullability
    nullable
    Description

    When a campaign paused at the daily limit carries on by itself.

  • Name
    autoPausedReason
    Type
    string
    Nullability
    nullable
    Description

    What Moonbase paused the campaign for, in words.

  • Name
    errorMessage
    Type
    string
    Nullability
    nullable
    Description

    Why a Failed campaign failed.

  • Name
    created
    Type
    object
    Description

    When the campaign was created, containing an at timestamp and by, who created it.

  • Name
    lastUpdated
    Type
    object
    Description

    When the campaign was last changed, containing an at timestamp and by, who changed it.

Blocks

Each block is an object with a type and an id. Leave the id out on a new block and Moonbase assigns one; send it back to keep the block. Text fields can use variables such as {{ customer.first_name | "there" }}. Heading, text, button, discount code, coupon and voucher blocks take an optional alignment (Left, the default, Center or Right).

  • Header: your logo over a title and optional subtitle, on your brand color or backgroundColor.
  • Heading: a section heading, text.
  • Text: a paragraph of Markdown, text.
  • Button: a call to action, label and url, with an optional second one, secondaryLabel and secondaryUrl.
  • Image and HeroImage: an image inset in the body, or one running edge to edge, with url, alt, linkUrl, width and height.
  • Product: a card for one of your products, productId, with an optional ctaLabel and ctaUrl. Its name, icon and price are read when the email is sent.
  • DiscountCode: one code you already have, code, with a title. Everyone gets the same code.
  • Coupon: a code of its own for each recipient, made from the coupon couponId as the campaign sends, with a title.
  • Voucher: a voucher code of its own for each recipient, from voucherId, with a title and an optional buttonLabel for a redeem button.
  • License: licenses for up to five products (each a productId and quantity) issued to every recipient as the campaign sends, with a title.
  • Conditional: shows the matched blocks to recipients a rule, rule, matches, and the otherwise blocks to everyone else.
  • Divider and Spacer: a line, or extra space, between sections.

Rules

Audience rules and conditional blocks use the same rule language as segments. Each rule is an object with a type:

  • All, Any: every one, or at least one, of conditions matches. Not: condition does not match.
  • InGroup: in the lists or segments groupIds, with mode All or Any.
  • OwnsItems: owns the items (Product/{id} or Bundle/{id}), with mode and includeSubscriptions.
  • CountryIn: lives in one of countryCodes.
  • AcquiredVia, LifetimeValueBetween, SpentBetween, CounterBetween, HasFlag, CustomerDateWithin, CustomPropertyMatches: how the customer found you, what they have spent, their counts, flags, dates and custom properties.
  • PerformedEvent, OpenedEmail, ValidatedAtLeast, WasActiveWithin, EnvironmentIs: what they did, which emails they opened, and how and where they use your products.

A rule Moonbase does not know, or one with fields that do not fit, is refused with 400: Bad Request.

Campaign example

{
    "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
    "name": "Example Product 2.0 launch",
    "slug": "example-product-2-0-launch",
    "status": "Draft",
    "category": "ProductUpdates",
    "groupId": "example-product-owners",
    "audienceRule": {
        "type": "CountryIn",
        "countryCodes": ["NO", "SE", "DK"]
    },
    "subject": "Example Product 2.0 is here",
    "previewText": "A free update for every owner",
    "blocks": [
        {
            "type": "Heading",
            "id": "0b6e7c1a-5d2f-4a8b-9c3e-1f4a7b2d6e90",
            "text": "Example Product 2.0 is here",
            "alignment": "Left"
        },
        {
            "type": "Text",
            "id": "7d2a9f4c-3e1b-4c6d-8a5f-2b9e0c7d4a18",
            "text": "Hi {{ customer.first_name | \"there\" }}, version 2.0 is out, and it is free for you.",
            "alignment": "Left"
        },
        {
            "type": "Button",
            "id": "c4f81e2b-9a6d-4b3c-a7e5-6d0f2c8b1a94",
            "label": "Download the update",
            "url": "https://example.com/download",
            "secondaryLabel": null,
            "secondaryUrl": null,
            "alignment": "Center"
        }
    ],
    "bodyText": "",
    "utm": {
        "source": "mb-campaign",
        "medium": "email",
        "campaign": "example-product-2-0-launch",
        "content": "product-updates"
    },
    "scheduledAt": null,
    "localDelivery": null,
    "sendStartedAt": null,
    "sendCompletedAt": null,
    "recipientCount": 0,
    "counters": {
        "recipients": 0,
        "sent": 0,
        "opened": 0,
        "clicked": 0,
        ...
    },
    "pauseReason": null,
    "autoResumeAt": null,
    "autoPausedReason": null,
    "errorMessage": null,
    "created": { "at": "2026-10-20T09:12:44.0000000Z", "by": { ... } },
    "lastUpdated": { "at": "2026-10-20T09:12:44.0000000Z", "by": { ... } }
}

GET Authenticated/api/campaigns

Get campaigns

Use this endpoint to fetch all campaigns page by page, newest first. For more details on how pagination works, see pagination.

Each campaign in the list leaves out audienceRule, previewText, blocks, bodyText, utm, autoPausedReason and errorMessage, and has hasAudienceRule instead. Get campaign by ID has the rest.

Optional query parameters

  • Name
    pageSize
    Type
    number
    Optionality
    optional
    Description

    Adjust the size of each page returned, up to 100.

Request

GET
/api/campaigns
GET https://demo.moonbase.sh/api/campaigns
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "items": [
        {
            "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
            "name": "Example Product 2.0 launch",
            "status": "Sent",
            "hasAudienceRule": true,
            ...
        }
    ],
    "hasMore": false,
    "next": null,
    "pageSize": 15
}

GET Authenticated/api/campaigns/{id}

Get campaign by ID

Use this endpoint to look up a campaign, with its content, by its ID. If no campaign exists with the given ID, the API responds with 404: Not Found.

Request

GET
/api/campaigns/{id}
GET https://demo.moonbase.sh/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
    "name": "Example Product 2.0 launch",
    ...
}

POST Authenticated/api/campaigns/create

Create campaign

Creates a draft campaign. Nothing is sent until you send or schedule it, so a draft is safe to create and look over in Moonbase first.

A group that does not exist, a block that does not fit, or a variable Moonbase does not know is refused with 400: Bad Request describing the problem.

Required body properties

  • Name
    name
    Type
    string
    Description

    The name of the campaign.

Optional body properties

  • Name
    category
    Type
    enum(Newsletter|ProductUpdates)
    Optionality
    optional
    Description

    Which opt-in a customer needs to get it. Defaults to Newsletter.

  • Name
    groupId
    Type
    string
    Optionality
    optional
    Description

    The list or segment to send to. Leave it out, or send all-customers, for everyone.

  • Name
    audienceRule
    Type
    object
    Optionality
    optional
    Description

    A rule that narrows the group to the members it matches.

  • Name
    subject
    Type
    string
    Optionality
    optional
    Description

    The subject line.

  • Name
    previewText
    Type
    string
    Optionality
    optional
    Description

    The line inboxes show after the subject.

  • Name
    blocks
    Type
    array
    Optionality
    optional
    Description

    The body, as a list of blocks. Leave out both this and bodyText to start from your account's starter layout.

  • Name
    bodyText
    Type
    string
    Optionality
    optional
    Description

    The plain-text part. Leave it out to have it made from the blocks at send.

  • Name
    slug
    Type
    string
    Optionality
    optional
    Description

    The utm_campaign for its links. Made from the name when left out. Whatever you send is normalized and made unique within your account, so read the one assigned from the response.

Request

POST
/api/campaigns/create
POST https://demo.moonbase.sh/api/campaigns/create
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "name": "Example Product 2.0 launch",
    "category": "ProductUpdates",
    "groupId": "example-product-owners",
    "subject": "Example Product 2.0 is here",
    "previewText": "A free update for every owner",
    "blocks": [
        { "type": "Heading", "text": "Example Product 2.0 is here" },
        { "type": "Text", "text": "Hi {{ customer.first_name | \"there\" }}, version 2.0 is out, and it is free for you." },
        { "type": "Button", "label": "Download the update", "url": "https://example.com/download", "alignment": "Center" }
    ]
}

Response

{
    "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
    "name": "Example Product 2.0 launch",
    "slug": "example-product-2-0-launch",
    "status": "Draft",
    ...
}

PATCH Authenticated/api/campaigns/{id}

Update campaign

Changes a draft campaign. Every property is optional, and one you leave out keeps its value.

A campaign that has been scheduled or sent can still be renamed: send name alone. Anything else on a campaign that is no longer a Draft is refused with 400: Bad Request. Unschedule a scheduled campaign to edit it. If someone else changes the campaign at the same moment, both changes are kept. In the rare case they cannot be, the API responds with 409: Conflict: read the campaign again and make your change to what it is now.

Optional body properties

  • Name
    name
    Type
    string
    Optionality
    optional
    Description

    The name of the campaign. Renaming does not change the slug.

  • Name
    category
    Type
    enum(Newsletter|ProductUpdates)
    Optionality
    optional
    Description

    Which opt-in a customer needs to get it.

  • Name
    groupId
    Type
    string
    Optionality
    optional
    Description

    The list or segment to send to, or all-customers for everyone.

  • Name
    audienceRule
    Type
    object
    Optionality
    optional
    Description

    Replaces the rule that narrows the group.

  • Name
    clearAudienceRule
    Type
    boolean
    Optionality
    optional
    Description

    Set to true to drop the audience rule and send to every member of the group again.

  • Name
    subject
    Type
    string
    Optionality
    optional
    Description

    The subject line.

  • Name
    previewText
    Type
    string
    Optionality
    optional
    Description

    The line inboxes show after the subject. Send an empty string to remove it.

  • Name
    blocks
    Type
    array
    Optionality
    optional
    Description

    Replaces the whole body. A block sent with its id keeps it.

  • Name
    bodyText
    Type
    string
    Optionality
    optional
    Description

    The plain-text part. Send an empty string to have it made from the blocks again.

  • Name
    slug
    Type
    string
    Optionality
    optional
    Description

    A new utm_campaign for its links.

Request

PATCH
/api/campaigns/{id}
PATCH https://demo.moonbase.sh/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "subject": "Example Product 2.0: free for owners",
    "clearAudienceRule": true
}

Response

{
    "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
    "subject": "Example Product 2.0: free for owners",
    "audienceRule": null,
    ...
}

DELETE Authenticated/api/campaigns/{id}

Delete campaign

Deletes a campaign and responds with 204: No Content. A campaign that is sending is refused with 400: Bad Request: pause or cancel it first. Deleting a scheduled campaign stops it from being sent.

Request

DELETE
/api/campaigns/{id}
DELETE https://demo.moonbase.sh/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13
Api-Key: mb_bbdac119b64649f6937e...

POST Authenticated/api/campaigns/{id}/schedule

Schedule campaign

Schedules a draft to start sending at a future time, and responds with the campaign as Scheduled.

Refused with 400: Bad Request when the account is not live, has no verified sending domain, the campaign has no group, subject or content, or the time is not in the future.

Required body properties

  • Name
    at
    Type
    datetime
    Description

    ISO-8601 date and time, in UTC, for the send to start.

Optional body properties

  • Name
    localDelivery
    Type
    object
    Optionality
    optional
    Description

    Set this to have each recipient get the campaign at 10:00 on their own clock, the first time that comes round after at, rather than everyone at at. The send then goes out over up to a day.

    • Name
      fallbackTimeZone
      Type
      string
      Description

      The IANA time zone, such as Europe/Oslo, for recipients Moonbase cannot place.

Request

POST
/api/campaigns/{id}/schedule
POST https://demo.moonbase.sh/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13/schedule
Api-Key: mb_bbdac119b64649f6937e...
Content-Type: application/json

{
    "at": "2026-11-03T08:00:00Z"
}

Response

{
    "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
    "status": "Scheduled",
    "scheduledAt": "2026-11-03T08:00:00Z",
    ...
}

POST Authenticated/api/campaigns/{id}/unschedule

Unschedule campaign

Takes a scheduled campaign back to Draft, so it can be edited or scheduled again. Refused with 400: Bad Request for a campaign that is not scheduled.

Request

POST
/api/campaigns/{id}/unschedule
POST https://demo.moonbase.sh/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13/unschedule
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
    "status": "Draft",
    "scheduledAt": null,
    ...
}

POST Authenticated/api/campaigns/{id}/send

Send campaign

Starts sending a draft or scheduled campaign now, and responds with the campaign as Sending. The body is optional.

Refused with 400: Bad Request when the account is not live, has no verified sending domain, or the campaign has no group, subject or content.

Optional body properties

  • Name
    localDelivery
    Type
    object
    Optionality
    optional
    Description

    Set this to have each recipient get the campaign at 10:00 on their own clock, the next time that comes round, rather than everyone now. Takes fallbackTimeZone, as when scheduling.

Request

POST
/api/campaigns/{id}/send
POST https://demo.moonbase.sh/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13/send
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
    "status": "Sending",
    "sendStartedAt": "2026-10-20T10:02:13.0000000Z",
    ...
}

POST Authenticated/api/campaigns/{id}/pause

Pause campaign

Pauses a campaign that is sending, within an email or two. Refused with 400: Bad Request for a campaign that is not sending.

Request

POST
/api/campaigns/{id}/pause
POST https://demo.moonbase.sh/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13/pause
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
    "status": "Paused",
    "pauseReason": "Manual",
    ...
}

POST Authenticated/api/campaigns/{id}/resume

Resume campaign

Carries on sending a paused campaign to the recipients it has not reached yet, whatever paused it. Refused with 400: Bad Request for a campaign that is not paused.

Request

POST
/api/campaigns/{id}/resume
POST https://demo.moonbase.sh/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13/resume
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
    "status": "Sending",
    "pauseReason": null,
    ...
}

POST Authenticated/api/campaigns/{id}/cancel

Cancel campaign

Stops a campaign for good. Whoever it has reached keeps their copy, and a scheduled campaign is not sent. Refused with 400: Bad Request for a campaign that is already sent or cancelled.

Request

POST
/api/campaigns/{id}/cancel
POST https://demo.moonbase.sh/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13/cancel
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "id": "6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13",
    "status": "Cancelled",
    ...
}

GET Authenticated/api/campaigns/{id}/recipients

Get campaign recipients

Use this endpoint to fetch who a campaign was sent to and what became of each, most recently processed first. For more details on how pagination works, see pagination.

Only recipients the send has reached are listed, so a draft gives an empty page and a send in progress a partial one. Compare with the campaign's recipientCount.

Optional query parameters

  • Name
    status
    Type
    enum(Sent|Skipped|Failed)
    Optionality
    optional
    Description

    Only list recipients with this status.

  • Name
    pageSize
    Type
    number
    Optionality
    optional
    Description

    Adjust the size of each page returned, up to 100.

Response content

The inner recipient objects have the following schema:

  • Name
    customerId
    Type
    string
    Description

    The Moonbase ID of the customer, kept after the customer is deleted.

  • Name
    customer
    Type
    object
    Optionality
    optional
    Description

    Who the customer is now: id, externalId (when set), name, email and isDeleted. Omitted once the customer has been removed for good.

  • Name
    email
    Type
    string
    Optionality
    optional
    Description

    The address the campaign was sent to, which can differ from the customer's current one. Omitted once the customer is deleted.

  • Name
    status
    Type
    enum(Sent|Skipped|Failed)
    Description

    What the send did with this recipient.

  • Name
    skipReason
    Type
    enum(NotOptedIn|Suppressed|Unconfirmed|Deleted)
    Optionality
    optional
    Description

    Why a skipped recipient was not emailed.

  • Name
    sentAt
    Type
    datetime
    Optionality
    optional
    Description

    When the email was sent.

  • Name
    failureMessage
    Type
    string
    Optionality
    optional
    Description

    Why a failed recipient was not emailed. Omitted once the customer is deleted.

  • Name
    delivery
    Type
    object
    Optionality
    optional
    Description

    What the receiving inbox did with the email: status (Sent, Delivered, Rejected, Bounced or Complained), and openedAt, clickedAt, unsubscribedAt and failure when they apply.

  • Name
    processedAt
    Type
    datetime
    Optionality
    optional
    Description

    When the send finished with this recipient, emailed or not.

Request

GET
/api/campaigns/{id}/recipients
GET https://demo.moonbase.sh/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13/recipients?status=Sent
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "items": [
        {
            "customerId": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
            "customer": {
                "id": "49b8da10-2d72-4bdf-bf9c-47e56c184bfa",
                "name": "Example User",
                "email": "user@example.com",
                "isDeleted": false
            },
            "email": "user@example.com",
            "status": "Sent",
            "sentAt": "2026-10-20T10:02:41.0000000Z",
            "delivery": {
                "status": "Delivered",
                "openedAt": "2026-10-20T11:15:09.0000000Z"
            },
            "processedAt": "2026-10-20T10:02:41.0000000Z"
        }
    ],
    "hasMore": true,
    "next": "/api/campaigns/6f1c2b9e-8d4a-4e3f-9a51-2c7d0e4b8a13/recipients?status=Sent&paginationToken=...",
    "pageSize": 25
}

GET Authenticated/api/campaigns/usage

Get campaign usage

Use this endpoint to see how much of today's (UTC) allowance of campaign emails your account has used. A send that reaches the limit pauses with pauseReason DailyLimitReached, and carries on by itself at autoResumeAt.

Response content

  • Name
    quotas
    Type
    array
    Description

    One entry per daily allowance, each with kind (Emails), used today, and limit, or null when there is no limit.

Request

GET
/api/campaigns/usage
GET https://demo.moonbase.sh/api/campaigns/usage
Api-Key: mb_bbdac119b64649f6937e...

Response

{
    "quotas": [
        {
            "kind": "Emails",
            "used": 1240,
            "limit": ...
        }
    ]
}

Was this page helpful?