URL redirect management with logging and statistics. Supports permanent (301, 308) and temporary (302, 307) redirects, regex pattern matching, and query string preservation.
12 endpoints
GET /redirects
List redirects
Returns all configured redirects with hit counts.
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
Examples
curl https://api.lynkow.com/v1/redirects \
-H "Authorization: Bearer $API_TOKEN"Response Example
{
"data": [
{
"id": 1,
"sourcePath": "/old-blog",
"targetUrl": "/blog",
"statusCode": 301,
"isRegex": false,
"isActive": true,
"preserveQueryString": true,
"hitCount": 237,
"lastHitAt": "2025-04-05T18:22:00.000Z",
"createdAt": "2025-02-01T10:00:00.000Z"
},
{
"id": 2,
"sourcePath": "/products/(.*)",
"targetUrl": "/shop/$1",
"statusCode": 301,
"isRegex": true,
"isActive": true,
"preserveQueryString": false,
"hitCount": 89,
"lastHitAt": "2025-04-06T09:10:00.000Z",
"createdAt": "2025-03-15T14:00:00.000Z"
}
],
"meta": {
"total": 24,
"perPage": 15,
"currentPage": 1,
"lastPage": 2
}
}POST /redirects
Create a redirect
Creates a new URL redirect. Provide sourcePath, targetUrl,
statusCode (301, 302, 307, 308), and optional isRegex flag
for pattern matching.
Request Body
Content-Type: application/json
Field | Type | Required | Description |
|---|---|---|---|
| string | Yes | Required. 1-2048 characters |
| string | Yes | Required. 1-2048 characters |
| "301" | "302" | "307" | "308" | No | One of: 301, 302, 307, 308 |
| boolean | No | Boolean |
| boolean | No | Boolean |
| boolean | No | Boolean |
| string | No | Max 500 characters |
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
| Validation error |
Examples
curl -X POST https://api.lynkow.com/v1/redirects \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"sourcePath": "/old-page",
"targetUrl": "/new-page",
"statusCode": 301,
"preserveQueryString": true
}'Response Example
{
"data": {
"id": 25,
"sourcePath": "/old-page",
"targetUrl": "/new-page",
"statusCode": 301,
"isRegex": false,
"isActive": true,
"preserveQueryString": true,
"hitCount": 0,
"lastHitAt": null,
"createdAt": "2025-04-06T11:45:00.000Z"
}
}GET /redirects/stats
Get redirect statistics
Returns aggregate redirect stats (total redirects, total hits, most used).
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
Examples
curl https://api.lynkow.com/v1/redirects/stats \
-H "Authorization: Bearer $API_TOKEN"Response Example
{
"total": 42,
"active": 38,
"inactive": 4,
"totalHits": 1250
}GET /redirects/match
Test redirect matching
Tests if a given URL path matches any configured redirect. Useful for debugging redirect rules without triggering an actual redirect.
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
Examples
curl "https://api.lynkow.com/v1/redirects/match?path=/old-page" \
-H "Authorization: Bearer $API_TOKEN"Response Example
{
"data": {
"id": 25,
"sourcePath": "/old-page",
"targetUrl": "/new-page",
"statusCode": 301,
"isRegex": false,
"isActive": true
}
}GET /redirects/export
Export redirects as CSV
Downloads all redirects as a CSV file.
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
Examples
curl "https://api.lynkow.com/v1/redirects/export" \
-H "Authorization: Bearer $API_TOKEN" \
-o redirects.csvResponse Example
"Returns a CSV file (Content-Type: text/csv). Example output:\nsource_path,target_url,status_code,is_regex,is_active,hit_count\n\"/old-blog\",\"/blog\",301,false,true,237\n"POST /redirects/import
Import redirects from CSV
Imports redirects from a CSV file. Expected columns: sourcePath, targetUrl, statusCode, isRegex, preserveQueryString.
Request Body
Content-Type: application/json
Field | Type | Required | Description |
|---|---|---|---|
| object[] | Yes | Required. Array of objects |
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
| Validation error |
Notes: - Duplicate source paths are skipped.
Examples
curl -X POST https://api.lynkow.com/v1/redirects/import \
-H "Authorization: Bearer $API_TOKEN" \
-F "[email protected]"Response Example
{
"imported": 18,
"skipped": 2,
"errors": []
}POST /redirects/bulk-delete
Bulk delete redirects
Permanently deletes multiple redirects at once.
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
| Validation error |
Examples
curl -X POST https://api.lynkow.com/v1/redirects/bulk-delete \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"ids": [10, 11, 12, 13, 14]}'Response Example
{
"deleted": 5
}GET /redirects/:id
Get a redirect
Returns a single redirect with its configuration and hit count.
Parameters
Name | In | Type | Required | Description |
|---|---|---|---|---|
| path | string | Yes | Unique identifier |
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
| Not found |
Examples
curl https://api.lynkow.com/v1/redirects/1 \
-H "Authorization: Bearer $API_TOKEN"Response Example
{
"data": {
"id": 1,
"sourcePath": "/old-blog",
"targetUrl": "/blog",
"statusCode": 301,
"isRegex": false,
"isActive": true,
"preserveQueryString": true,
"hitCount": 237,
"lastHitAt": "2025-04-05T18:22:00.000Z",
"createdAt": "2025-02-01T10:00:00.000Z",
"updatedAt": "2025-02-01T10:00:00.000Z"
}
}PUT /redirects/:id
Update a redirect
Updates a redirect's source path, target URL, status code, or options.
Parameters
Name | In | Type | Required | Description |
|---|---|---|---|---|
| path | string | Yes | Unique identifier |
Request Body
Content-Type: application/json
Field | Type | Required | Description |
|---|---|---|---|
| string | No | 1-2048 characters |
| string | No | 1-2048 characters |
| "301" | "302" | "307" | "308" | No | One of: 301, 302, 307, 308 |
| boolean | No | Boolean |
| boolean | No | Boolean |
| boolean | No | Boolean |
| string | No | Max 500 characters |
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
| Not found |
| Validation error |
Examples
curl -X PUT https://api.lynkow.com/v1/redirects/1 \
-H "Authorization: Bearer $API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"targetUrl": "/new-blog",
"statusCode": 302
}'Response Example
{
"data": {
"id": 1,
"sourcePath": "/old-blog",
"targetUrl": "/new-blog",
"statusCode": 302,
"isRegex": false,
"isActive": true,
"preserveQueryString": true,
"hitCount": 237,
"lastHitAt": "2025-04-05T18:22:00.000Z",
"createdAt": "2025-02-01T10:00:00.000Z",
"updatedAt": "2025-04-06T12:00:00.000Z"
}
}DELETE /redirects/:id
Delete a redirect
Permanently deletes a redirect.
Parameters
Name | In | Type | Required | Description |
|---|---|---|---|---|
| path | string | Yes | Unique identifier |
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
| Not found |
Examples
curl -X DELETE https://api.lynkow.com/v1/redirects/1 \
-H "Authorization: Bearer $API_TOKEN"Response Example
{
"message": "Redirect deleted"
}POST /redirects/:id/toggle
Toggle redirect active state
Enables or disables a redirect without deleting it.
Parameters
Name | In | Type | Required | Description |
|---|---|---|---|---|
| path | string | Yes | Unique identifier |
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
| Not found |
| Validation error |
Examples
curl -X POST https://api.lynkow.com/v1/redirects/1/toggle \
-H "Authorization: Bearer $API_TOKEN"Response Example
{
"data": {
"id": 1,
"sourcePath": "/old-blog",
"targetUrl": "/blog",
"statusCode": 301,
"isRegex": false,
"isActive": false,
"preserveQueryString": true,
"hitCount": 237,
"lastHitAt": "2025-04-05T18:22:00.000Z",
"createdAt": "2025-02-01T10:00:00.000Z",
"updatedAt": "2025-04-06T12:00:00.000Z"
}
}GET /redirects/:id/logs
Get redirect click logs
Returns the hit log for a redirect (timestamp, referrer, user agent).
Parameters
Name | In | Type | Required | Description |
|---|---|---|---|---|
| path | string | Yes | Unique identifier |
Responses
Status | Description |
|---|---|
| Successful response |
| Unauthorized — invalid or missing API token |
| Forbidden — insufficient permissions |
| Not found |
Examples
curl https://api.lynkow.com/v1/redirects/1/logs \
-H "Authorization: Bearer $API_TOKEN"Response Example
{
"data": [
{
"id": 1,
"redirectId": 1,
"referrer": "https://google.com/search?q=example",
"userAgent": "Mozilla/5.0",
"ipAddress": "203.0.113.42",
"createdAt": "2025-04-05T18:22:00.000Z"
},
{
"id": 2,
"redirectId": 1,
"referrer": null,
"userAgent": "Mozilla/5.0",
"ipAddress": "198.51.100.17",
"createdAt": "2025-04-05T14:10:00.000Z"
}
],
"meta": {
"total": 237,
"perPage": 15,
"currentPage": 1,
"lastPage": 16
}
}