The WHMCS API is a set of named actions that let code do what staff do in the admin area. Code outside the installation posts to includes/api.php with an identifier, a secret, an action and responsetype=json, after you create an API role and allow the caller's IP address. Code inside WHMCS calls localAPI() instead, with no keys at all.
The WHMCS API is the documented command set of a WHMCS installation: named actions, each with its own parameters and its own response, that read and change billing data without a person clicking through the admin area. It is not a REST API and it has no versioned base URL. Every external call is a POST of form fields to one endpoint, and the action field decides what happens.
Everything below was checked against the WHMCS developer documentation on 19 November 2026, with 9.1 listed as the General Availability release on the WHMCS documentation home page. The API pages are not versioned, so the same calls apply on 9.0 and 8.13.

Which WHMCS API should you call, the external one or localAPI?
Where your code runs decides it. The Getting Started page gives two methods: the External API, for a system hosted away from the installation, which accepts POST requests at includes/api.php, and the Internal API, for calls made from within WHMCS. Both run the same actions.
| Question | External API | Internal API |
|---|---|---|
| Where the code runs | Any other server | Hooks, modules, custom pages |
| How you call it | HTTPS POST to includes/api.php | localAPI($command, $values, $adminUsername) |
| Credentials | Identifier and secret in every request | None |
| IP allow list | Applies, and is on by default | Does not apply |
| What usually breaks it | Wrong IP, wrong role, a secret with a trailing space | Code running before WHMCS loads |

In words: code inside WHMCS uses localAPI() and needs no keys. Code acting for other people belongs on OAuth. Everything else is the external API, with the IP allow list when the caller has a fixed address and an access key when not.
How do you create a WHMCS API role and credentials?
Go to Configuration > System Settings > Manage API Credentials. The API Credentials documentation is explicit that at least one API role must exist first, because the role is the subset of actions a credential may run.
- On the API Roles tab, click Create API Role, name it, tick only the permissions this integration needs, and save.
- On the API Credentials tab, click Generate New API Credential, pick the admin it authenticates as, select the roles and click Generate.
- Copy the secret and store it safely. If you lose it, the documented fix is a new pair and deleting the old one.
Four rules catch people out, and each shows up as an authorization failure rather than a helpful message:
- The admin's role group needs the API Access permission, a separate setting from the API role.
- A credential with no role has no authorization, and roles that allow no actions deny every request.
- Changing the admin's password does not invalidate credentials. Disabling or deleting that admin does.
- Deleting a role unassigns it from every credential, and recreating it later does not reattach it.
The authentication page also documents the pre-7.2 method, an admin username with the MD5 hash of that admin's password. It is kept for backwards compatibility and may be deprecated. I avoid it: it ties an integration to one person's login.
How do you let the caller's IP address through?
Add the address to the allowed IPs list on the Security tab at Configuration > System Settings > General Settings. The Access Control page opens with the sentence that matters: access to the API by default is restricted by IP. A correct identifier and secret are not enough on their own. That page still writes the path the old way, as Setup > General Settings > Security, but it is the same tab.
Where the caller has no fixed address, WHMCS documents an access key. Add one line to configuration.php in the WHMCS root, then send the same value as an accesskey parameter on every request:
$api_access_key = 'secret_key_passphrase_goes_here';
The key may contain letters, numbers and the characters ! @ # $ % . ( ) * [ ] - _ only, so a passphrase with anything else in it is worth rewriting before you chase a failing call. It bypasses the IP restriction, so it removes a layer of protection.
How do you make a first WHMCS API call in PHP?
Send a POST with four fields plus the action's own parameters. The sample code page gives the cURL shape; this is it with the error handling I would not ship without.
<?php
$keys = require '/home/acme/whmcs-api-keys.php'; // outside the web root
$ch = curl_init('https://billing.example.com/includes/api.php');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query([
'identifier' => $keys['identifier'],
'secret' => $keys['secret'],
'action' => 'GetClientsDetails',
'email' => 'jane@example.com',
'responsetype' => 'json',
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_TIMEOUT => 30,
]);
$raw = curl_exec($ch);
if ($raw === false) {
throw new RuntimeException('Network: ' . curl_error($ch));
}
$data = json_decode($raw, true);
if (($data['result'] ?? '') !== 'success') {
throw new RuntimeException($data['message'] ?? 'No valid reply from WHMCS');
}
echo $data['client']['fullname'];
Neither check is decoration. The curl_exec test separates a network failure from a WHMCS refusal, and they need different fixes. The result test runs first because every response carries a result of success or error, and an error brings a message instead of the fields you wanted.
The Response Types page lists JSON, which it recommends, XML, and NVP, which it marks deprecated. WhmcsDetails needs no parameters and proves credential, role and IP in one call, so it makes the best first test. One trap above: the GetClientsDetails reference says the client information also comes back in the top level array, and marks that copy deprecated. Read from client.
Which WHMCS API actions will you actually use?
A handful out of a long list. I counted 162 actions on the API Index on 19 November 2026, under sixteen group headings lopsided in a way that tells you what the API is for: Products holds one action, AddProduct.

| Group | Actions | Group | Actions |
|---|---|---|---|
| Billing | 24 | Project Management | 10 |
| System | 24 | Users | 9 |
| Client | 17 | Tickets | 9 |
| Domains | 17 | Service | 9 |
| Support | 15 | Authentication | 6 |
| Orders | 11 | Module | 5 |
| Action | Required parameters | Worth knowing |
|---|---|---|
AddClient | Name, email, address, city, state, postcode, 2 character ISO country, phone. | password2 and securityqid become required when owner_user_id is absent. Card fields are marked Deprecated. |
GetClientsDetails | clientid or email. | Add stats for balances and revenue figures. |
AddOrder | clientid, paymentmethod in system format. | It ignores the "Automatically setup the product as soon as an order is placed" option, so you must make a subsequent explicit call to AcceptOrder. |
GetInvoices | None. | Filter with userid or status; sort with orderby. Default page size 25. |
AddInvoicePayment | invoiceid, transid, gateway, date. | For money taken outside WHMCS, such as a bank transfer. |
ModuleCreate | serviceid. | Runs the provisioning module on the product. Siblings: ModuleSuspend, ModuleUnsuspend, ModuleTerminate. |
CreateSsoToken | None. Both client_id and user_id are listed optional, so pass one. | Valid for 60 seconds at most. Returns access_token and a ready-made redirect_url. |
How do you call the WHMCS API from inside WHMCS?
Call localAPI($command, $values, $adminUsername) and read the returned array. The Internal API page says the import of init.php is not required when you are already in a WHMCS runtime, such as in a hook. A standalone script in the WHMCS directory does need require_once 'init.php'; first.
$result = localAPI('GetClientsDetails', ['clientid' => 42, 'stats' => true]);
if ($result['result'] === 'success') {
$email = $result['client']['email'];
$overdue = $result['stats']['numdueinvoices'];
}
The Local API examples in the reference mark the third argument "Optional for WHMCS 7.2 and later". Inherited hooks often still pass a hard-coded admin username, which is the first thing I check when old code breaks after a staff change: that admin was deleted, and the call went with them. No HTTP request happens, so there is no secret and no IP check, which also means a mistake runs with full authority. These calls pair with the events in my hooks guide.
How do you read server data through the WHMCS server API?
Two actions sit in the Servers group, both read-only. GetServers returns the servers configured in WHMCS and takes three optional parameters: serviceId for a product's module type, addonId for an addon, and fetchStatus, which the reference describes as an attempt to fetch server status values. GetHealthStatus takes the same flag.
The word "attempt" matters: WHMCS has to reach each machine, so the server that is down is the one that makes the call slow. Give monitoring jobs a generous timeout.
A WHMCS server API search usually means one of three things:
- Your server list or health. The Servers group above.
- Acting on a customer's service. The Service group, led by
ModuleCreate. These run the provisioning module attached to the product, so the real work happens in the module and in the panel's own API. - Seeing what failed.
GetModuleQueue, in the Module group, which reads the module command queue.
If the panel you provision on has no WHMCS module, no action bridges that gap and you need a custom WHMCS module of your own, or the same pattern wrapped as a WHMCS MCP server.
How do you page through results and catch errors?
List actions return a page, not a set. GetInvoices documents limitstart as the offset, default 0, and limitnum as the record count, default 25, and reports totalresults, startnumber and numreturned. A script that reads only the first response misses everything past record 25.
$start = 0;
do {
$page = whmcsApi([
'action' => 'GetInvoices',
'status' => 'Unpaid',
'limitstart' => $start,
'limitnum' => 100,
]);
if (($page['result'] ?? '') !== 'success') {
throw new RuntimeException($page['message'] ?? 'WHMCS did not answer');
}
foreach ($page['invoices']['invoice'] as $invoice) {
// handle $invoice
}
$start += (int) $page['numreturned'];
} while ($page['numreturned'] > 0 && $start < (int) $page['totalresults']);
Stopping on a zero-length page as well as on the total keeps a changing data set from spinning the loop forever. Note the shape too: GetInvoices nests rows under invoices then invoice, while the documented GetUsers response returns a flat users array.
How do you debug a WHMCS API call that fails?
Read the message field, then work through the three gates in front of every action: the role, the IP address and the credential.
| What you see | Where to look |
|---|---|
| No JSON at all, and cURL reports an error | Network, DNS or TLS. This is before WHMCS. |
| Every call refused, whatever the action | The IP allow list. Check the address WHMCS sees. |
| Authentication refused with a correct-looking key pair | A trailing space in the secret, a disabled admin, or a role group without API Access. |
| One action refused while others work | The API role. |
Expecting parameter <request-parameter> to be an array | A documented AddOrder error. Parameters such as pid must be arrays even for one item. |
Invalid Payment Method. Valid options include | Also documented for AddOrder. Use the system name, not the display name. |
When that is not enough, the API troubleshooting page says to add $api_enable_logging = true; to configuration.php, which logs calls in tblapilog, and that you must remove the line afterwards.
That page also gives the step I take first: run the documented sample code unmodified. If it works and your code does not, the problem is your code.
What should you check before an integration goes live?
The main risk is that a credential does whatever its role allows with nobody watching. This is the list I work through on a staging copy first.
- The role is ticked down to the actions this integration runs, and nothing else.
- One credential per integration, so one can be revoked without breaking others.
- The caller's IP is on the allow list; an access key only where there is no fixed address.
- Identifier and secret in a file outside the web root, never in a repository or browser JavaScript.
- Every response checked for
resultequal tosuccessbefore any field is read. - List calls paged all the way to
totalresults. $api_enable_loggingremoved fromconfiguration.phpand the log cleared.- A note of which admin each credential authenticates as, so a staff departure does not break billing silently.
One limit deserves saying plainly. CreateSsoToken carries a warning in its own reference: the token gives complete authentication to the client account, and the endpoint that redeems it does not enforce the captcha or two-factor controls of the WHMCS login form.
What else do people ask about the WHMCS API?
How do you authenticate with the WHMCS API?
With an identifier and secret from Configuration > System Settings > Manage API Credentials, sent as the identifier and secret fields of each request. The admin they belong to needs the API Access permission, and the credential needs a role allowing the action.
Does the WHMCS API have a rate limit?
Not one the documentation states. The WHMCS API documentation pages I read on 19 November 2026 name no published limit, so I will not quote a number. Your own server sets the real ceiling through PHP processes and database load.
When should you use OAuth instead of API credentials?
When an app acts on behalf of a WHMCS user rather than on behalf of you. A credential authenticates as an admin, so every call carries that admin's authority. The OAuth introduction says WHMCS uses OAuth 2, that the app never stores the user's WHMCS password, and that the user may revoke access at any time.
Why does a call work from my laptop but not from my server?
Because the allow list is checked against the address the request arrives from, and those are two different addresses. Add the address of whatever machine runs the job in production; shared hosting often sends outbound traffic from an address that is not the site's own.
Can the WHMCS API tell my system when something happens?
No. It answers when asked and never calls you. To be told that an invoice was paid or a service was suspended, write a hook inside WHMCS that posts to your system. The cron drives most of those events, which my WHMCS cron jobs guide covers.
If you would rather have an integration built and tested on a staging copy, that is my WHMCS API integration and automation service, and a review of credentials and roles is part of a WHMCS security audit; scoping calls are free and all sales are final, so ask before buying.
Last reviewed 19 November 2026. Disclosure: I am a freelance WHMCS developer and I sell API integration work, so I am not neutral. I am CTO at ElySpace, a freelance developer for Marmaids LLC, and founder of WHMCSPilot and MagizAI. Action names, parameters, defaults and error strings come from the WHMCS developer documentation as I read it that day.