Search Documentation

Search for a documentation page...

Redirects API

REST API endpoints for managing store URL redirects, one at a time or up to 5,000 per request.

Redirects send visitors from an old storefront address to a new one: after a product slug change, or when moving a shop from another platform. Each redirect has a source (the old path), a target (a path or an absolute URL), a match type and an HTTP status. Every change is synced to the storefront.

Reading redirects needs the storefront:read scope; creating, updating and deleting them needs content:write.

The Redirect object

FieldTypeDescription
idstringRedirect UUID
storeIdstringStore UUID
sourcestringPath to redirect from. Lowercased, without query string and trailing slash for exact and prefix; kept as sent for regex
targetstringA path, or an absolute URL for another domain. Case is kept
matchType"exact" | "prefix" | "regex"How source is matched
status"301" | "302"HTTP status of the redirect
forwardQuerybooleanWhether the incoming query string is copied onto the target
enabledbooleanDisabled redirects are kept but not applied
positionnumberEvaluation order when several prefix or regex rules match; lower runs first
titlestring | nullOptional note describing the redirect
hitsnumberHow many times the redirect was used
lastAccessedAtstring | nullWhen it was last used
createdAtstringISO 8601 timestamp
updatedAtstringISO 8601 timestamp

Write responses can also carry a warnings array of strings when a rule could not be made live on the storefront. It is left out when there is nothing to report.


List Redirects

GET /api/v1/redirects

Returns the store's redirects ordered by position, then source. Without limit or offset, every redirect is returned.

Query Parameters

ParameterTypeDefaultDescription
limitnumber1000Redirects per page (1-1000). Only applied when limit or offset is sent
offsetnumber0Redirects to skip

A value that is not a non-negative integer is ignored.

curl \
-H "Authorization: Bearer your_api_key" \
"https://your-store.yns.store/api/v1/redirects?limit=100&offset=0"

Response

{
"data": [
{
"id": "0191abc0-1234-7def-8000-000000000001",
"storeId": "0191abc0-0000-7def-8000-000000000001",
"source": "/old-product",
"target": "/product/new-product",
"matchType": "exact",
"status": "301",
"forwardQuery": true,
"enabled": true,
"position": 0,
"title": null,
"hits": 12,
"lastAccessedAt": "2026-11-28T10:00:00.000Z",
"createdAt": "2026-11-01T09:00:00.000Z",
"updatedAt": "2026-11-01T09:00:00.000Z"
}
]
}

Get Redirect

GET /api/v1/redirects/:id

Returns one redirect by UUID, as a bare Redirect object. Returns 404 when the store has no redirect with that id.


Create Redirect

POST /api/v1/redirects

Creates one redirect. To create many at once, send an array instead: see Create Many Redirects.

Request Body

FieldTypeRequiredDescription
sourcestringYesPath to redirect from, e.g. /old-url. A regular expression when matchType is regex
targetstringYesA path, or an absolute URL for another domain. May carry its own query string, and $1-$9 backreferences when matchType is regex
matchType"exact" | "prefix" | "regex"Noexact (default): the path must match exactly. prefix: the path or anything beneath it matches, and the remaining segments are appended to the target. regex: source is a regular expression
status"301" | "302"No301 (default) for a permanent move, 302 when the old URL will come back
forwardQuerybooleanNoCopy the incoming query string onto the target; params set on the target win (default true)
enabledbooleanNoDefault true
positionnumberNoInteger, at least 0 (default 0)
titlestring | nullNoOptional note, up to 200 characters

Unknown fields are rejected.

curl -X POST \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{"source": "/old-product", "target": "/product/new-product"}' \
https://your-store.yns.store/api/v1/redirects

Response (201)

The created Redirect object, plus warnings when there are any.

Errors

StatusWhen
400Invalid body; source and target are the same URL; a regex source that is empty, longer than 500 characters, has a repeat inside a repeat (like (a+)+) or does not compile
409The store already has a redirect for that source. Update it with PATCH, or send a different source

Create Many Redirects

POST /api/v1/redirects

Send an array of 1 to 5,000 redirects, each with the fields of Create Redirect, to write them in one request with a single storefront sync.

  • Every row is checked first. If any row is invalid, or the same source appears twice in the batch, nothing is written.
  • A source the store already has is updated instead of refused, so the same batch can be sent again.
curl -X POST \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '[
{"source": "/126-Wohnwand.html", "target": "/product/wohnwand"},
{"source": "/148-Holzbett.html", "target": "/product/holzbett", "status": "302"}
]' \
https://your-store.yns.store/api/v1/redirects

Response (200)

count is the number of redirects created or updated.

{
"count": 2
}

Errors

An empty array or one over 5,000 rows returns 400. Invalid rows return 400 naming each row by its 1-based position (up to 20), for example row 2: source sent twice, with this hint:

{
"error": "… row 2: source sent twice",
"hint": "Fix these rows and resend the batch; nothing was written."
}

Sources are compared after normalising, so /Old and /old/ count as the same source.


Update Redirect

PATCH /api/v1/redirects/:id

Send any subset of the Create Redirect fields; omitted fields keep their current value.

curl -X PATCH \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{"status": "302", "enabled": false}' \
https://your-store.yns.store/api/v1/redirects/0191abc0-1234-7def-8000-000000000001

Response (200)

The updated Redirect object, plus warnings when there are any. Returns 404 when the redirect does not exist, 400 for an invalid rule and 409 when another redirect already owns the new source.


Delete Redirect

DELETE /api/v1/redirects/:id

Deletes one redirect. Returns 204 with no body, or 404 when the store has no redirect with that id.

curl -X DELETE \
-H "Authorization: Bearer your_api_key" \
https://your-store.yns.store/api/v1/redirects/0191abc0-1234-7def-8000-000000000001

Delete Many Redirects

DELETE /api/v1/redirects

Send a JSON array of 1 to 5,000 redirect UUIDs to delete them in one request with a single storefront sync. An id the store does not have is skipped.

curl -X DELETE \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '["0191abc0-1234-7def-8000-000000000001", "0191abc0-1234-7def-8000-000000000002"]' \
https://your-store.yns.store/api/v1/redirects

Response (200)

count is the number of redirects actually deleted.

{
"count": 2
}

Anything other than an array of 1 to 5,000 UUIDs (an empty array, an id that is not a UUID, or an object such as {"ids": [...]}) returns 400.