Skip to content
Docs

Assign an Alias

POSThttps://api.vercel.com/v2/deployments/{id}/aliases
Creates a new alias for the deployment resolved from the given deployment or alias ID or URL. The authenticated user or team must own this deployment. If the desired alias is already assigned to another deployment, then it will be removed from the old deployment and assigned to the new one.
https://api.vercel.com/v2/deployments/{id}/aliases
const response = await fetch('https://api.vercel.com/v2/deployments/id/aliases?teamId=string&slug=string', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"alias": "my-alias.vercel.app",
"redirect": "null"
}),
});
const data = await response.json();
console.log(data);
Response
{
"alias": "my-alias.vercel.app",
"created": "2017-04-26T23:00:34.232Z",
"oldDeploymentId": "dpl_FjvFJncQHQcZMznrUm9EoB8sFuPa",
"uid": "2WjyKQmM8ZnGcJsPWMrHRHrE"
}
AuthorizationbearerToken

Default authentication mechanism

idanyRequired
The deployment or alias ID or URL to assign from
teamIdstringOptional
The Team identifier to perform the request on behalf of.
slugstringOptional
The Team slug to perform the request on behalf of.
application/json
aliasstringOptional
The alias we want to assign to the deployment defined in the URL
redirectstringOptional
The redirect property will take precedence over the deployment id from the URL and consists of a hostname (like test.com) to which the alias should redirect using status code 307
200The alias was successfully assigned to the deployment
aliasstringRequired
The assigned alias name
createdstringRequired
The date when the alias was created
oldDeploymentIdstringOptional
The unique identifier of the previously aliased deployment, only received when the alias was used before
uidstringRequired
The unique identifier of the alias
400One of the provided values in the request body is invalid. One of the provided values in the request query is invalid. The cert for the provided alias is not ready The deployment is not READY and can not be aliased The supplied alias is invalid
401The request is not authorized.
402The account is missing a payment so payment method must be updated
403You do not have permission to access this resource. If no .vercel.app alias exists then we fail (nothing to mirror)
404The domain used for the alias was not found The deployment was not found
409The provided alias is already assigned to the given deployment The domain is not allowed to be used
410Error