Redirects API
Manage URL redirect rules with full CRUD operations
Complete reference for managing URL redirects through the REST API.
Overview
The Redirects API allows you to create, read, update, and delete URL redirect rules. All endpoints require authentication using a valid JWT token.
Authentication
All API requests require authentication using a Bearer token in the Authorization header.
Request Headers:
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Required | Bearer token for API authentication Example: |
Content-Type | string | Required | Media type of the request body (for POST/PUT/PATCH requests) Example: |
Example:
{
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"Content-Type": "application/json"
}See below for detailed documentation of each endpoint including request/response formats and examples.
/api/v1/redirects
Create Redirect
Creates a new redirect rule.
Request Body
Provide the redirect configuration data.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
source | string | Required | The source URL path to redirect from Example: |
destination | string | Required | The destination URL path to redirect to Example: |
domain | string | Optional | The domain for the redirect (optional). Domain-based redirect will redirect to external URL instead of internal path. Example: |
statusCode | number | Required | HTTP status code for the redirect (e.g., 301, 302) Example: |
enabled | boolean | Required | Whether the redirect is active or not Example: |
Example:
{
"source": "/old-page",
"destination": "/new-page",
"domain": "example.com",
"statusCode": 301,
"enabled": true
}Response Structure
Response format and possible status codes for creating a redirect.
Created. Redirect created successfully.
Example Response:
{
"message": "Redirect created successfully",
"location": "/redirects/1"
}Bad Request. Invalid request body or validation error.
Example Response:
{
"error": {
"code": "BAD_REQUEST",
"message": "Invalid request body or validation error",
"details": "source field is required"
}
}Conflict. Redirect already exists (duplicate source URL).
Example Response:
{
"error": {
"code": "CONFLICT",
"message": "Redirect already exists (duplicate source URL)"
}
}/api/v1/redirects
Get Redirects
Retrieves all existing redirects in the system with pagination support.
Pagination Parameters
Control pagination behavior and sorting options.
Available Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
paginationType | string | Optional | offset | Pagination type offset or cursor Example: |
page | number | Optional | 1 | Page number for offset pagination min: 1 Example: |
limit | number | Optional | 10 | Items per page for offset pagination min: 1, max: 100 Example: |
cursor | string | Optional | null | Cursor for cursor pagination Example: |
first | number | Optional | 10 | Number of items for cursor pagination min: 1, max: 100 Example: |
sortBy | string | Optional | id | Sort field id, createdAt, updatedAt, source, destination Example: |
sortOrder | string | Optional | asc | Sort order asc or desc Example: |
Example Request:
GET /api/v1/redirects?page=1&limit=10&sortBy=createdAt&sortOrder=descFiltering Parameters
Filter redirects based on various criteria.
Available Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
statusCode | string | Optional | - | Filter by status code Example: |
statusCodeOp | string | Optional | eq | Status code operator eq, ne, in, notIn Example: |
source | string | Optional | - | Filter by source URL path Example: |
sourceOp | string | Optional | eq | Source operator eq, ne, contains, startsWith, endsWith Example: |
destination | string | Optional | - | Filter by destination URL path Example: |
destinationOp | string | Optional | eq | Destination operator eq, ne, contains, startsWith, endsWith Example: |
Example Request:
GET /api/v1/redirects?statusCode=301,302&statusCodeOp=in&source=/old&sourceOp=startsWithResponse (Offset Pagination)
Response structure for offset-based pagination.
Successfully retrieved redirects with pagination data.
Example Response:
{
"data": [
{
"id": 1,
"source": "/old-page",
"destination": "/new-page",
"domain": "example.com",
"statusCode": 301,
"createdAt": "2025-12-11T17:23:00.000Z",
"updatedAt": "2025-12-11T17:23:00.000Z",
"enabled": true,
"isCaseSensitive": false
}
],
"pagination": {
"total": 100,
"page": 1,
"limit": 10,
"hasNext": true,
"hasPrev": false
}
}Bad Request. Invalid query parameters.
Example Response:
{
"error": {
"code": "BAD_REQUEST",
"message": "Invalid query parameters",
"details": "page must be a positive integer"
}
}/api/v1/redirects/:id
Update Redirect
Completely updates an existing redirect with new values. All fields are required.
Path Parameters
URL path parameters required for this endpoint.
Required Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | number | Required | The unique identifier of the redirect Example: |
Example URL:
PUT /api/v1/redirects/1Request Body
Provide complete redirect data to replace existing redirect. All fields are required.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
source | string | Required | The source URL path to redirect from Example: |
destination | string | Required | The destination URL path to redirect to Example: |
domain | string | Optional | The domain for the redirect (optional). Domain-based redirect will redirect to external URL instead of internal path. Example: |
statusCode | number | Required | HTTP status code for the redirect (e.g., 301, 302) Example: |
enabled | boolean | Required | Whether the redirect is active or not Example: |
Example:
{
"source": "/updated-old-page",
"destination": "/updated-new-page",
"domain": "example.com",
"statusCode": 302,
"enabled": true
}Response Structure
Response format and possible status codes for updating a redirect.
OK. Redirect updated successfully.
Example Response:
{
"message": "Redirect updated successfully",
"location": "/redirects/1"
}Bad Request. Invalid request body or validation error.
Example Response:
{
"error": {
"code": "BAD_REQUEST",
"message": "Invalid request body or validation error"
}
}Not Found. Redirect with specified ID not found.
Example Response:
{
"error": {
"code": "NOT_FOUND",
"message": "Redirect with specified ID not found"
}
}Conflict. Updated redirect conflicts with existing redirect.
Example Response:
{
"error": {
"code": "CONFLICT",
"message": "Updated redirect conflicts with existing redirect"
}
}/api/v1/redirects/:id
Patch Redirect
Partially updates an existing redirect. Only provided fields are updated.
Path Parameters
URL path parameters required for this endpoint.
Required Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | number | Required | The unique identifier of the redirect Example: |
Example URL:
PATCH /api/v1/redirects/1Request Body (all fields optional)
Provide only the fields you want to update.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
destination | string | Optional | The destination URL path to redirect to Example: |
enabled | boolean | Optional | Whether the redirect is active or not Example: |
Example:
{
"destination": "/partially-updated-page",
"enabled": false
}Response Structure
Response format and possible status codes for partially updating a redirect.
OK. Redirect updated successfully.
Example Response:
{
"message": "Redirect updated successfully",
"location": "/redirects/1"
}Bad Request. Invalid request body or validation error.
Example Response:
{
"error": {
"code": "BAD_REQUEST",
"message": "Invalid request body or validation error"
}
}Not Found. Redirect with specified ID not found.
Example Response:
{
"error": {
"code": "NOT_FOUND",
"message": "Redirect with specified ID not found"
}
}Conflict. Updated redirect conflicts with existing redirect.
Example Response:
{
"error": {
"code": "CONFLICT",
"message": "Updated redirect conflicts with existing redirect"
}
}/api/v1/redirects/:id
Delete Redirect
Deletes a specific redirect by its ID.
Path Parameters
URL path parameters required for this endpoint.
Required Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | number | Required | The unique identifier of the redirect to delete Example: |
Example URL:
DELETE /api/v1/redirects/1Response Structure
Response format and possible status codes for deleting a redirect.
No Content. Redirect deleted successfully (empty response body).
Bad Request. Invalid redirect ID format.
Example Response:
{
"error": {
"code": "BAD_REQUEST",
"message": "Invalid redirect ID format"
}
}Not Found. Redirect with specified ID not found.
Example Response:
{
"error": {
"code": "NOT_FOUND",
"message": "Redirect with specified ID not found"
}
}/api/v1/redirects/batch
Batch Create Redirects
Creates multiple redirect rules in a single request.
Request Body
Provide an array of redirect configurations to create.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
redirects | array | Required | Array of redirect objects to create Example: |
Example:
{
"redirects": [
{
"source": "/old-page-1",
"destination": "/new-page-1",
"domain": "example.com",
"statusCode": 301,
"enabled": true
},
{
"source": "/old-page-2",
"destination": "/new-page-2",
"statusCode": 302,
"enabled": true
}
]
}Response Structure
Response format and possible status codes for batch creating redirects.
Created. All redirects created successfully.
Example Response:
{
"message": "All redirects created successfully.",
"createdRedirects": [
{
"message": "Redirect created successfully",
"location": "/redirects/1"
}
],
"createdCount": 1
}Multi-Status. Some redirects were invalid and were not created.
Example Response:
{
"message": "Some redirects were invalid and were not created",
"createdRedirects": [],
"createdCount": 0,
"errors": [
"Invalid redirect data"
]
}Bad Request. Invalid request body, empty array, or all redirects invalid.
Example Response:
{
"error": {
"code": "BAD_REQUEST",
"message": "Invalid request body, empty array, or all redirects invalid"
}
}/api/v1/redirects/batch
Batch Update Redirects
Partially updates multiple redirect rules in a single request. Only provided fields are updated for each redirect.
Request Body
Provide an array of redirect objects with ID and fields to update.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
redirects | array | Required | Array of redirect objects with ID and fields to update Example: |
Example:
{
"redirects": [
{
"id": 1,
"destination": "/updated-page-1",
"enabled": false
},
{
"id": 2,
"statusCode": 302,
"enabled": true
}
]
}Response Structure
Response format and possible status codes for batch updating redirects.
OK. All redirects updated successfully.
Example Response:
{
"message": "All redirects updated successfully.",
"updatedRedirects": [
{
"message": "Redirect updated successfully",
"id": 1,
"location": "/redirects/1"
}
],
"updatedCount": 1
}Multi-Status. Some redirects could not be updated.
Example Response:
{
"message": "Some redirects could not be updated",
"updatedRedirects": [],
"updatedCount": 0,
"errors": [
"Redirect not found"
]
}Bad Request. Invalid request body, empty array, or all updates invalid.
Example Response:
{
"error": {
"code": "BAD_REQUEST",
"message": "Invalid request body, empty array, or all updates invalid"
}
}/api/v1/redirects/batch
Batch Delete Redirects
Deletes multiple redirect rules in a single request.
Request Body
Provide an array of redirect IDs to delete.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
ids | array | Required | Array of redirect IDs to delete Example: |
Example:
{
"ids": [
1,
2,
3,
4
]
}Response Structure
Response format and possible status codes for batch deleting redirects.
OK. Redirects deleted successfully.
Example Response:
{
"message": "Redirects deleted successfully",
"deletedCount": 4
}Bad Request. Invalid request body or empty IDs array.
Example Response:
{
"error": {
"code": "BAD_REQUEST",
"message": "Invalid request body or empty IDs array"
}
}