Skip to content
Docs

Stage routing rules

PUThttps://api.vercel.com/v1/projects/{projectId}/routes
Stage routing rules for a project. Set overwrite to true to replace all existing rules, or omit it to merge with existing rules by ID. Returns the new staged version.
https://api.vercel.com/v1/projects/{projectId}/routes
const response = await fetch('https://api.vercel.com/v1/projects/projectId/routes?teamId=string&slug=string', {
method: 'PUT',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"overwrite": "true",
"routes": [
{
"id": "icfg_1234567890",
"name": "Example Name",
"description": "string",
"enabled": "true",
"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"
}
}
]
}),
});
const data = await response.json();
console.log(data);
Response
{
"version": {
"id": "icfg_1234567890",
"s3Key": "string",
"lastModified": "123",
"createdBy": "string",
"isStaging": "false",
"isLive": "false",
"ruleCount": "123",
"alias": "string"
}
}
AuthorizationbearerToken

Default authentication mechanism

projectIdstringRequired
teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
overwritebooleanOptional
routesarrayOptional
200Success
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.
409Error
410Error
500Error