ApiMock__mdt
Sobject
global class ApiMock__mdt extends SObjectExtends: SObject
Configures mock response scenarios for API services. Supports dynamic response interpolation, request body pattern matching, and fault simulation for both inbound and outbound APIs.
Fields
| Field | Description |
|---|---|
| global Id ApiSetting__c | The API Setting this mock belongs to. |
| global ApiSetting__mdt ApiSetting__r | The API Setting this mock belongs to. |
| global Decimal DelayMs__c | Simulated latency in milliseconds for fault simulation. |
| global Decimal FailureRate__c | Percentage of requests that should return a simulated failure (0-100). |
| global Boolean IsActive__c | Controls whether this mock scenario is active. |
| global Boolean IsRegex__c | When checked, the Match Request Body Pattern is treated as a regular expression instead of a simple contains match. |
| global String MatchRequestBodyPattern__c | Optional pattern to match against request body. |
| global Decimal Priority__c | Match priority for this mock. |
| global String ResponseBody__c | Mock response body content (JSON or XML). |
| global String ResponseHeaders__c | JSON object of response headers to include in the mock response. |
| global Decimal StatusCode__c | The HTTP status code to return in the mock response. |
Field Details
ApiSetting__c
global Id ApiSetting__cThe API Setting this mock belongs to. Multiple mocks can reference one setting, ordered by Priority.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | ApiSetting__mdt |
| Required | true |
| Unique | false |
ApiSetting__r
global ApiSetting__mdt ApiSetting__rThe API Setting this mock belongs to. Multiple mocks can reference one setting, ordered by Priority.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | ApiSetting__mdt |
| Required | true |
| Unique | false |
DelayMs__c
global Decimal DelayMs__cSimulated latency in milliseconds for fault simulation. Set to 0 for no delay. Used to test timeout handling and retry logic.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | Number(5,0) |
| Required | false |
| Unique | false |
| External ID | false |
| Default Value | 0 |
FailureRate__c
global Decimal FailureRate__cPercentage of requests that should return a simulated failure (0-100). Set to 0 for no failures. Used to test retry logic under partial failure conditions.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | Percent(3,0) |
| Required | false |
| Default Value | 0 |
IsActive__c
global Boolean IsActive__cControls whether this mock scenario is active. Inactive mocks are skipped during mock resolution.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | Checkbox |
| Default Value | true |
IsRegex__c
global Boolean IsRegex__cWhen checked, the Match Request Body Pattern is treated as a regular expression instead of a simple contains match.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | Checkbox |
| Default Value | false |
MatchRequestBodyPattern__c
global String MatchRequestBodyPattern__cOptional pattern to match against request body. Uses contains matching by default, or regex when Is Regex is checked.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | Text(255) |
| Required | false |
| Unique | false |
| External ID | false |
Priority__c
global Decimal Priority__cMatch priority for this mock. Lower values indicate higher priority. Used when multiple mocks match the same request.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | Number(3,0) |
| Required | false |
| Unique | false |
| External ID | false |
| Default Value | 100 |
ResponseBody__c
global String ResponseBody__cMock response body content (JSON or XML). Supports dynamic interpolation using {{request.field}} placeholders to echo request data back in the response.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | Long Text Area(131072) |
ResponseHeaders__c
global String ResponseHeaders__cJSON object of response headers to include in the mock response.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | Long Text Area(131072) |
StatusCode__c
global Decimal StatusCode__cThe HTTP status code to return in the mock response.
Field Attributes:
| Attribute | Value |
|---|---|
| Data Type | Number(3,0) |
| Required | false |
| Unique | false |
| External ID | false |
| Default Value | 200 |