Getting Started
Getting Started
Installation
Installation
Inspect Traffic
Inspect Traffic
HTTP Rules (Modify Traffic)
HTTP Rules (Modify Traffic)
Overview
Request Modification β Redirect URL (Map Local, Map Remote)
Request Modification β Replace Strings (Switch Hosts, API Endpoints)
Request Modification β Modify Headers
Request Modification β Modify Request Body
Response Modification β Modify Response Body
Request Modification β Modify Query Params
Request Modification β Modify User Agents
Request Modification β Delay Request
Request Modification β Map Local
Request Modification β Map Remote
Response Modification β Modify DOM/Inject scripts
Response Modification β Cancel Rule
Predefined Functions
Organizing Rule β Grouping
Organizing Rule β Import/Export Rules from File
Organizing Rule β Pause/Resume Requestly
Organizing Rule β Rule Operators
Organizing Rule β Advance Targeting
Organizing Rule β Sharing Rules
Organizing Rule β Pinning Rules
GraphQL - Modify Request & Response
Import / Export β Charles Proxy Rules
Test Rules β Test URL Condition
Test Rules β Test this Rule
Session Book
Session Book
File Server
File Server
Public API
Public API
Guides
Guides
TroubleShooting
TroubleShooting
Subscription & Billing
Subscription & Billing
Getting Started
Getting Started
Installation
Installation
Inspect Traffic
Inspect Traffic
HTTP Rules (Modify Traffic)
HTTP Rules (Modify Traffic)
Overview
Request Modification β Redirect URL (Map Local, Map Remote)
Request Modification β Replace Strings (Switch Hosts, API Endpoints)
Request Modification β Modify Headers
Request Modification β Modify Request Body
Response Modification β Modify Response Body
Request Modification β Modify Query Params
Response Modification β Modify DOM/Inject scripts
Request Modification β Modify User Agents
Request Modification β Delay Request
Response Modification β Cancel Rule
Organizing Rule β Grouping
Organizing Rule β Import/Export Rules from File
Organizing Rule β Pause/Resume Requestly
Organizing Rule β Rule Operators
Organizing Rule β Advance Targeting
Organizing Rule β Sharing Rules
Request Modification β Map Local
Request Modification β Map Remote
Organizing Rule β Pinning Rules
GraphQL - Modify Request & Response
Import / Export β Charles Proxy Rules
Test Rules β Test URL Condition
Predefined Functions
Test Rules β Test this Rule
File Server
File Server
Public API
Public API
Guides
Guides
Session Book
Session Book
Subscription & Billing
Subscription & Billing
Β
Β
Authentication
To authenticate with the API, use the custom header
x-api-key
with your provided API key.Example:
curl -H "x-api-key: YOUR_API_KEY" https://api2.requestly.io/v1/rules
Requestly API is currently in
BETA
. Fill this form to get your API key today.Endpoints
The current APIs give all the basic crud capabilities for rules. In case you want to quickly try these out on this playground https://requestly.readme.io/
Get rules
You have the option to either get all the rules or get a certain
Get all rules
To retrieve all the rules, use the following endpoint.
Endpoint:
GET /rules
CURL Example:
curl -H "x-api-key: YOUR_API_KEY" https://api2.requestly.io/v1/rules
Sample Response:
{ "success": true, "data": [ { "id": "Redirect_fohh4", "name": "Sample Redirect Rule", "description": "This rule redirects example.com to newexample.com", "status": "Active", "ruleType": "Redirect", "pairs": [ { "source": { "key": "Url", "operator": "Equals", "value": "<https://example.com>" }, "destinationType": "url", "destination": "<https://newexample.com>" } ] }, // ... other rules ] }
Get a particular rule
To retrieve a specific rule, use the rule's unique ID.
Endpoint:
GET /rules/:ruleId
CURL Example:
curl -H "x-api-key: YOUR_API_KEY" https://api2.requestly.io/v1/rules/Redirect_fohh4
Sample Response:
{ "success": true, "data": { "id": "Redirect_fohh4", "name": "Sample Redirect Rule", "description": "This rule redirects example.com to newexample.com", "status": "Active", "ruleType": "Redirect", "pairs": [ { "source": { "key": "Url", "operator": "Equals", "value": "<https://example.com>" }, "destinationType": "url", "destination": "<https://newexample.com>" } ] } }
Create Rule
To create a new rule, send a POST request with the rule details.
Endpoint:
POST /rules
CURL Example:
curl -X POST -H "x-api-key: YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "name": "Cancel Rule for Blocked Site", "description": "This rule blocks access to blockedsite.com", "status": "Active", "ruleType": "Cancel", "pairs": [ { "source": { "key": "Url", "operator": "Equals", "value": "https://blockedsite.com" } } ] }' https://api2.requestly.io/v1/rules
Sample Response:
{ "success": true, "data": { "id": "Cancel_a1b2c", "name": "Cancel Rule for Blocked Site", "description": "This rule blocks access to spammy.com", "status": "Active", "ruleType": "Cancel", "pairs": [ { "source": { "key": "Url", "operator": "Equals", "value": "https://spammy.com" } } ] } }
Update Rule
To update an existing rule, send a PUT request with the updated rule details.
Endpoint:
PUT /rules/:ruleId
CURL Example:
curl -X PUT -H "x-api-key: YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "name": "Replace Rule for Typo", "description": "This rule replaces typodomain.com with correctdomain.com", "status": "Active", "ruleType": "Replace", "pairs": [ { "source": { "key": "Url", "operator": "Equals", "value": "https://typodomain.com" }, "from": "typodomain.com", "to": "correctdomain.com" } ] }' https://api2.requestly.io/v1/rules/Replace_z5x6y
Sample Response:
{ "success": true, "data": { "id": "Replace_z5x6y", "name": "Replace Rule for Typo", "description": "This rule replaces typodomain.com with correctdomain.com", "status": "Active", "ruleType": "Replace", "pairs": [ { "source": { "key": "Url", "operator": "Equals", "value": "https://typodomain.com" }, "from": "typodomain.com", "to": "correctdomain.com" } ] } }
Delete Rule
To delete a rule, send a DELETE request specifying the rule's unique ID.
Endpoint:
DELETE /rules/:ruleId
CURL Example:
curl -X DELETE -H "x-api-key: YOUR_API_KEY" https://api2.requestly.io/v1/rules/Headers_w3e4r
Sample Response:
{ "success": true, "message": "Rule successfully deleted." }
Possible Errors
- Rule not found: The specified rule does not exist.
- Unauthorized action: You do not have access to the specified rule.
- Group not found: The specified group does not exist.
- Rule pairs are invalid: The provided rule pairs do not match the expected schema.
- Rule Payload is invalid: The entire rule payload is invalid.
- Rule Type update not allowed: Attempted to change the rule type after creation.
Each error will return a response in the format:
{ "success": false, "message": "Error message here." }