Table of Contents
- Overview
- Authentication
- Rate Limiting
- Error Handling
- Endpoints
- Webhooks
- API Restrictions & Validations
Overview
Base URL:https://pro.chargily.net/api/v1
Chargily Pro provides a RESTful API for managing mobile top-ups and digital voucher sales. The API supports multiple authentication methods and includes comprehensive validation middleware.
Key Features
- Mobile top-up operations (Ooredoo, Djezzy, Mobilis)
- Digital voucher/card sales
- Wallet & balance management
- Webhook notifications
- Multi-tenant support
- Sandbox mode for testing
Authentication
All API requests require authentication using an API Public Key. Header:Getting Your API Public Key
API Public Keys are generated through your account dashboard. Each API Public Key is unique and associated with your user account.Rate Limiting
- Limit: 2,400 requests per minute
- Applied to: All API routes
- Response on limit: HTTP 429 Too Many Requests
Error Handling
Standard Error Response
HTTP Status Codes
| Code | Meaning | Common Causes |
|---|---|---|
| 200 | OK | Successful GET request |
| 201 | Created | Successful POST request |
| 202 | Accepted | Request accepted for processing |
| 400 | Bad Request | Invalid request format |
| 401 | Unauthorized | Invalid/missing authentication |
| 402 | Payment Required | Insufficient balance |
| 403 | Forbidden | Mode inactive, permission denied |
| 404 | Not Found | Resource doesn’t exist |
| 409 | Conflict | Duplicate request |
| 410 | Gone | Subscription expired |
| 413 | Payload Too Large | Pending request exists (cooldown) |
| 422 | Unprocessable Entity | Validation failed |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server-side error |
Endpoints
User Management Endpoints
Get User Balance
Returns current balance and bonus for authenticated user.balance: 150000= 1,500.00 DZDbonus: 5000= 50.00 DZD
Get All-Time User Bonus
Returns total bonus earned by user.Mobile Topup (Flexy/Airtime) Endpoints
Create Topup Request
Creates a new mobile top-up request.- API subscription active
- Operator valid
- Mode valid and active
- Request timestamp recent (less than 30 seconds)
- Sufficient balance
- No duplicate pending request (3-minute cooldown)
request_number: Required, unique identifier for your systemcustomer_name: Required, stringphone_number: Required, must match operator formatvalue: Required, integer, between 10 and 5000operator: Required, one of:ooredoo,djezzy,mobilismode: (Bundle) Required, valid mode for operator (e.g., “prepaid”, “postpaid”)country_code: Required (e.g., “DZ”)webhook_url: Required, valid URLcreated_at: Required, datetime, max 30 seconds old
Get Topup Request Status
Retrieves the status of a specific topup request.request_number(string): Your unique request identifier
pending: Awaiting processingsent: Successfully completedfailed: Operation failedrejected: Request rejectedexpired: Request timed out
Get All Sent Operations
Returns all successfully sent topup operations for the authenticated user.Check Existing Operations
Checks which request numbers exist in the system.Resend Webhook for Processing Requests
Triggers webhook resend for specific request numbers.Topup Configuration Endpoints
List Operators
Returns all active mobile operators.first_number: Array of valid phone number prefixesnumber_length: Array of valid phone number lengthsdiscount: Percentage discount for regular rechargesmode_discount: Percentage discount for mode-based recharges
List Modes
Returns all active recharge modes.mode: Name of the bundle (e.g., “PixX1000”, “Sama Mix”)value: Face value of the rechargeamount: Actual amount charged (including fees/discounts)discount: Percentage discount for this mode
Get Mode Details
Returns details for a specific mode.id(integer): Mode ID
Vouchers/Gift Cards Endpoints
List All Vouchers
Returns all available digital vouchers, gift and prepaid cards.value: Face value of the cardamount: Selling priceredeem: Where to redeem the cardout_of_stock: Boolean indicating availability
Get Voucher Details
Returns details for a specific voucher.id(integer): Voucher ID
List Card Categories
Returns all voucher categories.Get Cards by Category
Returns all cards in a specific category.name_or_id: Category ID (integer) or category name (string)
Create Voucher Request
Purchases a digital voucher.- API subscription active
- Voucher category active
- Sufficient inventory
- Sufficient balance
quantity: Required, integer, > 0voucher_name: Required, stringvalue: Required, string (face value)customer_name: Required, stringrequest_number: Required, unique identifiercountry_code: Required, string
- Deducts amount from user balance
- Assigns voucher from inventory
- Marks voucher as sold
- Awards bonus points
Get All Successful Vouchers
Returns all successfully sold vouchers for the authenticated user.Add Voucher to Inventory (Internal)
Adds a new voucher code to inventory.- Increments card quantity
- Makes voucher available for purchase
Deposit Endpoints
Get All Deposits
Returns deposit history for authenticated user.pending: Awaiting approvalapproved: Deposit confirmedrejected: Deposit declined
Get Sum of Approved Deposits
Returns total of all approved deposits for authenticated user.Webhooks
Webhook Notifications
The system sends webhook notifications when topup request status changes. Package: spatie/laravel-webhook-server Trigger Events:- Status changed to:
sent,failed,rejected,expired
Webhook Security
Signature Verification: The webhook includes an HMAC signature in theX-Signature header. Verify using your secret key:
- Maximum 5 retry attempts
- Exponential backoff between retries
- SSL verification disabled (for development)
API Restrictions & Validations
All API requests go through automatic validation to ensure data integrity and prevent errors. Below are the restrictions you may encounter:Subscription Status
- Your API subscription must be active
- Error (410 Gone): “Subscription is expired”
Authentication
- Valid API key required in
X-Authorizationheader - Error (401 Unauthorized): “Unauthorized”
Balance Requirements
- Sufficient balance required for purchases
- Error (402 Payment Required): “Insufficient balance”
Operator Validation
When creating topup requests:- Operator must exist and be active
- Phone number length must match operator requirements
- Phone number must start with valid prefix for the operator
- 404: “Operator not found”
- 422: “Invalid phone number length”
- 422: “Invalid phone number format for operator”
Topup Mode Validation
- Mode must exist for the specified operator
- Mode must be active
- Value must match mode requirements (for fixed-value modes)
- 404: “Mode not found for operator”
- 403: “Mode is not active”
Request Timing & Duplicates
- Request timestamp must be within 30 seconds
- No duplicate requests (same
request_number+customer_name)
- 400: “Request timestamp too old (max 30 seconds)”
- 409: “Duplicate request detected”
Voucher Validation
- Voucher category must be active and available
- Sufficient inventory must be available for requested quantity
- 404: “this voucher is not available”
- 402: “Insufficient voucher inventory”
Business Logic
Topup Request Lifecycle
-
Validation
- Operator valid and active
- Mode valid and active
- Phone number format correct
- Request timestamp recent (less than 30 seconds)
- Sufficient user balance
-
Duplicate Check
- 3-minute cooldown per phone number
- Prevents duplicate pending requests
-
Balance Deduction
- Amount deducted from user wallet
- Transaction recorded
-
Request Creation
- Status set to “pending”
- Queued for processing
-
Processing
- Automatic or manual processing
- Status updated to “sent”/“failed”
-
Notification
- Webhook sent to client URL
- Up to 5 retry attempts
-
Finalization
- Success: Award bonus points
- Failure: Refund to user balance
Voucher Request Lifecycle
-
Validation
- Voucher category active
- Sufficient inventory
- Sufficient user balance
-
Balance Deduction
- Amount deducted from wallet
- Transaction recorded
-
Voucher Assignment
- Voucher retrieved from inventory
- Serial and key assigned
-
Status Update
- Voucher marked as sold
- Inventory quantity decremented
-
Bonus Award
- Reward points added to bonus wallet
-
Response
- Serial and key returned to client
Sandbox Mode
Purpose: Testing without consuming real inventory Sandbox Users:- karaOdin
- karaOdin2
- kyesmine
- developer
- Returns encrypted/test voucher data
- Does not consume inventory
- Does not deduct real balance
- Useful for integration testing
Best Practices
Request Timestamps
Always include current timestamp increated_at field:
Webhook Implementation
Implement webhook handler to receive status updates:Error Handling
Always handle API errors gracefully:Balance Management
Check balance before expensive operations:Idempotency
Use uniquerequest_number for idempotent requests:
Testing
Testing with Sandbox Mode
Use sandbox accounts for testing:Sample Integration Test
Support
For API support:- Email: [email protected]
- Documentation: Check this file
- Issue Tracker: Contact your account manager
Changelog
Version 1.0 (2024-01-15)
- Initial API documentation
- All endpoints documented
- Authentication methods described
- Error handling documented
- Webhook system explained