Skip to main content

domains

Creates, updates, deletes, gets or lists a domains resource.

Overview​

Namedomains
TypeResource
Idvercel.projects.domains

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestring
custom_environment_idstring (wire: customEnvironmentId)
project_idstring (wire: projectId)
apex_namestring (wire: apexName)
created_atnumber (wire: createdAt)
git_branchstring (wire: gitBranch)
redirectstring
redirect_status_codenumber (301, 302, 307, 308, ) (wire: redirectStatusCode)
updated_atnumber (wire: updatedAt)
verificationarrayA list of verification challenges, one of which must be completed to verify the domain for use on the project. After the challenge is complete POST /projects/:idOrName/domains/:domain/verify to verify the domain. Possible challenges: - If verification.type = TXT the verification.domain will be checked for a TXT record matching verification.value.
verifiedbooleantrue if the domain is verified for use with the project. If false it will not be used as an alias on this project until the challenge in verification is completed. (false, true)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectid_or_name, domainteam_id, slugGet project domain by project id/name and domain name.
listselectid_or_nameproduction, target, custom_environment_id, git_branch, redirects, redirect, verified, limit, since, until, order, team_id, slugRetrieve the domains associated with a given project by passing either the project id or name in the URL.
addinsertid_or_name, nameteam_id, slugAdd a domain to the project by passing its domain name and by specifying the project by either passing the project id or name in the URL. If the domain is not yet verified to be used on this project, the request will return verified = false, and the domain will need to be verified according to the verification challenge via POST /projects/:idOrName/domains/:domain/verify. If the domain already exists on the project, the request will fail with a 400 status code.
updateupdateid_or_name, domainteam_id, slugUpdate a project domain's configuration, including the name, git branch and redirect of the domain.
deletedeleteid_or_name, domainteam_id, slugRemove a domain from a project by passing the domain name and by specifying the project by either passing the project id or name in the URL.
moveexecid_or_name, domain, projectIdteamId, slugMove one project's domain to another project. Also allows the move of all redirects pointed to that domain in the same project.
verifyexecid_or_name, domainteamId, slugAttempts to verify a project domain with verified = false by checking the correctness of the project domain's verification challenge.

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
domainstringThe domain name you want to verify
id_or_namestringThe unique project identifier or the project name
custom_environment_idstringThe unique custom environment identifier within the project (wire: customEnvironmentId)
git_branchstringFilters domains based on specific branch. (wire: gitBranch)
limitnumberMaximum number of domains to list from a request (max 100).
orderDomains sort order by createdAt
productionFilters only production domains when set to true.
redirectstringFilters domains based on their redirect target.
redirectsExcludes redirect project domains when "false". Includes redirect project domains when "true" (default).
sincenumberGet domains created after this JavaScript timestamp.
slugstringThe Team slug to perform the request on behalf of.
targetstringFilters on the target of the domain. Can be either "production", "preview"
teamIdstringThe Team identifier to perform the request on behalf of.
team_idstringThe Team identifier to perform the request on behalf of. (wire: teamId)
untilnumberGet domains created before this JavaScript timestamp.
verifiedFilters domains based on their verification status.

SELECT examples​

Get project domain by project id/name and domain name.

SELECT
name,
custom_environment_id,
project_id,
apex_name,
created_at,
git_branch,
redirect,
redirect_status_code,
updated_at,
verification,
verified
FROM vercel.projects.domains
WHERE id_or_name = '{{ id_or_name }}' -- required
AND domain = '{{ domain }}' -- required
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

INSERT examples​

Add a domain to the project by passing its domain name and by specifying the project by either passing the project id or name in the URL. If the domain is not yet verified to be used on this project, the request will return verified = false, and the domain will need to be verified according to the verification challenge via POST /projects/:idOrName/domains/:domain/verify. If the domain already exists on the project, the request will fail with a 400 status code.

INSERT INTO vercel.projects.domains (
name,
git_branch,
custom_environment_id,
redirect,
redirect_status_code,
id_or_name,
team_id,
slug
)
SELECT
'{{ name }}' /* required */,
'{{ git_branch }}',
'{{ custom_environment_id }}',
'{{ redirect }}',
{{ redirect_status_code }},
'{{ id_or_name }}',
'{{ team_id }}',
'{{ slug }}'
RETURNING
name,
custom_environment_id,
project_id,
apex_name,
created_at,
git_branch,
redirect,
redirect_status_code,
updated_at,
verification,
verified
;

UPDATE examples​

Update a project domain's configuration, including the name, git branch and redirect of the domain.

UPDATE vercel.projects.domains
SET
git_branch = '{{ git_branch }}',
redirect = '{{ redirect }}',
redirect_status_code = {{ redirect_status_code }}
WHERE
id_or_name = '{{ id_or_name }}' --required
AND domain = '{{ domain }}' --required
AND team_id = '{{ team_id}}'
AND slug = '{{ slug}}'
RETURNING
name,
custom_environment_id,
project_id,
apex_name,
created_at,
git_branch,
redirect,
redirect_status_code,
updated_at,
verification,
verified;

DELETE examples​

Remove a domain from a project by passing the domain name and by specifying the project by either passing the project id or name in the URL.

DELETE FROM vercel.projects.domains
WHERE id_or_name = '{{ id_or_name }}' --required
AND domain = '{{ domain }}' --required
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

Lifecycle Methods​

EXEC variables use wire (API) names.

Move one project's domain to another project. Also allows the move of all redirects pointed to that domain in the same project.

EXEC vercel.projects.domains.move
@id_or_name='{{ id_or_name }}' --required,
@domain='{{ domain }}' --required,
@teamId='{{ teamId }}',
@slug='{{ slug }}'
@@json=
'{
"projectId": "{{ projectId }}",
"gitBranch": "{{ gitBranch }}",
"redirect": "{{ redirect }}",
"redirectStatusCode": {{ redirectStatusCode }}
}'
;