Forex CRM and the MT4/MT5 Manager API: An Integration Specification
The CRM and trading server integration is a production interface that moves money and changes accounts. Specify it like one: scope, authentication, behaviour under failure and proof that it works.

Scope: workflow inventory
List each workflow and its direction: account creation (CRM to server), group change (CRM to server), balance operation (CRM to server), account and trade data read (server to CRM). For each define trigger, inputs, outputs and the system of record. See our Manager API page.
Authentication and permissions
Define credentials, where they are stored, who can rotate them and the minimum permissions each workflow needs. On a grey label, confirm which management interfaces your setup exposes.
Idempotency and retries
Assign every balance operation a unique request identifier. On retry, check whether it was applied before applying again. Specify timeouts, retry counts and back-off.
Error handling
Define how errors surface: alerts, queues for manual review and reconciliation jobs. Define behaviour on partial failure, such as an account created but not recorded.
Acceptance tests
- Success path for each workflow.
- Duplicate request.
- Invalid input.
- Loss of connectivity mid-operation.
- Permission denial.
- Reconciliation after each test.
Monitoring
Specify metrics and alerts: failed calls, latency, unusual balance operation volume. Review access and credentials on a schedule. See also the CRM scoring model.
Example test case
Test: approve a deposit twice due to a simulated timeout. Expected: balance operation applied once, second request returns the original result, CRM status shows completed once, reconciliation shows no difference.
Each workflow deserves at least one such test written as input, expected result and evidence.
Workflow inventory and scope
Begin with a workflow inventory: account creation, credit, debit, group change, block or unblock, read balances and positions, read history, manage manager access. For each, document the API operations used, inputs, outputs, error codes and the business rule. This inventory is the scope and the basis of test cases.
Distinguish read operations (low risk) from write operations (high risk). Write operations need approvals, limits and audit trails in the CRM.
Authentication, permissions and secrets
Use a dedicated service identity with the minimum permissions required. Store credentials in a secrets manager, rotate them on a schedule, and restrict network access to known addresses. Log every call with caller, operation, parameters (masked as needed), result and correlation identifier.
Treat the integration identity as privileged: monitor for use outside expected patterns and alert on anomalies.
Idempotency, retries and ordering
Design write operations to be idempotent using client-generated reference identifiers. Implement retries with backoff and a maximum attempt count, and move exhausted items to a dead-letter queue with an alert. Preserve ordering where required, for example credit before bonus.
Test by injecting failures: timeout after success, timeout before action, duplicate delivery and out-of-order delivery. Verify balances and records after each.
Test cases and monitoring
| Case | Input | Expected result | Evidence |
|---|---|---|---|
| Duplicate credit | Same reference twice | One balance operation | Platform log and CRM record |
| Timeout after success | Response lost | No double credit on retry | Reconciliation report |
| Invalid group | Unknown group | Rejection, no account | Error log |
| Permission denied | Write with read-only identity | Rejection logged | Audit log |
Monitor error rates, latency, queue depth and reconciliation differences. Alert on thresholds and review weekly.
Runbook and change management
Write a runbook for the likely incidents: API unreachable, credential expired, queue growing, reconciliation mismatch. Define actions, owners and communication. Control changes to the integration through versioned releases with regression tests.
See our MetaTrader 5 and CRM patterns for the system-level view.
Worked example: a failure injection session
In staging, set the platform stub to return success then drop the connection. Send a credit with reference R1. The CRM does not see the response, retries with the same reference and the platform returns the original result without applying a second credit. Reconciliation shows one operation.
Now repeat with a delayed response beyond the timeout and with an out-of-order bonus credit. Expected behaviour is documented, each case is automated and results are stored. This session typically exposes at least one defect that only appears under failure.
Versioning and compatibility
Platform and CRM change over time. Maintain a compatibility matrix of API versions, CRM versions and tested combinations. Before upgrading either side, run the regression suite in staging and review release notes for breaking changes.
Treat the integration as software with a release process, not as a one-off project.
Capacity and rate limits
Document limits on request rate, concurrent connections and payload size, and design for them. Use batching where allowed, back off when throttled and avoid polling patterns that waste capacity. Test at the expected peak and at a multiple of it to understand headroom.
Because limits may differ between environments, confirm them for production in writing and record any differences from staging in the environment register.
Frequently asked questions
Which Manager API operations are high risk?
Write operations that change balances, groups or access, which need approvals, limits and audit.
What is idempotency and why does it matter?
Repeated requests with the same reference have no extra effect, preventing double credits on retries.
How should credentials be managed?
Dedicated identity, minimal permissions, secrets store, rotation and network restriction.
What should be monitored?
Error rate, latency, queue depth and reconciliation differences.