API
ক্রেডেনশিয়াল ও API রোল তৈরি, identifier ও secret সহ POST কল, JSON উত্তর, curl উদাহরণ, আর ক্লায়েন্ট, সার্ভিস, অর্ডার, বিলিং, সাপোর্ট ও সিস্টেম অনুযায়ী সব অ্যাকশন।
AIOBilling has an external JSON API: one address, an action name, your credentials and the parameters, and an answer in JSON. Use it to connect a website, a mobile app, an accounting tool or your own scripts - create a client, place an order, read invoices, open a ticket, record a payment. This chapter covers how to sign in, how to limit a credential, the actions and a few examples.
Credentials and API roles
- Open Setup → API Credentials, or the API link in the footer of the admin area (the API page, which has the documentation and your own credentials side by side).
- Choose Generate New API Credential. Fill in a Note (what will use it), the Administrator it acts as, an API Role and the Allowed IP Addresses (one per line; empty means any address).
- Press Generate. The page shows the identifier (it starts with
ab_) and the secret (40 characters). Copy the secret now. It is stored as a hash and is shown only once. If you lose it, delete the credential and make a new one.
The credentials table shows each identifier, note, administrator, role, allowed IP addresses and when it was last used. Creating, editing and deleting need the Manage API Credentials permission. A credential stops working at once when you delete it or when its administrator is disabled.
API roles (the second tab) limit which actions a credential may call. Create a role with a name and tick the allowed actions - for example a role with only GetInvoices and GetClientsDetails for a reporting tool. A credential with no role may call every action. A role in use cannot be deleted.
Calling the API
Send a POST to https://your-billing.example.com/api/ (the address the API page shows as the endpoint) with:
| Parameter | Meaning |
|---|---|
action | The action name, for example GetInvoices. Not case sensitive. |
identifier | The credential's identifier. |
secret | The credential's secret. |
| the rest | The parameters of the action. |
Parameters may be sent as a form (-d), in the query string or as a JSON body. Arrays are written itemdescription[]=... (repeat it). Yes/no values accept 1, on, yes and true.
Every answer is JSON with a result of success or error:
{ "result": "success", "totalresults": 12, "startnumber": 0, "numreturned": 10, "invoices": { "invoice": [ ... ] } }
{ "result": "error", "message": "Authentication Failed" }
| HTTP status | Meaning |
|---|---|
| 200 | Success. |
| 400 | The action failed; message says why, for example Missing argument: clientid. |
| 401 | Authentication Failed - wrong identifier or secret, or the administrator is disabled. |
| 403 | Invalid IP (the caller's address is not in Allowed IP Addresses), or the credential's role may not call this action. |
| 404 | Invalid action; the answer lists every action name. |
List actions take limitstart and limitnum (25 by default, 500 at most) and answer totalresults, startnumber and numreturned. Secrets - gateway keys, passwords and tokens - are never given out by the settings actions.
Switch on API Log under General Settings → Security to keep every call and its status in data/logs/api.log.
Examples
List unpaid invoices:
curl -s https://your-billing.example.com/api/ \
-d "action=GetInvoices" -d "identifier=ab_xxxxxxxxxx" -d "secret=YOUR_SECRET" \
-d "status=Unpaid" -d "limitnum=10"
Create a client:
curl -s https://your-billing.example.com/api/ \
-d "action=AddClient" -d "identifier=ab_xxxxxxxxxx" -d "secret=YOUR_SECRET" \
-d "firstname=Rahim" -d "lastname=Uddin" -d "email=rahim@example.com" \
-d "password2=a-strong-password" -d "country=BD"
Create an invoice with two lines:
curl -s https://your-billing.example.com/api/ \
-d "action=CreateInvoice" -d "identifier=ab_xxxxxxxxxx" -d "secret=YOUR_SECRET" -d "userid=1" \
-d "itemdescription[]=Consulting" -d "itemamount[]=50.00" -d "itemtaxed[]=0" \
-d "itemdescription[]=Setup" -d "itemamount[]=10.00" -d "sendinvoice=1"
Record a payment on an invoice (the amount defaults to the balance):
curl -s https://your-billing.example.com/api/ \
-d "action=AddInvoicePayment" -d "identifier=ab_xxxxxxxxxx" -d "secret=YOUR_SECRET" \
-d "invoiceid=25" -d "transid=BKASH-123" -d "gateway=bkash"
Place an order for a client and accept it:
curl -s https://your-billing.example.com/api/ \
-d "action=AddOrder" -d "identifier=ab_xxxxxxxxxx" -d "secret=YOUR_SECRET" \
-d "clientid=1" -d "paymentmethod=bkash" -d "pid[]=3" -d "billingcycle[]=monthly" -d "domain[]=example.com"
curl -s https://your-billing.example.com/api/ \
-d "action=AcceptOrder" -d "identifier=ab_xxxxxxxxxx" -d "secret=YOUR_SECRET" -d "orderid=40"
The actions
The API page lists every action with its parameters and a filter box. There are 72 in the core; plugins can add more, which the page names under "Plugins add".
Clients and contacts
| Action | Does |
|---|---|
GetClients | List clients (search, status, groupid, orderby, order). |
GetClientsDetails | One client by clientid or email; stats=true adds invoice and income figures. |
AddClient | Create a client; answers clientid. |
UpdateClient | Change a client (status, credit, groupid, address fields and so on). |
DeleteClient, CloseClient | Delete a client and everything of theirs, or set the status to Closed. |
GetContacts, AddContact | Contacts and sub-accounts of a client. |
ValidateLogin | Check a client's email and password2; answers userid. |
Products, services and domains
| Action | Does |
|---|---|
GetClientsProducts, UpdateClientProduct | A client's services, and change one. |
GetClientsDomains, UpdateClientDomain | A client's domains, and change one. |
ModuleCreate, ModuleSuspend, ModuleUnsuspend, ModuleTerminate, ModuleChangePassword | Run the server module on a service (accountid). |
DomainRegister, DomainRenew, DomainGetNameservers, DomainUpdateNameservers | Registrar commands on a domain. |
DomainWhois | Is a domain available? |
GetProducts, GetPromotions, GetTLDPricing, GetCurrencies, GetPaymentMethods | Read the catalogue, promotion codes, domain prices, currencies and active gateways. |
Orders
| Action | Does |
|---|---|
GetOrders, GetOrderStatuses | List orders with their lines, and the statuses with counts. |
AddOrder | Place an order for a client (pid[], billingcycle[], domain[], domaintype[], regperiod[], addons[], promocode, noinvoice, noemail). |
AcceptOrder | Accept a pending order (autosetup, sendregistrar, sendemail). |
CancelOrder, PendingOrder, FraudOrder, DeleteOrder | Move an order to another status, or delete it. |
Billing
| Action | Does |
|---|---|
GetInvoices, GetInvoice | List invoices (status may be Overdue), or one invoice with items and transactions. |
CreateInvoice, UpdateInvoice | Create an invoice from line items; change an invoice and its lines. |
AddInvoicePayment | Record a payment; the invoice is marked paid when covered. |
ApplyCredit, AddCredit, GetCredits | Use a client's credit on an invoice, add or remove credit, read the credit log. |
GetTransactions, AddTransaction | List and add transactions. |
GetQuotes, CreateQuote, AcceptQuote | Quotes; accepting one makes an invoice. |
GetAffiliates | Affiliates with balances. |
Support
| Action | Does |
|---|---|
GetTickets, GetTicket | List tickets (status may be Active or Awaiting Reply), or one with its replies. |
OpenTicket, AddTicketReply, UpdateTicket, DeleteTicket | Open a ticket (for a client or a visitor by name and e-mail), reply as staff or as the client, change, delete. |
GetSupportDepartments, GetSupportStatuses | Departments and statuses with counts. |
GetAnnouncements, AddAnnouncement | Announcements. |
System and mail
| Action | Does |
|---|---|
GetStats, GetHealthStatus, GetAdminDetails | Dashboard numbers; version, PHP, database and the last automation run; the administrator of the credential. |
GetActivityLog, LogActivity | Read the activity log, or write a line into it. |
GetConfigurationValue, SetConfigurationValue | Read or write a setting (never those that hold passwords, keys or tokens). |
EncryptPassword, DecryptPassword | Encrypt and decrypt text the way the script stores passwords. |
SendEmail, SendAdminEmail, GetEmailTemplates | Send a template or custom message to a client or to the administrators; list the templates. |
Good habits
- Make one credential per application, each with its own API role and, where the caller has a fixed address, Allowed IP Addresses.
- Always use
https://. Never put the secret in a web page or a mobile app that others can read. - Test with a role that can only read, then widen it.
- Delete credentials you no longer use. The last used time on the credentials page shows which ones are idle.
এই লেখাটি কি কাজে লেগেছে?
হালনাগাদ 2026-11-03