The IAccountManagementPOST Apex interface provides extensibility for POST operations through Apex pre- and post-hooks and GraphQL query customization. Implementations can validate incoming requests, modify query structures, and refine the response to support business-specific retrieval rules while maintaining TMF-compliant behavior.
Normalizes the incoming request and supplies default, derived, or contextual values before validation and mutation processing begins.
- Apply a default Account status or type - Normalize names, phone numbers, and addresses - Derive the region from the country code - Add a source-system value from the request context
Reduces client payload complexity and ensures consistent Account data at creation.
Enforce Business Rules
applyCustomValidations
Evaluates the request against organization-specific rules before the create mutation is built. Invalid requests are rejected early with a clear error response.
- Prevent duplicate Account names - Restrict creation to permitted Account types - Require registration details for business Accounts - Validate regional or lifecycle requirements
Rejects invalid requests early and prevents inconsistent or noncompliant Accounts from being created.
Relax or Tighten Built-In Validators
configureDefaultValidations
Enables, disables, or adjusts built-in validation flags according to the organization’s Account creation process.
- Require additional mandatory fields - Relax validations for trusted internal channels - Enable stricter address or identifier checks - Apply different validation policies by Account type or region
Adapts mandatory-field and validation rules to organization-specific processes without changing the shared create implementation.
Auto-Populate or Override Mutation Fields
customiseMutationPayload
Adds or replaces fields in the GraphQL mutation payload before execution, including organization-specific values that are not represented in the TMF schema.
- Set internal classification or segmentation fields - Add a source-system or correlation ID - Populate audit and provenance fields - Override a derived lifecycle status
Persists organization-specific fields beyond the standard TMF schema while preserving the shared API contract.
Create Related Records Atomically
customiseMutationPayload (insertGraphQlSnippet)
Inserts an additional GraphQL operation into the create mutation so related or junction records are created together with the Account.
Keeps custom and related data consistent with the Account while reducing additional API calls and partial-write risks.
Create an Audit Trail or Trigger Downstream Processing
handlePostOperation
Runs after the Account creation mutation succeeds and uses the operation result to perform compliance logging, publish events, or invoke downstream integrations.
- Write an Account-creation audit record - Publish an Account-created event - Synchronize the Account with billing or CRM systems - Trigger onboarding, compliance, or notification workflows
Supports compliance and integration side effects while keeping them separate from the core creation operation.
transformRequest
This hook transforms the request context before processing any operation. It is invoked early in the request lifecycle, allowing implementers to adjust the context for subsequent extensibility hooks.
Allow contacts without a contact name while preserving required validations.
1global class AccountMgmtValidationConfigPostExt implements comms_apex_ext.IAccountManagementPOST {2 global static Map<String, Boolean> configureDefaultValidations(3 Map<String, Boolean> defaultValidationConfiguration,4 Map<String, Object> context5 ) {6 // Keep mandatoryFieldsValidation and relatedPartyValidation ON (defaults);7 // turn OFF only contactValidation.8 return new Map<String, Boolean>{9 'contactValidation' => false10 };11 }12 // ... other hooks return null / empty map ...13}
applyCustomValidations
This hook validates custom business logic before retrieving customer record. If validation fails, it rejects the request and returns an error response.
The handler processes return values as follows.
Success:
Return a map with validationStatus set to “pass” (case-insensitive).
The API request continues normally.
Other fields in the map are logged but not used.
Failure:
Return a map with validationStatus set to “fail” (case-insensitive).
The API request is terminated immediately.
Raise a ValidationException containing
message: value from validationMessage key (or “Validation failed” by default)
details: value from validationDetails key (optional)
1global class AccountMgmtCustomValidationPostExt implements comms_apex_ext.IAccountManagementPOST {2 global static Map<String, Object> applyCustomValidations(Map<String, Object> context) {3 Map<String, Object> requestBody = (Map<String, Object>) context.get('requestBody');4 Map<String, Object> result = new Map<String, Object>();5 if (requestBody != null && requestBody.containsKey('name')) {6 String name = (String) requestBody.get('name');7 if (name != null && name.startsWith('INVALID_')) {8 result.put('validationStatus', 'fail');9 result.put('validationMessage',10 'Custom validation failed: name cannot start with INVALID_');11 result.put('validationDetails', new Map<String, Object>{12 'rejectedName' => name,13 'rule' => 'RESERVED_PREFIX'14 });15 return result;16 }17 }18 result.put('validationStatus', 'pass');19 return result;20 }21 // ... other hooks return null / empty map ...22}
customiseMutationPayload
This hook modifies the mutation payload before deleting a customer record. Use this to add deletion metadata, set soft-delete flags, or apply business logic transformations.