Add a new Redirect

POST /api/v2/redirects.json

Add a new redirect rule.

Scope

Requires the content OAuth scope.

Request body

Your request body must contain an object including:

data required
Containing a Redirect object.


Example: Adding by resource & ID

You may add a new redirect from a path to a dynamic resource (such as page, product or category) using the resource's ID.
Let's say we have a web page with an ID of 486435 and we want to redirect from /redirect-from-path to its current URL.

{
    "data": {
        "resource": "page",
        "resourceId": 486435,
        "path": "/redirect-from-path"
    }
}


Example: Adding by target URL

Supplying only the path and target allows Evance to auto-detect the resource type. Allowing you to add redirects for both dynamic and static resources. The target URL may be:

  • The current URL of a dynamic resource (page, product or category)
  • The path to a file in the Media Library
  • The absolute URL to an external website

{
    "data": {
        "path": "/redirect-external",
        "target": "https://www.external-website.com",
    }
}


Success responses

If the Redirect rule was created successfully you should receive a response with a 201 status code:

success
A boolean where a value of true means the Redirect was created successfully.
status
The HTTP status code e.g. 201 means the Redirect was created successfully.
data
Contains the Redirect object you created including its new id.


Error responses

If the Redirect could not be created you will encounter a response with a 422 status code:

success
A boolean where a value of false means the Redirect could not be created.
status
A response code of 422 means the Redirect could not be created and you should check the errors property for further information.
context
The context property indicates where the error occurred. For a 422 error this will typically contain a value of data, indicating that there was an error with the data object supplied.
errors

Contains an array of error objects, each will have the following properties:

  • name - The property name that encountered an error.
  • message - A human readable error message.
  • ref - An error reference string (e.g. error.not-unique if the alias supplied is already in use).