Skip to main content

The REST Admin API is a legacy API as of October 1, 2024. Starting April 1, 2025, all new public apps must be built exclusively with the GraphQL Admin API. For details and migration steps, visit our migration guide.

Redirect

Requires content access scope.

A redirect causes a visitor on a specific path on the shop's site to be automatically sent to a different location, called the target. The target can be a new path on the shop's site or a full URL. The new URL can even be on a completely different domain. Redirect paths are unique, so a shop can't have more than one redirect with the same path.

Was this section helpful?

Anchor to

The Redirect resource

Anchor to

Properties


id
read-only
->
id

The ID for the redirect.


path

The old path to be redirected. When the user visits this path, they will be redirected to the target. (maximum: 1024 characters)


target

The target location where the user will be redirected. When the user visits the old path specified by the path property, they will be redirected to this location. This property can be set to any path on the shop's site, or to an external URL. (maximum: 255 characters)


Was this section helpful?
{}

The Redirect resource

{
"id": 304339089,
"path": "/products.php",
"target": "/products"
}

Anchor to POST request, Creates a redirect
post
Creates a redirect

Creates a redirect. When you provide a full URL as the value of the path property, it will be saved as an absolute path without the domain. For example, "path": "http://www.example.com/springwear" will be saved as "path": "springwear".

Anchor to Parameters of Creates a redirectParameters


api_version
string
required

Was this section helpful?

Anchor to post-redirects-examplesExamples

Create a redirect

Request body
redirect
Redirect resource
Show redirect properties
redirect.path:"/ipod"

The old path to be redirected. When the user visits this path, they will be redirected to the target. (maximum: 1024 characters)

redirect.target:"/pages/itunes"

The target location where the user will be redirected. When the user visits the old path specified by the path property, they will be redirected to this location. This property can be set to any path on the shop's site, or to an external URL. (maximum: 255 characters)

Create a redirect using a full URL for the path, which will be saved as an absolute path without a domain

Request body
redirect
Redirect resource
Show redirect properties
redirect.path:"http://www.apple.com/forums"

The old path to be redirected. When the user visits this path, they will be redirected to the target. (maximum: 1024 characters)

redirect.target:"http://forums.apple.com"

The target location where the user will be redirected. When the user visits the old path specified by the path property, they will be redirected to this location. This property can be set to any path on the shop's site, or to an external URL. (maximum: 255 characters)

Creating a redirect without a path or target fails and returns an error

Was this section helpful?
post

/admin/api/2025-07/redirects.json

curl -d '{"redirect":{"path":"/ipod","target":"/pages/itunes"}}' \
-X POST "https://your-development-store.myshopify.com/admin/api/2025-07/redirects.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"

{}

Response

JSON
HTTP/1.1 201 Created
{
"redirect": {
"id": 984542199,
"path": "/ipod",
"target": "/pages/itunes"
}
}

Retrieves a list of URL redirects. Note: This endpoint implements pagination by using links that are provided in the response header. To learn more, refer to Make paginated requests to the REST Admin API.


api_version
string
required

fields

Show only certain fields, specified by a comma-separated list of field names.


limit
≤ 250
default 50

The maximum number of results to show.


path

Show redirects with a given path.


since_id

Restrict results to after the specified ID.


target

Show redirects with a given target.


Was this section helpful?

Retrieve a list of URL redirects after a specified ID

Query parameters
since_id=668809255

Restrict results to after the specified ID.

Retrieve a list of all redirects

Was this section helpful?
get

/admin/api/2025-07/redirects.json?since_id=668809255

curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-07/redirects.json?since_id=668809255" \
-H "X-Shopify-Access-Token: {access_token}"

{}

Response

JSON
HTTP/1.1 200 OK
{
"redirects": [
{
"id": 950115854,
"path": "/ibook",
"target": "/products/macbook"
}
]
}

Retrieves a single redirect


api_version
string
required

redirect_id
string
required

fields

Show only certain fields, specified by a comma-separated list of field names.


Was this section helpful?

Retrieve a single redirect by its ID

Path parameters
redirect_id=668809255
string
required
Was this section helpful?
get

/admin/api/2025-07/redirects/668809255.json

curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-07/redirects/668809255.json" \
-H "X-Shopify-Access-Token: {access_token}"

{}

Response

JSON
HTTP/1.1 200 OK
{
"redirect": {
"id": 668809255,
"path": "/leopard",
"target": "/pages/macosx"
}
}

Retrieves a count of URL redirects


api_version
string
required

path

Count redirects with given path.


target

Count redirects with given target.


Was this section helpful?

Count all redirects

Was this section helpful?
get

/admin/api/2025-07/redirects/count.json

curl -X GET "https://your-development-store.myshopify.com/admin/api/2025-07/redirects/count.json" \
-H "X-Shopify-Access-Token: {access_token}"

{}

Response

JSON
HTTP/1.1 200 OK
{
"count": 3
}

Updates an existing redirect


api_version
string
required

redirect_id
string
required

Was this section helpful?

Update both the source (path) and target URIs of a redirect

Path parameters
redirect_id=950115854
string
required
Request body
redirect
Redirect resource
Show redirect properties
redirect.id:950115854
read-only

The ID for the redirect.

redirect.path:"/powermac"

The old path to be redirected. When the user visits this path, they will be redirected to the target. (maximum: 1024 characters)

redirect.target:"/pages/macpro"

The target location where the user will be redirected. When the user visits the old path specified by the path property, they will be redirected to this location. This property can be set to any path on the shop's site, or to an external URL. (maximum: 255 characters)

Update the source (path) URI of a redirect

Path parameters
redirect_id=668809255
string
required
Request body
redirect
Redirect resource
Show redirect properties
redirect.id:668809255
read-only

The ID for the redirect.

redirect.path:"/tiger"

The old path to be redirected. When the user visits this path, they will be redirected to the target. (maximum: 1024 characters)

Update the target URI of a redirect

Path parameters
redirect_id=668809255
string
required
Request body
redirect
Redirect resource
Show redirect properties
redirect.id:668809255
read-only

The ID for the redirect.

redirect.target:"/pages/macpro"

The target location where the user will be redirected. When the user visits the old path specified by the path property, they will be redirected to this location. This property can be set to any path on the shop's site, or to an external URL. (maximum: 255 characters)

Was this section helpful?
put

/admin/api/2025-07/redirects/950115854.json

curl -d '{"redirect":{"id":950115854,"path":"/powermac","target":"/pages/macpro"}}' \
-X PUT "https://your-development-store.myshopify.com/admin/api/2025-07/redirects/950115854.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"

{}

Response

JSON
HTTP/1.1 200 OK
{
"redirect": {
"path": "/powermac",
"target": "/pages/macpro",
"id": 950115854
}
}

Deletes a redirect


api_version
string
required

redirect_id
string
required

Was this section helpful?

Delete an existing redirect

Path parameters
redirect_id=668809255
string
required
Was this section helpful?
del

/admin/api/2025-07/redirects/668809255.json

curl -X DELETE "https://your-development-store.myshopify.com/admin/api/2025-07/redirects/668809255.json" \
-H "X-Shopify-Access-Token: {access_token}"

{}

Response

JSON
HTTP/1.1 200 OK
{}