Skip to main content

Table of Contents


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:
Example:

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


Endpoints

User Management Endpoints

Get User Balance

Returns current balance and bonus for authenticated user.
Authentication: API Public Key required Response (200 OK):
Note: Amounts are in cents (divide by 100 for actual value) Example:
  • balance: 150000 = 1,500.00 DZD
  • bonus: 5000 = 50.00 DZD

Get All-Time User Bonus

Returns total bonus earned by user.
Response (200 OK):
Note: Amount in cents (25000 = 250.00 DZD)

Mobile Topup (Flexy/Airtime) Endpoints

Create Topup Request

Creates a new mobile top-up request.
Authentication: API Public Key required Middleware Checks:
  • 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 Body:
Validation Rules:
  • request_number: Required, unique identifier for your system
  • customer_name: Required, string
  • phone_number: Required, must match operator format
  • value: Required, integer, between 10 and 5000
  • operator: Required, one of: ooredoo, djezzy, mobilis
  • mode: (Bundle) Required, valid mode for operator (e.g., “prepaid”, “postpaid”)
  • country_code: Required (e.g., “DZ”)
  • webhook_url: Required, valid URL
  • created_at: Required, datetime, max 30 seconds old
Response (201 Created):
Response (402 Payment Required):
Response (413 Payload Too Large):
Response (422 Unprocessable Entity):

Get Topup Request Status

Retrieves the status of a specific topup request.
URL Parameters:
  • request_number (string): Your unique request identifier
Response (200 OK):
Possible Status Values:
  • pending: Awaiting processing
  • sent: Successfully completed
  • failed: Operation failed
  • rejected: Request rejected
  • expired: Request timed out

Get All Sent Operations

Returns all successfully sent topup operations for the authenticated user.
Response (200 OK):

Check Existing Operations

Checks which request numbers exist in the system.
Request Body:
Response (200 OK):
Note: Returns only IDs that exist in the database

Resend Webhook for Processing Requests

Triggers webhook resend for specific request numbers.
Request Body:
Response (202 Accepted):
Response (400 Bad Request):

Topup Configuration Endpoints

List Operators

Returns all active mobile operators.
Authentication: None required Response (200 OK):
Fields:
  • first_number: Array of valid phone number prefixes
  • number_length: Array of valid phone number lengths
  • discount: Percentage discount for regular recharges
  • mode_discount: Percentage discount for mode-based recharges

List Modes

Returns all active recharge modes.
Authentication: None required Response (200 OK):
Fields:
  • mode: Name of the bundle (e.g., “PixX1000”, “Sama Mix”)
  • value: Face value of the recharge
  • amount: Actual amount charged (including fees/discounts)
  • discount: Percentage discount for this mode

Get Mode Details

Returns details for a specific mode.
URL Parameters:
  • id (integer): Mode ID
Response (200 OK):

Vouchers/Gift Cards Endpoints

List All Vouchers

Returns all available digital vouchers, gift and prepaid cards.
Authentication: None required Response (200 OK):
Fields:
  • value: Face value of the card
  • amount: Selling price
  • redeem: Where to redeem the card
  • out_of_stock: Boolean indicating availability

Get Voucher Details

Returns details for a specific voucher.
URL Parameters:
  • id (integer): Voucher ID
Response (200 OK):
Response (404 Not Found):

List Card Categories

Returns all voucher categories.
Authentication: None required Response (200 OK):

Get Cards by Category

Returns all cards in a specific category.
URL Parameters:
  • name_or_id: Category ID (integer) or category name (string)
Response (200 OK):
Response (404 Not Found):

Create Voucher Request

Purchases a digital voucher.
Authentication: API Key required Middleware Checks:
  • API subscription active
  • Voucher category active
  • Sufficient inventory
  • Sufficient balance
Request Body:
Validation Rules:
  • quantity: Required, integer, > 0
  • voucher_name: Required, string
  • value: Required, string (face value)
  • customer_name: Required, string
  • request_number: Required, unique identifier
  • country_code: Required, string
Response (201 Created):
Response (402 Payment Required):
Side Effects:
  • Deducts amount from user balance
  • Assigns voucher from inventory
  • Marks voucher as sold
  • Awards bonus points
Sandbox Mode: For testing users (karaOdin, karaOdin2, kyesmine, developer), returns encrypted/test voucher data without consuming inventory.

Get All Successful Vouchers

Returns all successfully sold vouchers for the authenticated user.
Response (200 OK):
Response (404 Not Found):

Add Voucher to Inventory (Internal)

Adds a new voucher code to inventory.
Authentication: None (should be restricted in production) Request Body:
Response (201 Created):
Side Effects:
  • Increments card quantity
  • Makes voucher available for purchase

Deposit Endpoints

Get All Deposits

Returns deposit history for authenticated user.
Authentication: API Key required Response (200 OK):
Possible Status Values:
  • pending: Awaiting approval
  • approved: Deposit confirmed
  • rejected: Deposit declined

Get Sum of Approved Deposits

Returns total of all approved deposits for authenticated user.
Response (200 OK):

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 Request:
Payload:

Webhook Security

Signature Verification: The webhook includes an HMAC signature in the X-Signature header. Verify using your secret key:
Retry Logic:
  • 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-Authorization header
  • 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
Possible Errors:
  • 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)
Possible Errors:
  • 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)
Possible Errors:
  • 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
Possible Errors:
  • 404: “this voucher is not available”
  • 402: “Insufficient voucher inventory”

Business Logic

Topup Request Lifecycle

  1. Validation
    • Operator valid and active
    • Mode valid and active
    • Phone number format correct
    • Request timestamp recent (less than 30 seconds)
    • Sufficient user balance
  2. Duplicate Check
    • 3-minute cooldown per phone number
    • Prevents duplicate pending requests
  3. Balance Deduction
    • Amount deducted from user wallet
    • Transaction recorded
  4. Request Creation
    • Status set to “pending”
    • Queued for processing
  5. Processing
    • Automatic or manual processing
    • Status updated to “sent”/“failed”
  6. Notification
    • Webhook sent to client URL
    • Up to 5 retry attempts
  7. Finalization
    • Success: Award bonus points
    • Failure: Refund to user balance

Voucher Request Lifecycle

  1. Validation
    • Voucher category active
    • Sufficient inventory
    • Sufficient user balance
  2. Balance Deduction
    • Amount deducted from wallet
    • Transaction recorded
  3. Voucher Assignment
    • Voucher retrieved from inventory
    • Serial and key assigned
  4. Status Update
    • Voucher marked as sold
    • Inventory quantity decremented
  5. Bonus Award
    • Reward points added to bonus wallet
  6. Response
    • Serial and key returned to client

Sandbox Mode

Purpose: Testing without consuming real inventory Sandbox Users:
  • karaOdin
  • karaOdin2
  • kyesmine
  • developer
Behavior:
  • 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 in created_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 unique request_number for idempotent requests:
This ensures duplicate API calls don’t create duplicate charges.

Testing

Testing with Sandbox Mode

Use sandbox accounts for testing:
These accounts return test data without consuming real inventory or balance.

Sample Integration Test


Support

For API support:
  • Email: support@chargily.net
  • 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