Skip to main content

redirects

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

Overview

Nameredirects
TypeResource
Idvercel.bulk_redirects.redirects

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
case_sensitiveboolean (false, true) (wire: caseSensitive)
destinationstring
permanentboolean (false, true)
preserve_query_paramsboolean (false, true) (wire: preserveQueryParams)
queryboolean (false, true)
sensitiveboolean (false, true)
sourcestring
status_codenumber (wire: statusCode)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectproject_idversion_id, q, diff, page, per_page, sort_by, sort_order, team_id, slugGet the version history for a project's bulk redirects
updateupdateproject_id, redirectteam_id, slugEdits a single redirect identified by its source path. Stages a new change with the modified redirect and returns the alias for the new version in the response.
stagereplaceproject_id, team_idslugStages new redirects for a project and returns the new version.
deletedeleteproject_idteam_id, slugDeletes the provided redirects from the latest version of the projects' bulk redirects. Stages a new change with the new redirects and returns the alias for the new version in the response.
restoreexecprojectId, redirectsteamId, slugRestores the provided redirects in the staging version to the value in the production version. If no production version exists, removes the redirects from staging.

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
projectIdstring
project_idstring (wire: projectId)
diff
pageinteger
per_pageinteger
qstring
slugstringThe Team slug to perform the request on behalf of.
sort_bystring
sort_orderstring
teamIdstringThe Team identifier to perform the request on behalf of.
team_idstringThe Team identifier to perform the request on behalf of. (wire: teamId)
version_idstring (wire: versionId)

SELECT examples

Get the version history for a project's bulk redirects

SELECT
case_sensitive,
destination,
permanent,
preserve_query_params,
query,
sensitive,
source,
status_code
FROM vercel.bulk_redirects.redirects
WHERE project_id = '{{ project_id }}' -- required
AND version_id = '{{ version_id }}'
AND q = '{{ q }}'
AND diff = '{{ diff }}'
AND page = '{{ page }}'
AND per_page = '{{ per_page }}'
AND sort_by = '{{ sort_by }}'
AND sort_order = '{{ sort_order }}'
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

UPDATE examples

Edits a single redirect identified by its source path. Stages a new change with the modified redirect and returns the alias for the new version in the response.

UPDATE vercel.bulk_redirects.redirects
SET
name = '{{ name }}',
redirect = '{{ redirect }}',
restore = {{ restore }}
WHERE
project_id = '{{ project_id }}' --required
AND redirect = '{{ redirect }}' --required
AND team_id = '{{ team_id}}'
AND slug = '{{ slug}}'
RETURNING
alias,
version;

REPLACE examples

Stages new redirects for a project and returns the new version.

REPLACE vercel.bulk_redirects.redirects
SET
project_id = '{{ project_id }}',
team_id = '{{ team_id }}',
overwrite = {{ overwrite }},
name = '{{ name }}',
redirects = '{{ redirects }}'
WHERE
project_id = '{{ project_id }}' --required
AND team_id = '{{ team_id }}' --required
AND slug = '{{ slug}}'
RETURNING
alias,
version;

DELETE examples

Deletes the provided redirects from the latest version of the projects' bulk redirects. Stages a new change with the new redirects and returns the alias for the new version in the response.

DELETE FROM vercel.bulk_redirects.redirects
WHERE project_id = '{{ project_id }}' --required
AND team_id = '{{ team_id }}'
AND slug = '{{ slug }}'
;

Lifecycle Methods

EXEC variables use wire (API) names.

Restores the provided redirects in the staging version to the value in the production version. If no production version exists, removes the redirects from staging.

EXEC vercel.bulk_redirects.redirects.restore
@projectId='{{ projectId }}' --required,
@teamId='{{ teamId }}',
@slug='{{ slug }}'
@@json=
'{
"name": "{{ name }}",
"redirects": "{{ redirects }}"
}'
;