Complete integration guide for Bills and Subscriptions
Version 1.0.0Welcome to our API documentation. This API allows you to integrate your system with our billing and subscription management platform.
https://yourdomain.com/{username}/
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/add/bill |
Create a new bill |
| POST | /v1/add/subscription |
Create a new subscription |
All API requests require authentication using an API key sent in the request header.
X-API-Key: your-api-key-here
| Endpoint | Rate Limit |
|---|---|
/v1/add/bill |
100 requests/hour |
/v1/add/subscription |
50 requests/hour |
Create a new bill for a customer. This endpoint allows you to generate bills that can be paid through the system.
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
customerName |
string | Required | Customer's full name | "Razzbery Solutions" |
customerPhone |
string | Required | Phone (07xxxxxxxx) | "0777839071" |
customerEmail |
string | Optional | Customer's email | "test@razzbery.com" |
customerNationalId |
string | Optional | National ID (10 digits) | "9876543210" |
customerAddress |
string | Optional | Customer's address | "Amman, Jordan" |
serviceType |
string | Required | Type of service | "Water Bill" |
dueAmount |
number | Required | Amount in JOD (> 0) | 150.50 |
dueDate |
string | Required | Date (YYYY-MM-DD) | "2025-12-31" |
description |
string | Optional | Additional details | "Monthly bill" |
notes |
string | Optional | Internal notes | "Priority customer" |
{
"customerName": "Razzbery Solutions",
"customerPhone": "0777839071",
"customerEmail": "info@razzbery.com",
"customerNationalId": "9876543210",
"customerAddress": "123 Main St, Amman, Jordan",
"serviceType": "Water Bill",
"dueAmount": 150.50,
"dueDate": "2025-12-31",
"description": "Monthly water consumption bill",
"notes": "Customer prefers email notifications"
}
{
"success": true,
"message": "Bill created successfully",
"data": {
"_id": "674a1b2c3d4e5f6a7b8c9d0e",
"billingNo": "BILL-20251201-0001",
"billNo": "BN-20251201-0001",
"customerName": "Razzbery Solutions",
"customerPhone": "0777839071",
"customerEmail": "info@razzbery.com",
"serviceType": "Water Bill",
"dueAmount": 150.50,
"dueDate": "2025-12-31T00:00:00.000Z",
"status": "PENDING",
"createdAt": "2025-12-01T10:30:00.000Z"
}
}
Create a new subscription with support for 3 types: Fixed Monthly, Custom Schedule, or Open-Ended.
Fixed amount paid monthly until completed (e.g., phone installment)
Custom payment dates and amounts (e.g., quarterly payments)
Recurring monthly until cancelled (e.g., gym membership)
| Parameter | Type | Required | Description |
|---|---|---|---|
subscriptionType |
string | Required | FIXED_MONTHLY, CUSTOM_SCHEDULE, or OPEN_ENDED |
customerName |
string | Required | Customer's full name |
customerPhone |
string | Required | Phone (07xxxxxxxx) |
productName |
string | Required | Product or service name |
customerEmail |
string | Optional | Customer's email |
autoGenerateInvoices |
boolean | Optional | Auto-create invoices (default: true) |
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
totalAmount |
number | Required | Total amount (JOD) | 1200 |
monthlyPayment |
number | Required | Monthly installment | 100 |
paymentDay |
number | Required | Day of month (1-28) | 5 |
| Parameter | Type | Required | Description |
|---|---|---|---|
totalAmount |
number | Required | Total amount (JOD) |
customInstallments |
array | Required | Array of payment objects (see below) |
[
{
"dueDate": "2025-12-10",
"amount": 300,
"description": "First payment"
}
]
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
recurringAmount |
number | Required | Monthly recurring amount | 25 |
paymentDay |
number | Required | Day of month (1-28) | 1 |
{
"subscriptionType": "FIXED_MONTHLY",
"customerName": "Razzbery Solutions",
"customerPhone": "0777839071",
"customerEmail": "info@razzbery.com",
"productName": "iPhone 15 Pro Max",
"totalAmount": 1200,
"monthlyPayment": 100,
"paymentDay": 5,
"autoGenerateInvoices": true,
"description": "iPhone 15 Pro Max 256GB Black"
}
{
"subscriptionType": "CUSTOM_SCHEDULE",
"customerName": "Ahmad Ali",
"customerPhone": "0791234567",
"customerEmail": "ahmad@razzbery.com",
"productName": "Laptop Dell XPS 15",
"totalAmount": 900,
"customInstallments": [
{
"dueDate": "2025-12-10",
"amount": 300,
"description": "First payment"
},
{
"dueDate": "2026-03-10",
"amount": 300,
"description": "Second payment"
},
{
"dueDate": "2026-06-10",
"amount": 300,
"description": "Final payment"
}
],
"autoGenerateInvoices": true
}
{
"subscriptionType": "OPEN_ENDED",
"customerName": "Razzbery Solutions",
"customerPhone": "0777839071",
"customerEmail": "info@razzbery.com",
"productName": "Gym Membership - Premium",
"recurringAmount": 25,
"paymentDay": 1,
"autoGenerateInvoices": true,
"description": "Premium gym membership"
}
{
"success": true,
"message": "Subscription created successfully",
"data": {
"_id": "674a1b2c3d4e5f6a7b8c9d0e",
"subscriptionNo": "SUB-20251201-0001",
"subscriptionType": "FIXED_MONTHLY",
"customerName": "Razzbery Solutions",
"customerPhone": "0777839071",
"productName": "iPhone 15 Pro Max",
"totalAmount": 1200,
"monthlyPayment": 100,
"recurringAmount": null,
"numberOfInstallments": 12,
"status": "ACTIVE",
"createdAt": "2025-12-01T10:30:00.000Z"
}
}
All error responses follow the same format and include a descriptive error code and message.
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Human readable error message"
}
}
API key is missing from the request headers.
{
"success": false,
"error": {
"code": "NO_API_KEY",
"message": "API key is required. Please provide X-API-Key header."
}
}
The provided API key is invalid or expired.
{
"success": false,
"error": {
"code": "INVALID_API_KEY",
"message": "Invalid API key provided."
}
}
Required fields are missing from the request.
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Missing required fields",
"required": [
"customerName",
"customerPhone",
"serviceType",
"dueAmount",
"dueDate"
]
}
}
Phone number doesn't match the required format.
{
"success": false,
"error": {
"code": "INVALID_PHONE",
"message": "Phone number must match pattern: 07xxxxxxxx"
}
}
Amount must be greater than zero.
{
"success": false,
"error": {
"code": "INVALID_AMOUNT",
"message": "Due amount must be greater than 0"
}
}
Subscription type is not valid.
{
"success": false,
"error": {
"code": "INVALID_TYPE",
"message": "Invalid subscription type",
"validTypes": [
"FIXED_MONTHLY",
"CUSTOM_SCHEDULE",
"OPEN_ENDED"
]
}
}
An unexpected error occurred on the server.
{
"success": false,
"error": {
"code": "SERVER_ERROR",
"message": "An error occurred while creating the bill",
"details": "Database connection timeout"
}
}
| Status Code | Meaning | Description |
|---|---|---|
| 200 | OK | Request succeeded |
| 400 | Bad Request | Invalid request data |
| 401 | Unauthorized | Authentication failed |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server encountered an error |