---
schema_version: "1"
id: 876c3e0b9a83fc2f0330b4add595999313b62163d7a0a09f1641703b9fe66e30
title: HttpCalloutMock Interface
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_interface_httpcalloutmock.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_httpcalloutmock.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 57099ed59cbcdc87d4a0422fcc557cfbc0bd00cabfc01956369022f2e25105de
description: Enables sending fake responses when testing HTTP callouts.Returns an HTTP response for the given request. The implementation of this method is called by the Apex runtime to send a fake response when an HTTP callout is made after Test.setMock has been called.
---
# HttpCalloutMock Interface

Enables sending fake responses when testing HTTP callouts.

## 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

For an implementation example, see [Testing HTTP Callouts by Implementing the HttpCalloutMock Interface](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm).

## HttpCalloutMock Methods

The following are methods for HttpCalloutMock.

- **[respond(request)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_httpcalloutmock.htm#apex_System_HttpCalloutMock_respond)**  
    Returns an HTTP response for the given request. The implementation of this method is called by the Apex runtime to send a fake response when an HTTP callout is made after Test.setMock has been called.

### respond(request)

Returns an HTTP response for the given request. The implementation of this method is called by the Apex runtime to send a fake response when an HTTP callout is made after Test.setMock has been called.

#### Signature

public HttpResponse respond(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_classes_restful_http_httprequest "Use the HttpRequest class to programmatically create HTTP requests like GET, POST, PATCH, PUT, and DELETE.")

#### Return Value

Type: [System.HttpResponse](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_restful_http_httpresponse.htm#apex_classes_restful_http_httpresponse "Use the HttpResponse class to handle the HTTP response returned by the Http class.")