This endpoint allows you to modify the details of an existing rule. You can update properties like the rule's name, description, status, source, and destination. This endpoint is useful for keeping your rules updated as your requirements evolve.
For a live view and to test this API interactively, visit the API Playground.
Endpoint
-
Method: PUT
-
URL:
https://api2.requestly.io/v1/rules/{ruleId}
Parameters
Path Parameters
ruleId
(string, required): The unique identifier of the rule you want to update.
Body Parameters
Parameter | Type | Description | Default Value |
---|---|---|---|
| string | Name of the rule. | - |
| string | Description of the rule. | - |
| string | Type of the object. Always set to |
|
| string | Type of the rule. For this schema, it’s | - |
| string | Status of the rule: |
|
| array | List of rule pairs defining the redirect conditions. | - |
cURL Request
curl --request PUT \
--url https://api2.requestly.io/v1/rules/Redirect_wi3uJ \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-api-key: YOUR_API_KEY' \
--data '{
"objectType": "rule",
"ruleType": "Redirect",
"status": "Inactive",
"name": "Redirect Bing to Google",
"pairs": [
{
"source": {
"key": "Url",
"operator": "Equals",
"value": "https://www.bing.com/"
},
"destination": "https://www.google.com/",
"destinationType": "url"
}
]
}'
Example Response
{
"success": true,
"data": {
"id": "Redirect_wi3uJ",
"creationDate": 1736960959780,
"modificationDate": 1760142474884,
"createdBy": "user_id",
"lastModifiedBy": "user_id",
"name": "Redirect Bing to Google",
"description": "",
"ruleType": "Redirect",
"objectType": "rule",
"pairs": [
{
"source": {
"key": "Url",
"operator": "Equals",
"value": "https://www.bing.com/"
},
"destination": "https://www.google.com/",
"destinationType": "url",
"id": "2d9dv"
}
],
"status": "Inactive"
}
}
Request Structure
Body Parameters
Name | Type | Required | Default | Description |
---|---|---|---|---|
name |
| Yes | Name of the rule. | |
description |
| No | Description of the rule. | |
objectType |
| Yes |
| Type of the object. For this endpoint, it is always |
ruleType |
| Yes | Type of the rule. Possible values are: | |
status |
| No |
| Status of the rule, either |
pairs |
| Yes | List of rule pairs specific to the rule type. See details below. | |
groupId |
| No | The ID of the group the rule belongs to. If omitted, the rule is ungrouped. |
Rule Type Details
Each rule type has a unique structure for its pairs of objects. The schemas for each rule type are detailed below:
Common Source Schema
The source object is consistent across all rule types. It has the following structure:
Property | Type | Required | Description |
---|---|---|---|
key |
| Yes | The key for the source (e.g., |
operator |
| Yes | The operator for matching ( |
value |
| Yes | The value to match against. |
filters |
| No | Optional filters for more accurate targeting. |
Redirect Rule
-
ruleType:
Redirect
-
pairs schema:
Property | Type | Required | Description |
---|---|---|---|
source |
| Yes | The source object for matching (see common source schema). |
destinationType |
| Yes | Type of the destination ( |
destination |
| Yes | The destination URL value. |
Cancel Rule
-
ruleType:
Cancel
-
pairs schema:
Property | Type | Required | Description |
---|---|---|---|
source |
| Yes | The source object for matching. |
Replace Rule
-
ruleType:
Replace
-
pairs schema:
Property | Type | Required | Description |
---|---|---|---|
source |
| Yes | The source object for matching. |
from |
| Yes | The target string to replace. |
to |
| Yes | The replacement value. |
Headers Rule
-
ruleType:
Headers
-
pairs schema:
Property | Type | Required | Description |
---|---|---|---|
source |
| Yes | The source object for matching. |
modifications |
| Yes | List of header modifications (see below). |
Header Modification Object:
Property | Type | Required | Description |
---|---|---|---|
header |
| Yes | The name of the header to modify. |
type |
| Yes | Modification type ( |
value |
| No | The value to set for the header (required for |
User-Agent Rule
-
ruleType:
UserAgent
-
pairs schema:
Property | Type | Required | Description |
---|---|---|---|
source |
| Yes | The source object for matching. |
userAgent |
| Yes | The User-Agent string to set. |
Query Param Rule
-
ruleType:
QueryParam
-
pairs schema:
Property | Type | Required | Description |
---|---|---|---|
source |
| Yes | The source object for matching. |
modifications |
| Yes | Array of query parameter modifications (see below). |
Query Param Modification Object:
Property | Type | Required | Description |
---|---|---|---|
param |
| Yes | The name of the query parameter to modify. |
type |
| Yes | Modification type ( |
value |
| No | The value to set (required for |
Modify Request Rule
-
ruleType:
Request
-
pairs schema:
Property | Type | Required | Description |
---|---|---|---|
type |
| Yes | Type of request modification ( |
value |
| Yes | The request value or code. |
Modify Response Rule
-
ruleType:
Response
-
pairs schema:
Property | Type | Required | Description |
---|---|---|---|
type |
| Yes | Type of response modification ( |
value |
| Yes | The response value or status code. |
serveWithoutRequest |
| No | Whether to serve the response directly from Requestly. |
Delay Rule
-
ruleType:
Delay
-
pairs schema:
Property | Type | Required | Description |
---|---|---|---|
source |
| Yes | The source object for matching. |
delay |
| Yes | Delay value in milliseconds. |
Error Responses
Status Code | Description |
---|---|
400 | Rule pairs or payload are invalid. |
401 | Unauthorized action. |
404 | Rule or group not found. |
405 | Rule type update not allowed. |