Lifecycle mapping
You can run any of these by hand from Module Commands on the service’s page in the WHMCS admin area.

Sub-account handles
Each sub-account handle is deterministic. It is built from three parts:1234 on an installation with hash 3f9a1c7e2b4d gets the handle whmcs3f9a1c7e2b4dya.
The installation hash is derived from your WHMCS system URL and encryption hash when the addon is activated. Because the handle is derived rather than random, a retried provisioning run always looks for the same sub-account. The handle contains no customer identity and no secret material.
The sub-account’s company name is the client’s company name from their WHMCS profile, truncated to 128 characters. If the client has no company name, or it is shorter than three characters, the plugin uses WHMCS service <ID> instead.
What happens on create
When WHMCS runs Create, the module:- Takes a per-service MySQL advisory lock so two operations cannot run on the same service at once. The lock waits up to 20 seconds, then fails with
Another MailChannels operation is already running for this service. - Records the service as
provisioningwith its handle, limit, and credential mode. - Looks for an existing sub-account with that handle by paging through your parent account’s sub-account list.
- Creates the sub-account if none exists. If MailChannels answers with a conflict and the handle is then found, the existing sub-account is reused.
- Sets the send limit from the plan.
- Creates each credential type the plan requires that the service does not already have. Secrets are encrypted immediately with the WHMCS encryption API.
- Marks the service
activeand writes a success entry to the operation history.
provisioning, a sanitized failure entry is written to the operation history, and WHMCS shows the error in the Module Queue. Retrying Create picks up where it left off.
Credential creation safety
Creating a credential is the one step whose outcome can be ambiguous, for example when a request times out after MailChannels has already created the key. To avoid leaving unknown credentials behind, the module:- Lists the sub-account’s credential IDs before the request.
- Creates the credential.
- On an ambiguous failure, lists the IDs again and compares.
- If exactly one new ID appeared, revokes it and retries the creation once.
- If more than one new ID appeared, stops and records
RecoveryRequiredException. An administrator must inspect the sub-account in the MailChannels Console and remove stray credentials before retrying.
What happens on change package
Change Package runs when a customer upgrades or downgrades, or when you apply plan changes from the addon:- Retrieves the sub-account’s current-period usage.
- Rejects the change if the new limit is below current usage. Nothing is changed at MailChannels.
- Applies the new limit.
- Creates any newly required credential type.
- Revokes active module-managed credentials of a type the new plan no longer includes, and erases their stored secrets.
- Records the new limit and mode.
What happens on terminate
Terminate deletes the sub-account at MailChannels. If the sub-account is already gone, the deletion is treated as successful. The plugin then:- Sets every stored credential to
erasedand removes its ciphertext. - Clears cached usage.
- Sets the service to
terminatedand records a tombstone timestamp.
Recover a failed service
Failed operations appear in two places: the WHMCS Module Queue and the Operation history at the bottom of the addon page. Each history row shows the time, service ID, operation, outcome, error code, and the MailChannels request ID when one is available. To retry provisioning from the addon:- Go to Addons > MailChannels Email API and find Recovery and reconciliation.
- Enter the WHMCS service ID and click Retry provisioning.
ModuleCreate API for that service, which runs the same idempotent create flow. You can also retry from the service’s Module Commands in the WHMCS admin area.
Common causes and fixes are listed in Troubleshooting.
Service states
The client area shows the state to the customer while the service is active. See Client area.

