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
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
- Navigate to System Configuration → Users & API Keys.
- Locate your user and click the Edit (pencil) icon.
- Click New API Key.
- Enter a name for the API Key.
- Save to generate the API Key.
Option 2: From Your Profile
- Click your user avatar in the bottom-left corner.
- Select Profile.
- Click New API Key.
- Enter a name for the API Key .
- Save to generate the API Key.
Copying Your API Key
After the API Key is created:- Locate the newly generated API Key in the list.
- Click the Copy button next to the API Key.
- 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:
- The account number field name is
number, notaccountNumber. - 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
numberin 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:
effectiveDatemust be today inYYYY-MM-DDformat. Do not use a fixed date such as the first day of a month.- Set
expirationDateas needed. For a one-year contract, set one year later (for example,2027-04-13). expirationDatemeans the contract expires at 00:00 on that date, so that date is not included.createContractWithPlanmust be an array.
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:
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:
- Set
effectiveDateto 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
subscriptionStatustoCANCELEDin 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.
eventTimemust be ISO 8601 UTC format.- Use UUID v4 for
eventIdto ensure idempotency. - Asynchronous reporting is recommended. On failure, log the error in your business table and do not block the main flow.
attributesmust match the usage event schema definition. The sample above is only an example.
9. Invoice List Query
Endpoint:POST /api/data-query
Request body:
10. Invoice PDF Generation
Endpoint:POST /template-engine/api/pdf/generate
Request body:
nameshould use the invoicenumberfield, i.e.invoiceNumber.objectIdshould use the invoiceidfield, i.e.invoiceId.- Before calling PDF API, verify the invoice belongs to the current user account by checking the invoice list.
- The response
idispdfId. Download PDF viaGET /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
Step 2: Build the Portal URL
12. Notification Configuration
EasyBilling supports webhook notifications for the following events:Configure a Webhook Endpoint
- Navigate to System Configuration → Notifications.
- Locate the notification event you want to configure.
- Click the Edit (pencil) icon.
- Enter your webhook HTTP URL.
- Click Save.
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, notaccountNumber - Contract creation uses today’s
effectiveDate contractInfo.idis persisted in user table- Usage event body is an array
account-authtoken extraction supports all 6 response formats- Portal URL containing token is returned only from backend
