Skip to main content

Redirect

Version: 1.0

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

Authenticated access scopes: com.read_contents, com.write_contents

What you can do with Redirect?

The haravan API lets you do the following with the Redirect resource. More detailed versions of these general actions may be available:

Redirect Properties


id : string

"id": 304339089

The unique numeric identifier for the redirect.

path : string

"path": "/products.php"

The "before" path to be redirected. When the user this path, s/he will be redirected to the path specified by target.

target : string

"target": "/products"

The "after" path or URL to be redirected to. When the user visits the path specified by path, s/he will be redirected to this path or URL. This property can be set to any path on the shop's site, or any URL, even one on a completely different domain.

Endpoints



Receive a list of all Redirects

GET
https://apis.haravan.com/web/redirects.json

Get a list of all URL redirects for your shop.

Parameters


limit default: 50 maximum: 250

Amount of results


page default: 1

Page to show


since_id

Restrict results to after the specified ID


path

Show Redirects with given target


target

Show Redirects with given target


fields

comma-separated list of fields to include in the response


A redirect's "path" attribute is the path which activates this redirect when visited, and a shop cannot have more than one redirect with the same path. The "target" attribute is the URL which the visitor is redirected to when they try to access the associated path. The target could either be a path or a full URL, possibly even for a different domain.

  • GET https://apis.haravan.com/web/redirects.json
Details
HTTP/1.1 200 OK
{
"redirects": [
{
"id": 304339089,
"path": "\/products.php",
"target": "\/products"
},
{
"id": 668809255,
"path": "\/leopard",
"target": "\/pages\/macosx"
},
{
"id": 950115854,
"path": "\/ibook",
"target": "\/products\/macbook"
}
]
}

Get a list of all URL redirects for your shop after a specified ID

  • GET https://apis.haravan.com/web/redirects.json?since_id=668809255
Details
HTTP/1.1 200 OK
{
"redirects": [
{
"id": 950115854,
"path": "\/ibook",
"target": "\/products\/macbook"
}
]
}


Receive a count of all Redirects

GET
https://apis.haravan.com/web/redirects/count.json

Get a count of all URL redirects for your shop.

Parameters


path

Count Redirects with given path


target

Count Redirects with given target


A redirect’s “path” attribute is the path which activates this redirect when visited, and a shop cannot have more than one redirect with the same path. The “target” attribute is the URL which the visitor is redirected to when they try to access the associated path. The target could either be a path or a full URL, possibly even for a different domain.

  • GET https://apis.haravan.com/web/redirects/count.json
Details
HTTP/1.1 200 OK
{
"count": 3
}


Receive a single Redirect

GET
https://apis.haravan.com/web/redirects/{redirect_id}.json

Get a single redirect.

Parameters


fields

comma-separated list of fields to include in the response


Get a single redirect by its ID.

  • GET https://apis.haravan.com/web/redirects/668809255.json
Details
HTTP/1.1 200 OK
{
"redirect": {
"id": 668809255,
"path": "\/leopard",
"target": "\/pages\/macosx"
}
}


Create a new Redirect

POST
https://apis.haravan.com/web/redirects.json

Create a new redirect.

We expect users might try going to /ipod in order to find about one of our popular products, but we want to redirect them to /itunes because that's where we have the information they're looking for.

  • POST https://apis.haravan.com/web/redirects.json
{
"redirect": {
"path": "\/ipod",
"target": "\/pages\/itunes"
}
}
Details
HTTP/1.1 201 Created
{
"redirect": {
"id": 979034144,
"path": "\/ipod",
"target": "\/pages\/itunes"
}
}

We have a separate forums site that is on a different subdomain. The "path" is always converted to an absolute path without a domain, but the "target" can be a full URL.

  • POST https://apis.haravan.com/web/redirects.json
{
"redirect": {
"path": "http:\/\/www.apple.com\/forums",
"target": "http:\/\/forums.apple.com"
}
}
Details
HTTP/1.1 201 Created
{
"redirect": {
"id": 979034145,
"path": "\/forums",
"target": "http:\/\/forums.apple.com"
}
}

Trying to create a redirect without a path and target will return an error

  • POST https://apis.haravan.com/web/redirects.json
{
"redirect": {
"body": "foobar"
}
}
Details
HTTP/1.1 422 Unprocessable Entity
{
"errors": {
"path": [
"can't be blank"
],
"target": [
"can't be blank",
"URI is invalid"
]
}
}


Modify an existing Redirect

PUT
https://apis.haravan.com/web/redirects/{redirect_id}.json

Update a redirect's path and/or target URIs.

Change a redirect so that it activates for a different request path:

  • PUT https://apis.haravan.com/web/redirects/668809255.json
{
"redirect": {
"id": 668809255,
"path": "\/tiger"
}
}
Details
HTTP/1.1 200 OK
{
"redirect": {
"id": 668809255,
"path": "\/tiger",
"target": "\/pages\/macosx"
}
}

Change both the path and target URIs for an existing redirect

  • PUT https://apis.haravan.com/web/redirects/950115854.json
{
"redirect": {
"id": 950115854,
"path": "\/powermac",
"target": "\/pages\/macpro"
}
}
Details
HTTP/1.1 200 OK
{
"redirect": {
"id": 950115854,
"path": "\/powermac",
"target": "\/pages\/macpro"
}
}


Remove a Redirect from the database

DELETE
https://apis.haravan.com/web/redirects/{redirect_id}.json

Delete a redirect

Remove an existing redirect from a shop

  • DELETE https://apis.haravan.com/web/redirects/668809255.json
Details
HTTP/1.1 200 OK
{}