Complete API reference for managing redirects programmatically. All endpoints require authentication.
All API requests must include authentication. RedirectFlow uses session-based authentication for web requests.
Content-Type: application/json Cookie: next-auth.session-token=your-session-token
Note: API tokens are available on Pro and Business plans. Contact support for details.
https://your-domain.com/api
Replace with your actual RedirectFlow instance URL
/api/redirectsRetrieve all redirects for authenticated user
| Name | Type | Description |
|---|---|---|
| website_id | integer | Filter by website ID |
| group | string | Filter by redirect group |
{
"redirects": [
{
"id": 1,
"old_path": "/old-blog",
"new_path": "/blog",
"status_code": 301,
"is_regex": false,
"group_id": "blog",
"website_id": 1,
"target_environments": "production,staging",
"deployed_to_prod": "2024-01-15T10:30:00Z",
"deployed_to_staging": "2024-01-15T10:29:00Z",
"deployed_to_dev": null,
"created_at": "2024-01-15T09:00:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
]
}/api/redirectsCreate a new redirect
{
"old_path": "/old-page",
"new_path": "/new-page",
"status_code": 301,
"is_regex": false,
"group_id": "migration",
"website_id": 1,
"target_environments": "production",
"notes": "Migration redirect for old page"
}{
"redirect": {
"id": 2,
"old_path": "/old-page",
"new_path": "/new-page",
"status_code": 301,
"is_regex": false,
"group_id": "migration",
"website_id": 1,
"target_environments": "production",
"notes": "Migration redirect for old page",
"created_at": "2024-01-15T11:00:00Z",
"updated_at": "2024-01-15T11:00:00Z"
}
}/api/redirects/{id}Update an existing redirect
{
"old_path": "/updated-old-path",
"new_path": "/updated-new-path",
"status_code": 302,
"target_environments": "production,staging"
}{
"redirect": {
"id": 2,
"old_path": "/updated-old-path",
"new_path": "/updated-new-path",
"status_code": 302,
"target_environments": "production,staging",
"updated_at": "2024-01-15T12:00:00Z"
}
}/api/redirects/{id}Delete a redirect
{
"message": "Redirect deleted successfully"
}/api/redirects/bulk-updateUpdate multiple redirects at once
{
"redirectIds": [1, 2, 3],
"updates": {
"target_environments": "production,staging,development",
"group_id": "updated-group"
}
}{
"updated": 3,
"message": "Redirects updated successfully"
}/api/redirects/bulk-deleteDelete multiple redirects at once
{
"redirectIds": [1, 2, 3]
}{
"deleted": 3,
"message": "Redirects deleted successfully"
}/api/redirects/importImport redirects from CSV file
FormData with CSV file
{
"imported": 25,
"skipped": 2,
"errors": [],
"message": "Import completed successfully"
}The API uses conventional HTTP response codes to indicate success or failure.
| Code | Message | Description |
|---|---|---|
| 400 | Bad Request | Invalid request parameters or body |
| 401 | Unauthorized | Authentication required |
| 403 | Forbidden | Insufficient permissions or usage limits exceeded |
| 404 | Not Found | Redirect not found |
| 409 | Conflict | Redirect with same path already exists |
| 422 | Unprocessable Entity | Validation errors |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server error occurred |
// Create a new redirect
const response = await fetch('/api/redirects', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include', // Include cookies for session auth
body: JSON.stringify({
old_path: '/old-page',
new_path: '/new-page',
status_code: 301,
website_id: 1,
target_environments: 'production'
})
});
const result = await response.json();
console.log('Created redirect:', result.redirect);curl -X POST https://your-domain.com/api/redirects \
-H "Content-Type: application/json" \
-H "Cookie: next-auth.session-token=your-session-token" \
-d '{
"old_path": "/old-page",
"new_path": "/new-page",
"status_code": 301,
"website_id": 1,
"target_environments": "production"
}'