---
schema_version: "1"
id: f1b60f87b4364679d5dd12b7231ff12c225e8ab13e3c0ccf58404151f8d645a0
title: ExternalServiceTest Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_System_ExternalServiceTest.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_ExternalServiceTest.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 3de4eff92c682608354099a37b59d9116709836127ad9e27dd7a50c823e9c841
description: Provides methods to test an external service's asynchronous callouts, enables sending a mock request, asserts the expected request payload, then triggers the mocked external service’s asynchronous callback response.An instance of the ExternalServiceTest method is used when the test class triggers a mocked external service’s callback response. You can access ExternalServiceTest through Test.getExternalService() Sends the HTTP request back as an external service asynchronous response.
---
# ExternalServiceTest Class

Provides methods to test an external service's asynchronous callouts, enables sending a mock request, asserts the expected request payload, then triggers the mocked external service’s asynchronous callback response.

## Namespace

[System](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_System.htm "The System namespace provides classes and methods for core Apex functionality.")

## Usage

See [Create Unit Testing for Asynchronous Callouts](https://help.salesforce.com/s/articleView?id=platform.external_services_aysnc_ops_testing.htm&type=5&language=en_US) in the "Extend Salesforce with Clicks, Not Code" Help Guide.

- **[ExternalServiceTest Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_ExternalServiceTest.htm#apex_System_ExternalServiceTest_methods)**  
    An instance of the ExternalServiceTest method is used when the test class triggers a mocked external service’s callback response. You can access ExternalServiceTest through Test.getExternalService()

## ExternalServiceTest Methods

An instance of the ExternalServiceTest method is used when the test class triggers a mocked external service’s callback response. You can access ExternalServiceTest through Test.getExternalService()

The following are methods for ExternalServiceTest.

- **[sendCallback(request)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_ExternalServiceTest.htm#apex_System_ExternalServiceTest_sendCallback)**  
    Sends the HTTP request back as an external service asynchronous response.

### sendCallback(request)

Sends the HTTP request back as an external service asynchronous response.

#### Signature

public System.HttpResponse sendCallback(System.HttpRequest request)

#### Parameters

- **request**: Type: [System.HttpRequest](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_restful_http_httprequest.htm#apex_System_HttpRequest_methods)

#### Return Value

Type: [System.HttpResponse](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_restful_http_httpresponse.htm#apex_System_HttpResponse_methods)