# URL Redirects

Manage dead storefront paths without shadowing live routes.

A URL redirect is considered only after the requested storefront route or resource returns not found, so it cannot replace a live product, page, policy, collection, or other route. Merchant-managed rows use `manual` for one path or `prefix` for a `/*` path family. `auto_slug` and `system_prefix` rows are generated by catalog and permalink changes; reads expose them for diagnosis, but write endpoints do not change or delete them.

Store logical paths whenever one redirect should apply across public addresses. Shared domains use `/{locale}-{country}` for non-primary countries; country-pinned domains use only `/{locale}` for secondary languages. Resolution checks the addressed path first and then the logical path with that recognized address prefix removed. External targets must use HTTPS.

## Endpoints

## URL Redirect limits

`GET /api/2025-01/redirects/limits`

Returns live list, search, bulk-delete, merchant redirect, and prefix-rule limits. Automatic redirects are reported separately and do not consume the merchant redirect limit. `kind_options` lists every redirect kind for the list filter and `create_kind_options` the kinds you can create, each with a `label` in English.

Scope: `read_redirects`

```curl
curl 'https://api-store.tringify.com/api/2025-01/redirects/limits' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN"
```

Response:

```json
{"success":true,"data":{"max_per_store":10000,"max_prefix_per_store":50,"path_max_length":1024,"target_max_length":1024,"search_max_length":200,"list_default_limit":50,"list_max_limit":200,"bulk_delete_max":100,"usage":{"merchant_count":24,"prefix_count":2,"auto_count":31},"kind_options":[{"value":"manual","label":"Exact"},{"value":"prefix","label":"Prefix rule"},{"value":"system_prefix","label":"Permalink rename"},{"value":"auto_slug","label":"Slug change"}],"create_kind_options":[{"value":"manual","label":"Exact — one URL to one target"},{"value":"prefix","label":"Prefix rule — everything under a path"}]}}
```

## List URL redirects

`GET /api/2025-01/redirects`

Search paths and targets or filter by kind. `manual` and `prefix` rows are merchant-managed. `auto_slug` and `system_prefix` rows explain platform-generated routing history and are read-only. Each row carries `kind_display`, its kind named in English. Usage fields come from storefront analytics: `hit_count` is the approximate number of times the redirect was served over the last 90 days, including responses served from the edge cache; counts are aggregated, may be sampled at high volume, and include new visits within a few minutes. `last_used_at` is the most recent counted use within the last 90 days and is omitted when there was none. Usage recorded before analytics-based counting is not carried over. When the counts can't be read, the redirect is still returned, with `usage_available` false, `hit_count` null and no `last_used_at`; otherwise `usage_available` is true.

Scope: `read_redirects`

```curl
curl 'https://api-store.tringify.com/api/2025-01/redirects?kind=manual&limit=50&page=1&search=old-page' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN"
```

Response:

```json
{"success":true,"data":{"redirects":[{"id":"9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37","kind":"manual","kind_display":"Exact","path":"/old-page","target":"/new-page","redirect_type":301,"hit_count":4,"last_used_at":"2026-08-10T09:15:00-04:00","usage_available":true,"created_at":"2026-08-03T12:00:00-04:00","updated_at":"2026-08-03T12:00:00-04:00"}],"total":1,"page":1,"limit":50}}
```

## Get a URL redirect

`GET /api/2025-01/redirects/{redirectId}`

Returns the redirect only when it belongs to the token's store. Usage fields come from storefront analytics: `hit_count` is the approximate number of times the redirect was served over the last 90 days, including responses served from the edge cache; counts are aggregated, may be sampled at high volume, and include new visits within a few minutes. `last_used_at` is the most recent counted use within the last 90 days and is omitted when there was none. Usage recorded before analytics-based counting is not carried over. When the counts can't be read, the redirect is still returned, with `usage_available` false, `hit_count` null and no `last_used_at`; otherwise `usage_available` is true.

Scope: `read_redirects`

```curl
curl 'https://api-store.tringify.com/api/2025-01/redirects/9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN"
```

Response:

```json
{"success":true,"data":{"id":"9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37","kind":"manual","kind_display":"Exact","path":"/old-page","target":"/new-page","redirect_type":301,"hit_count":4,"last_used_at":"2026-08-10T09:15:00-04:00","usage_available":true,"created_at":"2026-08-03T12:00:00-04:00","updated_at":"2026-08-03T12:00:00-04:00"}}
```

## Create a URL redirect

`POST /api/2025-01/redirects`

Redirects are evaluated only after a storefront route returns not found, so they cannot shadow live content. Paths use the logical storefront path. On shared domains, regional addresses use `/{locale}-{country}`; country-pinned domains use `/{locale}` for non-default languages. The runtime checks both the addressed path and its logical path. External targets must use HTTPS without URL credentials. Internal targets start with a single slash; network-path URLs and backslashes are rejected. A redirect keeps the target you give it. When that target is itself a redirected dead path, the shopper is sent on through each redirect in turn, so changing a later redirect takes effect for every earlier one, and a step that becomes a live page ends the chain there. Cycles are rejected. Prefix rules may use a fixed target or a trailing /* target that preserves the unmatched suffix. Exact addressed and logical matches are checked before prefixes; the longest matching prefix wins and includes its base path. Paths are lowercased, repeated slashes collapsed, trailing slash removed, and query/fragment ignored. Source limits count UTF-8 bytes. Incoming query parameters survive only when the target does not specify a query; they precede any target fragment. Prefix and mixed exact/prefix loops are checked on writes, including CSV imports. The separate prefix usage count includes system prefixes. Source paths that the storefront edge answers as automated vulnerability scans are rejected with `REDIRECT_PATH_SCAN_ANSWERED`, including in CSV imports, because such a redirect could never be reached: any path segment starting with a dot (certificate-validation paths under `/.well-known/acme-challenge/`, `/.well-known/pki-validation/` and `/.well-known/cf-custom-hostname-challenge/` are allowed), any segment ending in `.php`, paths starting with `/wp-admin`, `/wp-includes`, `/cgi-bin`, `/phpmyadmin`, `/vendor/phpunit` or `/@fs`, the paths `/null` and `/undefined`, and private-key file names (`id_rsa`, `id_dsa`, `id_ecdsa`, `id_ed25519`, `*.key`, `*.pem`). Paths under `/wp-content/` are allowed.

Scope: `write_redirects`

```curl
curl -X POST 'https://api-store.tringify.com/api/2025-01/redirects' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "kind": "manual",
  "path": "/old-page",
  "redirect_type": 301,
  "target": "/new-page"
}'
```

Response:

```json
{"success":true,"data":{"id":"9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37","kind":"manual","kind_display":"Exact","path":"/old-page","target":"/new-page","redirect_type":301,"hit_count":4,"last_used_at":"2026-08-10T09:15:00-04:00","usage_available":true,"created_at":"2026-08-03T12:00:00-04:00","updated_at":"2026-08-03T12:00:00-04:00"}}
```

## Update a URL redirect

`PUT /api/2025-01/redirects/{redirectId}`

Omitted fields stay unchanged. Platform-generated `auto_slug` and `system_prefix` rows cannot be changed.

Scope: `write_redirects`

```curl
curl -X PUT 'https://api-store.tringify.com/api/2025-01/redirects/9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "path": "/old-page",
  "redirect_type": 301,
  "target": "/new-page"
}'
```

Response:

```json
{"success":true,"data":{"id":"9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37","kind":"manual","kind_display":"Exact","path":"/old-page","target":"/new-page","redirect_type":301,"hit_count":4,"last_used_at":"2026-08-10T09:15:00-04:00","usage_available":true,"created_at":"2026-08-03T12:00:00-04:00","updated_at":"2026-08-03T12:00:00-04:00"}}
```

## Delete a URL redirect

`DELETE /api/2025-01/redirects/{redirectId}`

Platform-generated `auto_slug` and `system_prefix` rows cannot be deleted.

Scope: `write_redirects`

```curl
curl -X DELETE 'https://api-store.tringify.com/api/2025-01/redirects/9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN"
```

Response:

```json
{"success":true,"code":"REDIRECT_DELETED","message":"Redirect deleted."}
```

## Bulk delete URL redirects

`POST /api/2025-01/redirects/bulk-delete`

The configured bulk cap is returned by the limits endpoint. The request is atomic: an invalid or platform-generated id rejects the selection without deleting the other rows. Unknown ids are ignored, duplicate ids are deleted once, and deleted reports the actual count.

Scope: `write_redirects`

```curl
curl -X POST 'https://api-store.tringify.com/api/2025-01/redirects/bulk-delete' \
  -H "Authorization: Bearer YOUR_STORE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "ids": [
    "9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37"
  ]
}'
```

Response:

```json
{"success":true,"code":"REDIRECT_BULK_DELETED","message":"2 redirects deleted.","data":{"deleted":2}}
```

## Webhook events

Subscribe to redirect events to mirror every committed create, update, and delete.

## Redirect created

Event: `redirects/create` · App scope: `read_redirects` · Staff permission: `online_store.redirects:write`

Fired when a URL redirect is created — manually, by a slug change, or by a permalink rename.

```json
{
  "redirect": {
    "created_at": "2026-06-09T12:00:00-04:00",
    "id": "9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37",
    "kind": "manual",
    "locale": "fr",
    "path": "/old-summer-sale",
    "redirect_type": 301,
    "target": "/collections/summer-essentials",
    "updated_at": "2026-06-09T12:00:00-04:00"
  }
}
```

## Redirect updated

Event: `redirects/update` · App scope: `read_redirects` · Staff permission: `online_store.redirects:write`

Fired when a URL redirect is updated.

```json
{
  "redirect": {
    "created_at": "2026-06-09T12:00:00-04:00",
    "id": "9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37",
    "kind": "manual",
    "locale": "fr",
    "path": "/old-summer-sale",
    "redirect_type": 301,
    "target": "/collections/summer-essentials",
    "updated_at": "2026-06-09T12:00:00-04:00"
  }
}
```

## Redirect deleted

Event: `redirects/delete` · App scope: `read_redirects` · Staff permission: `online_store.redirects:write`

Fired when a URL redirect is deleted.

```json
{
  "redirect": {
    "id": "9a7e4a90-9ac4-4aa6-aeb8-baad66d9fc37",
    "path": "/old-summer-sale"
  }
}
```

