The REST Admin API is a legacy API as of October 1, 2024. All apps and integrations should be built with the GraphQL Admin API. For details and migration steps, visit our migration guide.

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?

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"
}

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".

api_version
string
required

Was this section helpful?
Request body
redirect
Redirect resource
Was this section helpful?
post
/admin/api/2024-07/redirects.json
Copy
curl -d '{"redirect":{"path":"/ipod","target":"/pages/itunes"}}' \
-X POST "https://your-development-store.myshopify.com/admin/api/2024-07/redirects.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"
{}Response
JSON
HTTP/1.1 201 Created
{
  "redirect": {
    "id": 984542202,
    "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?
Query parameters
sinceid=668809255
Restrict results to after the specified ID.
Was this section helpful?
get
/admin/api/2024-07/redirects.json?sinceid=668809255
Copy
curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-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?
Path parameters
redirectid=668809255
string
required
Was this section helpful?
get
/admin/api/2024-07/redirects/668809255.json
Copy
curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-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?
Was this section helpful?
get
/admin/api/2024-07/redirects/count.json
Copy
curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-07/redirects/count.json" \
-H "X-Shopify-Access-Token: {access_token}"
{}Response
JSON
HTTP/1.1 200 OK
{
  "count": 3
}

Updates an existing [redirect](https://shopify.dev/api/admin-rest/latest/resources/redirect)

api_version
string
required

redirect_id
string
required

Was this section helpful?
Path parameters
redirectid=950115854
string
required
Request body
redirect
Redirect resource
Was this section helpful?
put
/admin/api/2024-07/redirects/950115854.json
Copy
curl -d '{"redirect":{"id":950115854,"path":"/powermac","target":"/pages/macpro"}}' \
-X PUT "https://your-development-store.myshopify.com/admin/api/2024-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?
Path parameters
redirectid=668809255
string
required
Was this section helpful?
del
/admin/api/2024-07/redirects/668809255.json
Copy
curl -X DELETE "https://your-development-store.myshopify.com/admin/api/2024-07/redirects/668809255.json" \
-H "X-Shopify-Access-Token: {access_token}"
{}Response
JSON
HTTP/1.1 200 OK
{}