Skip to main content
This document is for new merchants. It provides a structured overview of all key points required to integrate with the EasyBilling billing platform, including environment setup, API workflows, field mapping notes, and common pitfalls.

1. Overview

EasyBilling is the subscription billing platform used by this system. It is responsible for:
  • Managing customer accounts and subscription contracts
  • Supporting usage-based billing
  • Processing actual payments through Stripe Connect
  • Providing invoice generation and a customer self-service portal
Sandbox Base URL:
Production Base URL:
All requests must include these headers:
  • Authorization: Bearer <EASYBILLING_API_KEY>
  • trace-id: <UUID>

2. API Key

There are two ways to create an API Key in EasyBilling:

Option 1: From System Configuration

  1. Navigate to System ConfigurationUsers & API Keys.
  2. Locate your user and click the Edit (pencil) icon.
  3. Click New API Key.
  4. Enter a name for the API Key.
  5. Save to generate the API Key.

Option 2: From Your Profile

  1. Click your user avatar in the bottom-left corner.
  2. Select Profile.
  3. Click New API Key.
  4. Enter a name for the API Key .
  5. Save to generate the API Key.

Copying Your API Key

After the API Key is created:
  1. Locate the newly generated API Key in the list.
  2. Click the Copy button next to the API Key.
  3. Store the API Key securely, as it will be used to authenticate API requests.

3. Environment Variable Configuration

Required:

4. Account Creation

When a user registers, create the corresponding account in EasyBilling. Endpoint: POST /api/accounts Request body:
Key notes:
  • The account number field name is number, not accountNumber.
  • The account number should use your own system’s customer account number.
  • If you do not pass an account number, EasyBilling will generate its own.
  • If you do not use your own customer account number, you must store EasyBilling number in your user table. All follow-up EasyBilling operations depend on this field.
  • Always query the account by accountNumber before creating one. If the account already exists, reuse its accountNumber and proceed to create the contract. Only create a new account when no existing account is found. This prevents duplicate accounts and avoids integration errors when a previous request successfully created the account but failed to create the contract.

5. Contract Creation

After registration (or on demand), create a contract for the default plan. Endpoint: POST /api/contract-actions Request body:
Key notes:
  • effectiveDate must be today in YYYY-MM-DD format. Do not use a fixed date such as the first day of a month.
  • Set expirationDate as needed. For a one-year contract, set one year later (for example, 2027-04-13).
  • expirationDate means the contract expires at 00:00 on that date, so that date is not included.
  • createContractWithPlan must be an array.
Response (must be persisted):
Persist contractInfo.id to your user table as easyBillingContractId. This field is required for both upgrade and cancellation.

6. Plan Upgrade

Switch a user from the current plan to a paid plan. Endpoint: POST /api/contract-actions Request body:
Response handling:
Extract the Stripe Checkout URL from paymentResults[].sessionUrl and return it to the frontend. Recovery path (when contractId is empty): If contract creation failed during registration and contractId is empty, first create a contract directly with the target upgrade plan (skip switch-plan). Then extract sessionUrl from the response.

7. Contract Cancellation

Cancel the active contract immediately. Endpoint: POST /api/contract-actions Request body:
Notes:
  • Set effectiveDate to tomorrow (today + 1 day). Cancellation takes effect on the next day.
  • If today’s usage has already been uploaded, the earliest possible cancellation is tomorrow.
  • EasyBilling automatically handles refunds and tax reversal. No separate backend calculation is required.
  • After cancellation succeeds, update user subscriptionStatus to CANCELED in your own system.

8. Usage Event Reporting

Whenever a user completes a billable action (for example, one AI analysis), report usage to EasyBilling. Endpoint: POST /api/usage-events Important: The request body must be an array.
Key notes:
  • eventTime must be ISO 8601 UTC format.
  • Use UUID v4 for eventId to ensure idempotency.
  • Asynchronous reporting is recommended. On failure, log the error in your business table and do not block the main flow.
  • attributes must match the usage event schema definition. The sample above is only an example.

9. Invoice List Query

Endpoint: POST /api/data-query Request body:
Response field mapping (important):

10. Invoice PDF Generation

Endpoint: POST /template-engine/api/pdf/generate Request body:
Notes:
  • name should use the invoice number field, i.e. invoiceNumber.
  • objectId should use the invoice id field, i.e. invoiceId.
  • Before calling PDF API, verify the invoice belongs to the current user account by checking the invoice list.
  • The response id is pdfId. Download PDF via GET /template-engine/api/pdf/{pdfId}.

11. Customer Portal

The customer portal allows users to self-manage subscriptions and view invoices.

Step 1: Get a Short-lived Token

Endpoint: POST /api/authenticate/account-auth
Token field compatibility (check in priority order):
Only log the first 6 characters of the token. Never output the full token.

Step 2: Build the Portal URL

Use URL API to build safely and avoid encoding issues from manual string concatenation:
Important: The portal URL contains sensitive token data. It must be returned by a backend endpoint and must not be hardcoded or persisted on frontend.

12. Notification Configuration

EasyBilling supports webhook notifications for the following events:

Configure a Webhook Endpoint

  1. Navigate to System ConfigurationNotifications.
  2. Locate the notification event you want to configure.
  3. Click the Edit (pencil) icon.
  4. Enter your webhook HTTP URL.
  5. Click Save.
After the webhook URL has been saved, you can view and copy the webhook secret to verify that incoming webhook requests were sent by EasyBilling.

Webhook Delivery & Retries

EasyBilling will attempt to deliver each webhook event to your configured endpoint. If a delivery attempt fails (for example, due to a network error or a non-success HTTP response), EasyBilling will automatically retry the notification:
  • Retry Attempts: 2 additional retries
  • Retry Interval: 1 minute between each retry

13. Common Notes

Quick Checklist

For new project integration, verify:
  • Environment variables are configured (8 required items)
  • Account creation response uses number, not accountNumber
  • Contract creation uses today’s effectiveDate
  • contractInfo.id is persisted in user table
  • Usage event body is an array
  • account-auth token extraction supports all 6 response formats
  • Portal URL containing token is returned only from backend