Getting Started
Getting Started
Installation
Installation
HTTP Rules (Modify Traffic)
HTTP Rules (Modify Traffic)
Overview
Redirect URL (Map Local, Map Remote)
Replace Strings (Switch Hosts, API Endpoints)
Modify Headers
Modify Request Body
Modify Response Body
Modify Query Params
Modify Cookies
Modify DOM/Inject scripts
Modify User Agents
Delay Request
Cancel Rule
Organizing Rule
Import/Export Rules from File
Pause/Resume Requestly
Rule Operators
Advance Targeting
Sharing Rules
Map Local
Map Remote
Pinning Rules
GraphQL Support
Edit and Replay
Import Setting from Charles Proxy
Test URL Condition
Test this Rule
File Server
File Server
Sessions Replay
Sessions Replay
Getting Started
Getting Started
Installation
Installation
HTTP Rules (Modify Traffic)
HTTP Rules (Modify Traffic)
Overview
Redirect URL (Map Local, Map Remote)
Replace Strings (Switch Hosts, API Endpoints)
Modify Headers
Modify Request Body
Modify Response Body
Modify Query Params
Modify Cookies
Modify DOM/Inject scripts
Modify User Agents
Delay Request
Cancel Rule
Organizing Rule
Import/Export Rules from File
Pause/Resume Requestly
Rule Operators
Advance Targeting
Sharing Rules
Map Local
Map Remote
Pinning Rules
GraphQL Support
Edit and Replay
Import Setting from Charles Proxy
Test URL Condition
Test this Rule
File Server
File Server
Â
Modify Response Body
The Modify Response Rule allows you to mock the response body of an HTTP request.
Popular use cases
- You want to work on front-end while back-end is not available or ready yet.
- You want to test application behaviour when provided altered data.
- You want to simulate errors by returning different status codes.
- You want to modify API responses but don't have access to the back-end.

Supported resource types
Response Rule resource types
- Rest API: Supports modifying XHR/fetch requests.
- GraphQL API: Target & modify GraphQL api using operation.
- HTML/JS/CSS: Only available in Desktop app
Types of Modifications
Static Response Modification
In this mode, you can enter the response body which you want as the response.
Response Rule - Static Body
- Source Condition : If the request url matches this source condition, then only the rule is applied. You can useÂ
URL
,ÂHost
 orÂPath
 withÂRegex
,ÂContains
,ÂWildcard
 orÂEquals
 to match the source request. Learn more about source conditions here.
- Status Code : Update the Response status code. (2XX, 3XX, 4XX, 5XX ...). If left empty, original status code is returned.
- Static Response Body : Define the updated response body which needs to be returned.
- Source Filters : This helps you define better targeting conditions and restrict rules to be applied on specific webpages (or domains), request types, request methods, or request payload. Learn more about source filters here.
Programmatic Response Modification
Programmatic Modification Script (JS)Â : Write a JavaScript script which can modify the existing response programmatically.
Arguments of modifyResponse
method
 (string)- The HTTP method of the request.ÂGET | POST | PUT | DELETE
 etc.
url
 (string) - The request URL.
response
 (string)- The original response object represented as string. Eg:
'{"id":1,"app":"requestly","feature":"modify-request"}'
responseType
 (string)- The content-type of the HTTP response.
requestHeaders
 (Object)- The request headers sent to the server.
requestData
 (string)- The HTTP request payload in case ofÂPOST | PUT | PATCH
 requests.
responseJSON
 (JSON object)- The original response represented as JSON Object:
{ "id":1, "app":"requestly", "feature":"modify-request" }
Return type of modifyResponse (string
 or JSON
 object)
You can modify both response or responseJSON and return any of them. Response Rule will automatically handle the response returned for the request.
Targeting GraphQL requests
You can target GraphQL requests using the operation name in request body. To do so add:
- Payload JSON Key, e.g.,Â
operationName
- Value, e.g.,Â
getUsers
To learn more about this checkout GraphQL Support.
Guides
- Modifying Response asynchronously: Async modifications lets you perform some long running tasks before returning the response
- Modifying Non Existent Domain: Helpful for frontend developers when the backend isn't ready yet.
Â
FAQs
What happens if I leave the status code field empty
If you leave the status code empty, then the original status code of the request is returned.
Where would console.log
show up?
TODO
Â