← Home
POST/hyax-api/v1/redirects

Create redirects

Create one redirect by sending its fields directly, or up to 500 at once as `{ "redirects": [ … ] }`. Each needs `from` and a destination: `to` (a path on your site or a full `https://` URL) or `postId` (leads to that post and keeps following it if its URL changes). End `from` with `/*` to cover everything under a section, and end `to` with `/*` too to keep each page's own address: `/old-section/*` to `/new-section/*`. A batch never fails as a whole — rules that can't be created come back under `rejected` with the reason (the old address still serves a live page, the rule would loop, the path is reserved, or it already redirects elsewhere). A single redirect that is refused returns `400`.

Base URL: https://platform.hyax.com · Replace YOUR_API_KEY with your team API key.

Request body

FieldRequiredDescription
from Required Old path or full URL. End with `/*` for a whole section.
toNoDestination path or `https://` URL. Leave out when `postId` is given.
postIdNoLead to this post wherever it lives
statusCodeNo`301` | `302` | `307` | `308`. Default `302` with `to` (so you can check it first), `301` with `postId`.
redirectsNoArray of the fields above, to create several at once

Request

curl -X POST 'https://platform.hyax.com/hyax-api/v1/redirects' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "redirects": [
      {
        "from": "/2019/05/old-post",
        "to": "/article/new-post",
        "statusCode": 301
      },
      {
        "from": "/gaming/*",
        "to": "/article/*",
        "statusCode": 301
      },
      {
        "from": "/old-name",
        "postId": "clx…"
      }
    ]
  }'

Response

{
  "success": true,
  "data": [
    { "id": "clx…", "from": "/2019/05/old-post", "to": "/article/new-post", "statusCode": 301 }
  ],
  "rejected": [
    {
      "from": "/gaming/*",
      "to": "/article/*",
      "postId": null,
      "error": "/gaming/* would hide your landing pages under /gaming, such as "Launch"."
    }
  ],
  "summary": { "created": 1, "rejected": 1 }
}