Skip to main content

Response Simulation

Simulate server responses to enable more thorough testing and troubleshooting

Overview

Response simulation functionality allows the mimicry of server responses for requests directed to` the /echo endpoint. This capability is valuable for simulating responses from 3rd-party APIs or testing transient faults. This is achieved by defining a set of responses associated with a unique key. When requests with a matching key are received, the responses are delivered in the order defined in the set. If no corresponding response set is found for the provided key or if the response set has expired, the original request is echoed back.

Adding a Response Set

To add a response set, make a POST request to /Echo/AddResponseSet with the following request body:

Field NameTypeRequiredNotes
ResponseSetKeystringOptionalThe key to be associated with the set. If no key provided, a GUID is generated.
TimeToLivestringOptionalThe duration for which a response set remains valid. Max 15 minutes: 00:15:00
ResponsesarrayRequiredAn array of response objects to simulate. Max 10.
Response Object - StatusCodenumericOptionalA valid HTTP status code. Defaults to 200.
Response Object - HeadersarrayOptionalAn array of key-value-pairs for response headers to return. Max 10. If Content-Type is not included, the Content-Type will default to "application/json."
Response Object - BodystringOptionalA string representation of the content to return in the response body.
Response Object - DelaynumericOptionalThe time delay, in milliseconds, before a response is sent. Maximum 90,000 milliseconds.

Example Request

AddingResponseSet Request
{
"Responses": [
{
"StatusCode": 200,
"Headers": {
"Content-Type": "application/json",
"Custom-Header": "Value1"
},
"Body": "{\"message\": \"Response 1\"}",
"Delay": 1000
},
{
"StatusCode": 404,
"Headers": {
"Content-Type": "text/plain"
},
"Body": "Not Found",
"Delay": 2000
},
{
"StatusCode": 201,
"Headers": {
"Content-Type": "application/xml"
},
"Body": "<response>Response 3</response>",
"Delay": 500
},
{
"StatusCode": 500,
"Headers": {
"Content-Type": "text/html"
},
"Body": "<html><body>Internal Server Error</body></html>",
"Delay": 0
}
],
"TimeToLive": "00:03:00"
}

Example Response

AddResponseSet Response
{
"responseSetKey": "bcd5db64-c8fa-497d-927b-69ad0952a4d4",
"timeToLive": "00:03:00",
"expiresAt": "2023-09-05T16:38:55.4495311Z" // UTC
}

Using the Response Set

To use a response set, add the query parameter ResponseSetKey to an /echo request: /echo?ResponseSetKey=bcd5db64-c8fa-497d-927b-69ad0952a4d4

For each request including the ResponseSetKey, the next response in the set will be returned. If the set has expired or already been consumed - the request body and headers will be echoed back with a 200 response code.