Skip to content
Docs

Edit a routing rule

PATCHhttps://api.vercel.com/v1/projects/{projectId}/routes/{routeId}
Replace a routing rule identified by its ID, or restore it from the current production version. Stages a new version with the modified route.
https://api.vercel.com/v1/projects/{projectId}/routes/{routeId}
const response = await fetch('https://api.vercel.com/v1/projects/projectId/routes/routeId?teamId=string&slug=string', {
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"route": {
"name": "Example Name",
"description": "string",
"enabled": "true",
"srcSyntax": "equals",
"route": {
"src": "string",
"dest": "string",
"headers": "value",
"caseSensitive": "true",
"status": "123",
"has": [
{
"type": "host",
"key": "string",
"value": "string"
}
],
"missing": [
{
"type": "host",
"key": "string",
"value": "string"
}
],
"transforms": [
{
"type": "request.headers",
"op": "append",
"target": "value",
"args": "value",
"env": []
}
],
"respectOriginCacheControl": "true"
}
},
"restore": "true"
}),
});
const data = await response.json();
console.log(data);
Response
{
"route": {
"description": "string",
"enabled": "false",
"id": "icfg_1234567890",
"name": "Example Name",
"rawDest": "string",
"rawSrc": "string",
"route": {
"caseSensitive": "false",
"check": "false",
"continue": "false",
"dest": "string",
"destination": "string",
"env": [],
"has": [
{
"type": "host",
"value": "string"
}
],
"headers": "value",
"important": "false",
"locale": {
"cookie": "string",
"redirect": "value"
},
"methods": [],
"middleware": "123",
"middlewarePath": "example_id",
"middlewareRawSrc": [],
"missing": [
{
"type": "host",
"value": "string"
}
],
"mitigate": {
"action": "challenge"
},
"override": "false",
"respectOriginCacheControl": "false",
"source": "string",
"src": "string",
"status": "123",
"statusCode": "123",
"transforms": [
{
"args": "string",
"env": [],
"op": "append",
"target": {
"key": "string"
},
"type": "request.headers"
}
]
},
"routeType": "redirect",
"srcSyntax": "equals",
"staged": "false"
},
"version": {
"alias": "string",
"createdBy": "string",
"id": "icfg_1234567890",
"isLive": "false",
"isStaging": "false",
"lastModified": "123",
"ruleCount": "123",
"s3Key": "string"
}
}
AuthorizationbearerToken

Default authentication mechanism

projectIdstringRequired
routeIdstringRequired
teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
routeobjectOptional
The full route object to replace the existing route with
restorebooleanOptional
If true, restores the staged route to the value in the production version.
200Success
routeobjectOptional
versionobjectRequired
A version of routing rules stored in S3.
400One of the provided values in the request body is invalid. One of the provided values in the request query is invalid.
401The request is not authorized.
403You do not have permission to access this resource.
404Error
409Error
410Error
500Error