Skip to content

Import a zone redirect map from CSV

POST
/api/zones/{zoneId}/redirect-map/import

Replaces or extends the zone's redirect map from a CSV upload (multipart field file).

CSV columns, in order:

  • source (required): the exact match key as "host/path", e.g. www.example.com/old. The host is lowercased; the path is kept as-is.
  • target (required): the redirect destination - a full URL (e.g. https://www.example.com/new), or a bare host when mode is H.
  • mode (optional, default L): L = literal (target is the final URL), Q = preserve-query (the incoming query string is appended to the target), H = host-swap (keep the incoming path, swap only the host).
  • status (optional, default 301): the HTTP redirect code, one of 301, 302, 307, 308.

A leading source,target header row is ignored, as are blank lines and lines starting with #. The multipart form field mode chooses "replace" (default - the upload becomes the entire map) or "append" (the upload is merged into the existing map).

Validation before storage: rows with a missing source/target, an invalid mode, or an invalid status are skipped; duplicate sources are rejected (the first is kept); redirect chains (A to B to C) are collapsed to a single hop (A to C); and cycles (A to B to A) are rejected. Skipped or rejected rows do not fail the request - the response reports how many entries were stored (imported), how many chains were collapsed (collapsed), and a message per problem row (errors).

Authorizations

ApiToken

Long-lived API token created via POST /api/api-tokens (returned once in plaintext). A token created with readOnly may only perform safe requests (GET, HEAD, OPTIONS); write requests are rejected on every endpoint.

Type
API Key (header: X-API-TOKEN)
or
JWT

JWT access token obtained via POST /api/auth/login. Send as: Authorization: Bearer .

Type
HTTP (bearer)

Parameters

Path Parameters

zoneId*

Zone identifier

Type
string
Required

Request Body

multipart/form-data
object

CSV file with columns "source,target[,mode][,status]" (an optional header row is ignored). See the endpoint description for each column's allowed values and defaults.

Format"binary"

"replace" (default) overwrites the whole map with the upload; "append" merges the upload into the existing map.

Valid values"replace""append"
Default"replace"

Responses

redirect-map resource created

JSON
{
  
"@context": "string",
  
"@id": "string",
  
"@type": "string",
  
"imported": 3,
  
"collapsed": 1,
  
"errors": [
  
  
"string"
  
]
}

Playground

Authorization
Variables
Key
Value
Body

Samples

Powered by VitePress OpenAPI