IIndividualPartyManagementPOST Apex Interface

The IIndividualPartyManagementPOST 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.

This interface supports the following hooks.

Create Operation Use Cases 

This table lists common use cases and the hooks required for the POST operation.

Use CaseHook(s)DescriptionExample ScenariosBenefit
Default or Normalize Request FieldstransformRequestTransforms the incoming request before validation or mutation processing. It can supply default values, normalize formats, and map client-specific fields to the canonical request structure.- Apply a default contact status
- Normalize phone numbers or email addresses
- Standardize country and region codes
- Map legacy fields to TMF632 fields
Ensures consistent, standardized data at the point of creation.
Relax or Tighten Built-In ValidatorsconfigureDefaultValidationsEnables, disables, or adjusts built-in validation flags for create requests according to organization-specific requirements.- Require stricter email or phone validation
- Disable a validator that is not applicable to an internal channel
- Require additional identity checks in regulated organizations
- Apply different validation policies by tenant or environment
Supports per-organization validation policies without modifying the shared create implementation.
Enforce Custom Business RulesapplyCustomValidationsEvaluates organization-specific business and eligibility rules before the create mutation is built. Invalid payloads are rejected early with an HTTP 400 response and a clear validation message.- Prevent duplicate contacts based on organization rules
- Require consent before creating a marketing contact
- Validate permitted customer types or lifecycle states
- Require additional fields for specific regions
Rejects invalid payloads early and prevents inconsistent or noncompliant records from being created.
Set Organization-Specific Contact FieldscustomiseMutationPayloadAdds or modifies organization-specific Contact fields in the GraphQL mutation payload before execution. This supports fields that extend beyond the standard TMF632 schema.- Set an internal customer segment
- Add a source-system identifier
- Populate custom consent or preference fields
- Store organization-specific classification data
Persists custom Contact fields beyond the TMF632 data model while preserving the shared API contract.
Audit or Integrate After CreationhandlePostOperationRuns after the create mutation completes and performs post-operation side effects using the creation result. It can write audit records, publish events, or invoke downstream integrations.- Write a contact-creation audit record
- Publish a customer-created event
- Synchronize the contact with a downstream CRM or marketing platform
- Trigger onboarding or notification workflows
Enables reliable auditing and downstream processing after successful creation while keeping side effects separate from the core 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.

Hook Method 

Map<String, Object> transformRequest(Map<String, Object> context)

Sample Apex Implementation 

Default a missing title and normalize the country code.

1global class IndividualPostTransformRequestExt implements comms_apex_ext.IIndividualPartyManagementPOST {
2    global static Map<String, Object> transformRequest(Map<String, Object> context) {
3        if (context == null || !(context.get('requestBody') instanceof Map<String, Object>)) {
4            return context;
5        }
6        Map<String, Object> body = (Map<String, Object>) context.get('requestBody');
7
8
9        if (body.get('title') == null) {
10            body.put('title', 'Contact');
11        }
12
13
14        if (body.get('contactMedium') instanceof List<Object>) {
15            for (Object cmObj : (List<Object>) body.get('contactMedium')) {
16                if (cmObj instanceof Map<String, Object>) {
17                    Map<String, Object> cm = (Map<String, Object>) cmObj;
18                    if ('GeographicAddressContactMedium'.equals(cm.get('@type'))
19                        && cm.get('country') instanceof String) {
20                        cm.put('country', ((String) cm.get('country')).toUpperCase());
21                    }
22                }
23            }
24        }
25        return context;
26    }
27    // ... other hooks return null / empty map ...
28}

configureDefaultValidations 

This hook enables, disables, or modifies the built-in validation rules before they execute.

Hook Method 

Map<String, Boolean> configureDefaultValidations(Map<String, Boolean> defaultValidationConfiguration, Map<String, Object> context)

Sample Apex Implementation 

Relax the contactMedium validation.

1global class IndividualPostConfigValidationsExt implements comms_apex_ext.IIndividualPartyManagementPOST {
2    global static Map<String, Boolean> configureDefaultValidations(
3        Map<String, Boolean> defaultValidationConfiguration,
4        Map<String, Object> context
5    ) {
6        Map<String, Boolean> overrides = defaultValidationConfiguration != null
7            ? defaultValidationConfiguration.clone()
8            : new Map<String, Boolean>();
9        overrides.put('contactMediumValidation', false);   // allow arbitrary contactMedium shapes
10        return overrides;
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)
  • The client receives an HTTP 400 error response.

Hook Method 

Map<String, Object> applyCustomValidations(Map<String, Object> context)

Sample Apex Implementation 

Require a corporate email domain.

1global class IndividualPostValidationExt implements comms_apex_ext.IIndividualPartyManagementPOST {
2    global static Map<String, Object> applyCustomValidations(Map<String, Object> context) {
3        Map<String, Object> result = new Map<String, Object>();
4        if (!(context.get('requestBody') instanceof Map<String, Object>)) {
5            return result;
6        }
7        Map<String, Object> body = (Map<String, Object>) context.get('requestBody');
8
9
10        if (body.get('contactMedium') instanceof List<Object>) {
11            for (Object cmObj : (List<Object>) body.get('contactMedium')) {
12                Map<String, Object> cm = (Map<String, Object>) cmObj;
13                if ('EmailContactMedium'.equals(cm.get('@type'))) {
14                    String email = (String) cm.get('emailAddress');
15                    if (email != null && !email.endsWithIgnoreCase('@acme.com')) {
16                        result.put('validationStatus', 'fail');
17                        result.put('validationMessage',
18                            'Email domain not allowed. Individuals must use an @acme.com address.');
19                    }
20                }
21            }
22        }
23        return result;   // empty => proceed; validationStatus="fail" => HTTP 400
24    }
25    // ... other hooks return null / empty map ...
26}

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.

Hook Method 

Map<String, Object> customiseMutationPayload(Map<String, Object> request, Map<String, Object> context)

Sample Apex Implementation 

Add custom Contact fields on creation.

1global class IndividualPostCustomMutationExt implements comms_apex_ext.IIndividualPartyManagementPOST {
2    global static Map<String, Object> customiseMutationPayload(
3        Map<String, Object> graphQLAsMap,
4        Map<String, Object> context
5    ) {
6        Map<String, Object> node = new Map<String, Object>{
7            'path' => 'individualData',
8            'addFields' => new Map<String, Object>{
9                'LeadSource'      => 'Web',
10                'Department'      => 'Sales',
11                'Loyalty_Tier__c' => 'Gold'
12            }
13        };
14        return new Map<String, Object>{
15            'nodes' => new List<Object>{ node }
16        };
17    }
18    // ... other hooks return null / empty map ...
19}

handlePostOperation 

This hook post-processes and transforms the API response after data retrieval.

Hook Method 

Map<String, Object> handlePostOperation(Map<String, Object> graphQLQueryResultAsMap, Map<String, Object> constructedTMFResponse, Map<String, Object> context)

Sample Apex Implementation 

Publish a platform event after creation.

1global class IndividualPostHandlePostOpExt implements comms_apex_ext.IIndividualPartyManagementPOST {
2    global static Map<String, Object> handlePostOperation(
3        Map<String, Object> graphQLQueryResultAsMap,
4        Map<String, Object> constructedTMFResponse,
5        Map<String, Object> context
6    ) {
7        String newId = constructedTMFResponse != null
8            ? (String) constructedTMFResponse.get('id')
9            : null;
10        if (newId != null) {
11            EventBus.publish(new Individual_Created__e(Individual_Id__c = newId));
12        }
13        return null;   // ignored for POST
14    }
15    // ... other hooks return null / empty map ...
16}

Full Implementation Example 

Here’s a complete sample Apex implementation using all supported hooks.

1/**
2 * Complete TMF632 Individual (Party Management) POST API extension,
3 * demonstrating all hooks with business logic.
4 */
5global class IndividualPartyManagementPOSTExtension implements comms_apex_ext.IIndividualPartyManagementPOST {
6
7
8    // Hook 1: normalize the request body.
9    global static Map<String, Object> transformRequest(Map<String, Object> context) {
10        if (context != null && context.get('requestBody') instanceof Map<String, Object>) {
11            Map<String, Object> body = (Map<String, Object>) context.get('requestBody');
12            if (body.get('title') == null) {
13                body.put('title', 'Contact');
14            }
15        }
16        return context;
17    }
18
19
20    // Hook 2: keep the default validations (all three enabled).
21    global static Map<String, Boolean> configureDefaultValidations(
22        Map<String, Boolean> defaultValidationConfiguration,
23        Map<String, Object> context
24    ) {
25        return new Map<String, Boolean>();
26    }
27
28
29    // Hook 3: enforce a corporate email domain.
30    global static Map<String, Object> applyCustomValidations(Map<String, Object> context) {
31        Map<String, Object> result = new Map<String, Object>();
32        if (context.get('requestBody') instanceof Map<String, Object>) {
33            Map<String, Object> body = (Map<String, Object>) context.get('requestBody');
34            if (body.get('contactMedium') instanceof List<Object>) {
35                for (Object cmObj : (List<Object>) body.get('contactMedium')) {
36                    Map<String, Object> cm = (Map<String, Object>) cmObj;
37                    if ('EmailContactMedium'.equals(cm.get('@type'))) {
38                        String email = (String) cm.get('emailAddress');
39                        if (email != null && !email.endsWithIgnoreCase('@acme.com')) {
40                            result.put('validationStatus', 'fail');
41                            result.put('validationMessage',
42                                'Email domain not allowed. Individuals must use an @acme.com address.');
43                        }
44                    }
45                }
46            }
47        }
48        return result;
49    }
50
51
52    // Hook 4: add custom Contact fields to the create mutation.
53    global static Map<String, Object> customiseMutationPayload(
54        Map<String, Object> graphQLAsMap,
55        Map<String, Object> context
56    ) {
57        Map<String, Object> node = new Map<String, Object>{
58            'path' => 'individualData',
59            'addFields' => new Map<String, Object>{ 'LeadSource' => 'Web', 'Department' => 'Sales' }
60        };
61        return new Map<String, Object>{ 'nodes' => new List<Object>{ node } };
62    }
63
64
65    // Hook 5: side effect only (return ignored).
66    global static Map<String, Object> handlePostOperation(
67        Map<String, Object> graphQLQueryResultAsMap,
68        Map<String, Object> constructedTMFResponse,
69        Map<String, Object> context
70    ) {
71        return null;
72    }
73}

Response Structure 

Request Body 

A TMF632 Individual create payload supports the following input fields:

  • Scalars:@type (must be "Individual"), givenName, familyName, title, and birthDate.

  • contactMedium[]: Each item includes an @type discriminator and a corresponding value field:

    • EmailContactMediumemailAddress
    • PhoneContactMediumphoneNumber
    • FaxContactMediumfaxNumber
    • GeographicAddressContactMediumstreet1, city, stateOrProvince, postCode, country
  • relatedParty[]: Each item includes a role and a partyOrPartyRole with @type = "PartyRef", @referredType = "Organization", and id set to the Account ID.

    • The first entry sets Contact.AccountId.
    • Additional entries create AccountContactRelation records and require Contacts to Multiple Accounts to be enabled.
1{
2  "@type": "Individual",
3  "givenName": "John",
4  "familyName": "Smith",
5  "title": "VP of Operations",
6  "birthDate": "1980-04-12",
7  "contactMedium": [
8    { "@type": "EmailContactMedium", "emailAddress": "john.smith@acme.com" },
9    { "@type": "PhoneContactMedium", "phoneNumber": "+1-555-0100" },
10    {
11      "@type": "GeographicAddressContactMedium",
12      "street1": "1 Market St",
13      "city": "San Francisco",
14      "stateOrProvince": "CA",
15      "postCode": "94105",
16      "country": "US"
17    }
18  ],
19  "relatedParty": [
20    {
21      "role": "employer",
22      "partyOrPartyRole": { "@type": "PartyRef", "@referredType": "Organization", "id": "001xx000003DHP" }
23    }
24  ]
25}

Response (HTTP 201 Created) 

The created Individual, in the same representation returned by GET (relative href, @type = “Individual”, @baseType = “Party”):

1{
2  "id": "003xx000004MZZ",
3  "href": "/connect/comms/partymanagement/v5/individual/003xx000004MZZ",
4  "@type": "Individual",
5  "@baseType": "Party",
6  "givenName": "John",
7  "familyName": "Smith",
8  "name": "John Smith",
9  "title": "VP of Operations",
10  "birthDate": "1980-04-12",
11  "contactMedium": [
12    { "@type": "EmailContactMedium", "emailAddress": "john.smith@acme.com" },
13    { "@type": "PhoneContactMedium", "phoneNumber": "+1-555-0100" },
14    {
15      "@type": "GeographicAddressContactMedium",
16      "street1": "1 Market St",
17      "city": "San Francisco",
18      "stateOrProvince": "CA",
19      "postCode": "94105",
20      "country": "US"
21    }
22  ],
23  "relatedParty": [
24    {
25      "@type": "RelatedPartyRefOrPartyRoleRef",
26      "role": "employer",
27      "partyOrPartyRole": {
28        "id": "001xx000003DHP",
29        "href": "/connect/comms/partymanagement/v5/organization/001xx000003DHP",
30        "name": "Acme Corporation",
31        "@type": "PartyRef",
32        "@referredType": "Organization"
33      }
34    }
35  ]
36}