Skip to content
Docs

Add a routing rule

POSThttps://api.vercel.com/v1/projects/{projectId}/routes
Add a single routing rule to a project at a specified position. Defaults to the end of the list if no position is provided. The route is enabled by default. Stages a new version with the added route.
Request
import { Vercel } from "@vercel/sdk";
const vercel = new Vercel({
bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await vercel.projectRoutes.addRoute({
projectId: "<id>",
teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
slug: "my-team-url-slug",
});
console.log(result);
}
run();
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
teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
routeobjectRequired
positionobjectOptional
Controls where the route is inserted. Defaults to "end" if omitted.
200Success
routeobjectRequired
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